From 048cfb3ee239f9a919c359b7adc94b256fd5852a Mon Sep 17 00:00:00 2001
From: Erik Thuning <boooink@gmail.com>
Date: Wed, 21 Feb 2024 11:37:35 +0100
Subject: [PATCH] match is a keyword in php8, so renamed the match() function
 accordingly

---
 include/Product.php   | 10 +++++-----
 include/User.php      | 12 ++++++------
 include/functions.php |  2 +-
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/Product.php b/include/Product.php
index 2b246c0..3de4598 100644
--- a/include/Product.php
+++ b/include/Product.php
@@ -142,7 +142,7 @@ class Product extends Entity {
                     // If $key is a standard field, check against its value
                     $getter = $fields[$key];
                     $value = $this->$getter();
-                    if(match($term, $value)) {
+                    if(match_term($term, $value)) {
                         //Record a successful match
                         $matches[$key] = $value;
                         $matched = true;
@@ -170,7 +170,7 @@ class Product extends Entity {
                     // First check basic fields
                     foreach($fields as $field => $getter) {
                         $value = $this->$getter();
-                        if(match($term, $value)) {
+                        if(match_term($term, $value)) {
                             $matches[$field] = $value;
                             $matched = true;
                         }
@@ -189,7 +189,7 @@ class Product extends Entity {
                     }
                     // Then custom fields
                     foreach($this->get_info() as $field => $value) {
-                        if(match($term, $value)) {
+                        if(match_term($term, $value)) {
                             //Record a successful match
                             $matches[$field] = $value;
                             $matched = true;
@@ -202,7 +202,7 @@ class Product extends Entity {
                     if(isset($info[$key])) {
                         // If $key is a valid custom field on this product
                         $value = $info[$key];
-                        if(match($term, $value)) {
+                        if(match_term($term, $value)) {
                             //Record a successful match
                             $matches[$key] = $value;
                             $matched = true;
@@ -228,7 +228,7 @@ class Product extends Entity {
         $tags = $this->get_tags();
         $matches = array();
         foreach($tags as $tag) {
-            if(match($term, $tag)) {
+            if(match_term($term, $tag)) {
                 $matches[] = $tag;
             }
         }
diff --git a/include/User.php b/include/User.php
index ba218b4..9d15791 100644
--- a/include/User.php
+++ b/include/User.php
@@ -55,12 +55,12 @@ class User extends Entity {
                 case 'name':
                     // If the key is name, check username and displayname
                     $name = $this->get_name();
-                    if(match($term, $name)) {
+                    if(match_term($term, $name)) {
                         $matches['name'] = $name;
                         $matched = true;
                     }
                     $dname = $this->get_displayname($ldap);
-                    if(match($term, $dname)) {
+                    if(match_term($term, $dname)) {
                         $matches['displayname'] = $dname;
                         $matched = true;
                     }
@@ -68,14 +68,14 @@ class User extends Entity {
                 case 'note':
                     // If the key is note, check it.
                     $note = $this->get_note();
-                    if($note && match($term, $note)) {
+                    if($note && match_term($term, $note)) {
                         $matches['note'] = $note;
                         $matched = true;
                     }
                     break;
                 case 'email':
                     $email = $this->get_email($ldap, false);
-                    if($email && match($term, $email)) {
+                    if($email && match_term($term, $email)) {
                         $matches['email'] = $email;
                         $matched = true;
                     }
@@ -83,12 +83,12 @@ class User extends Entity {
                 case 'fritext':
                     //Check everything if the key is fritext
                     $name = $this->get_name();
-                    if(match($term, $name)) {
+                    if(match_term($term, $name)) {
                         $matches['name'] = $name;
                         $matched = true;
                     }
                     $dname = $this->get_displayname($ldap);
-                    if(match($term, $dname)) {
+                    if(match_term($term, $dname)) {
                         $matches['displayname'] = $dname;
                         $matched = true;
                     }
diff --git a/include/functions.php b/include/functions.php
index b85f1b3..f265439 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -253,7 +253,7 @@ function suggest_content($fieldname) {
     return $out;
 }
 
-function match($term, $subject) {
+function match_term($term, $subject) {
     if(fnmatch('*'.$term->get_query().'*', $subject, FNM_CASEFOLD)) {
         return true;
     }