From 3a3ee7b76534506ae2ac0209d622f22764e7e8c9 Mon Sep 17 00:00:00 2001
From: Damien <damien.burel@maarch.org>
Date: Fri, 6 Nov 2020 16:08:31 +0100
Subject: [PATCH] FEAT #13271 TIME 0:20 Add migrateSQL messages + add longfield
 param for search

---
 migration/20.10/migrateSQL.php                  | 4 ++++
 src/app/search/controllers/SearchController.php | 9 ++++++---
 src/core/controllers/AutoCompleteController.php | 6 +++++-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/migration/20.10/migrateSQL.php b/migration/20.10/migrateSQL.php
index e5ed40dfe51..82015d69758 100644
--- a/migration/20.10/migrateSQL.php
+++ b/migration/20.10/migrateSQL.php
@@ -16,6 +16,8 @@ if (is_file("apps/maarch_entreprise/xml/config.json")) {
     foreach ($REQUESTS as $query) {
         $db->query($query);
     }
+
+    printf("Exécution du dernier script sql pour le socle.\n");
 }
 
 
@@ -32,5 +34,7 @@ foreach ($customs as $custom) {
         foreach ($REQUESTS as $query) {
             $db->query($query);
         }
+
+        printf("Exécution du dernier script sql pour le custom {$custom}.\n");
     }
 }
diff --git a/src/app/search/controllers/SearchController.php b/src/app/search/controllers/SearchController.php
index 188795b7f72..cb476e79c8d 100644
--- a/src/app/search/controllers/SearchController.php
+++ b/src/app/search/controllers/SearchController.php
@@ -332,7 +332,8 @@ class SearchController
                     'fields'        => $fields,
                     'where'         => [],
                     'data'          => [],
-                    'fieldsNumber'  => 3
+                    'fieldsNumber'  => 3,
+                    'longField'     => true
                 ]);
 
                 $fields = ['title', 'identifier'];
@@ -342,7 +343,8 @@ class SearchController
                     'fields'        => $fields,
                     'where'         => [],
                     'data'          => [],
-                    'fieldsNumber'  => 2
+                    'fieldsNumber'  => 2,
+                    'longField'     => true
                 ]);
 
                 if (!empty($requestDataDocument['where'])) {
@@ -389,7 +391,8 @@ class SearchController
                     'fields'        => $fields,
                     'where'         => [],
                     'data'          => [],
-                    'fieldsNumber'  => 1
+                    'fieldsNumber'  => 1,
+                    'longField'     => true
                 ]);
                 $subjectGlue = implode(' AND ', $requestData['where']);
                 $attachmentField = AutoCompleteController::getInsensitiveFieldsForRequest(['fields' => ['title']]);
diff --git a/src/core/controllers/AutoCompleteController.php b/src/core/controllers/AutoCompleteController.php
index cf63f696786..c5677d88426 100755
--- a/src/core/controllers/AutoCompleteController.php
+++ b/src/core/controllers/AutoCompleteController.php
@@ -945,7 +945,11 @@ class AutoCompleteController
                     }
                 }
                 for ($i = 0; $i < $args['fieldsNumber']; $i++) {
-                    $args['data'][] = ($isIncluded ? "%{$item}" : "%{$item}%");
+                    if (!empty($args['longField'])) {
+                        $args['data'][] = ($isIncluded ? "%{$item} %" : "%{$item}%");
+                    } else {
+                        $args['data'][] = ($isIncluded ? "%{$item}" : "%{$item}%");
+                    }
                 }
             }
         }
-- 
GitLab