From 2479d46bbb5340d3bec38eb56c5c532ab9e998f7 Mon Sep 17 00:00:00 2001
From: Viktor Pedersen <viktor@dsv.su.se>
Date: Wed, 8 Sep 2021 16:36:38 +0200
Subject: [PATCH] testing search function

---
 include/Product.php    | 4 +---
 include/SearchPage.php | 8 ++++----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/include/Product.php b/include/Product.php
index 1808aca..46ed39f 100644
--- a/include/Product.php
+++ b/include/Product.php
@@ -120,9 +120,7 @@ class Product extends Entity {
                                                      'invoice',
                                                      'status',
                                                      'tag'));
-        print('DEBUG $terms post translation: ');
-        var_dump($terms);
-        print('<br><br>');
+        var_dump('DEBUG $terms post translation: ', $terms, '<br><br>');
         $matches = array();
         foreach($terms as $field => $values) {
             if(property_exists($this, $field)) {
diff --git a/include/SearchPage.php b/include/SearchPage.php
index 862edce..9be7a54 100644
--- a/include/SearchPage.php
+++ b/include/SearchPage.php
@@ -73,26 +73,26 @@ class SearchPage extends Page {
                         if (!array_key_exists($key, $mustMatchArray)) {
                             $mustMatchArray[$key] = array();
                         }
-                        $mustMatchArray[] = substr($parsedTerm, 1);
+                        $mustMatchArray[$key][] = substr($parsedTerm, 1);
                         break;
                     case "!":
                     case "-":
                         if (!array_key_exists($key, $cannotMatchArray)) {
                             $cannotMatchArray[$key] = array();
                         }
-                        $cannotMatchArray[] = array($key => substr($parsedTerm, 1));
+                        $cannotMatchArray[$key][] = substr($parsedTerm, 1);
                         break;
                     case "~":
                         if (!array_key_exists($key, $mayMatchArray)) {
                             $mayMatchArray[$key] = array();
                         }
-                        $mayMatchArray[] = array($key => substr($parsedTerm, 1));
+                        $mayMatchArray[$key][] = substr($parsedTerm, 1);
                         break;
                     default:
                         if (!array_key_exists($key, $mayMatchArray)) {
                             $mayMatchArray[$key] = array();
                         }
-                        $mayMatchArray[] = array($key => $parsedTerm);
+                        $mayMatchArray[$key][] = $parsedTerm;
                         break;
                 }
             }