[TikiWiki-commits] [Git][tikiwiki/tiki][24.x] [FIX] manticore/mysql index optimization: include object_id/type and partially...

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68ef35adeda66_2ce0cb83864a@gitlab-sidekiq-low-urgency-cpu-bound-v2-646f46c745-5h8fz.mail>

Victor Emanouilov pushed to branch 24.x at Tiki Wiki CMS Groupware / Tiki


Commits:
a6cb2769 by Victor Emanouilov at 2025-10-15T08:48:19+03:00
[FIX] manticore/mysql index optimization: include object_id/type and partially revert this change in search lookup controller as it needs field types like _text and _paths

- - - - -


3 changed files:

- lib/core/Search/MySql/Index.php
- lib/core/Search/Query.php
- lib/core/Services/Search/Controller.php


Changes:

=====================================
lib/core/Search/MySql/Index.php
=====================================
@@ -133,10 +133,10 @@ class Search_MySql_Index implements Search_Index_Interface
             $order = $this->getOrderClause($query, (bool) $scoreFields);
 
             if ($selectFields = $query->getSelectionFields()) {
-                $selectFields = array_map(function($field) {
+                $selectFields = array_map(function ($field) {
                     return $this->tfTranslator->shortenize($field);
                 }, $selectFields);
-            } else  {
+            } else {
                 $selectFields = $this->table->all();
             }
 


=====================================
lib/core/Search/Query.php
=====================================
@@ -49,6 +49,12 @@ class Search_Query implements Search_Query_Interface
 
     public function setSelectionFields(array $fields)
     {
+        if (! in_array('object_type', $fields)) {
+            $fields[] = 'object_type';
+        }
+        if (! in_array('object_id', $fields)) {
+            $fields[] = 'object_id';
+        }
         $this->selectionFields = $fields;
     }
 


=====================================
lib/core/Services/Search/Controller.php
=====================================
@@ -157,9 +157,7 @@ class Services_Search_Controller
             /** @var UnifiedSearchLib $lib */
             $lib = TikiLib::lib('unifiedsearch');
 
-            $format_pattern = '/\{([\w\.]+)\}/';
-
-            if (! empty($filter['title']) && preg_match_all($format_pattern, $format, $matches)) {
+            if (! empty($filter['title']) && preg_match_all('/\{(\w+)\}/', $format, $matches)) {
                 // formatted object_selector search results should also search in formatted fields besides the title
                 $titleFilter = $filter['title'];
                 unset($filter['title']);
@@ -187,18 +185,14 @@ class Services_Search_Controller
             $query->setOrder($input->sort_order->text() ?: 'title_asc');
             $query->setRange($input->offset->int(), $input->maxRecords->int() ?: $prefs['maxRecords']);
 
-            if (preg_match_all($format_pattern, $format, $m)) {
-                $query->setSelectionFields($m[1]);
-            }
-
             $result = $query->search($lib->getIndex());
 
-            $result->applyTransform(function ($item) use ($format, $format_pattern, $smarty) {
+            $result->applyTransform(function ($item) use ($format, $smarty) {
                 $transformed = [
                     'object_type' => $item['object_type'],
                     'object_id' => $item['object_id'],
                     'parent_id' => $item['gallery_id'],
-                    'title' => preg_replace_callback($format_pattern, function ($matches) use ($item, $format) {
+                    'title' => preg_replace_callback('/\{([\w\.]+)\}/', function ($matches) use ($item, $format) {
                         $key = $matches[1];
                         if (isset($item[$key])) {
                             // if this is a trackeritem we do not want only the name but also the trackerid listed when setting up a field



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/a6cb27693a26d9299ea8f03e710cc691100c18d6

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/a6cb27693a26d9299ea8f03e710cc691100c18d6
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.