[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [FIX] update field mapping only when in main tiki index

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6960ac0315ec3_3b180bf0902c4@gitlab-sidekiq-low-urgency-cpu-bound-v2-57f4f8bc5b-mg6pd.mail>

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


Commits:
18d44944 by Victor Emanouilov at 2026-01-09T09:19:23+02:00
[FIX] update field mapping only when in main tiki index

- - - - -


1 changed file:

- lib/core/Search/Manticore/Index.php


Changes:

=====================================
lib/core/Search/Manticore/Index.php
=====================================
@@ -51,25 +51,10 @@ class Index implements \Search_Index_Interface, \Search_Index_QueryRepository
 
     public function __destruct()
     {
-        global $prefs;
-
         if (! $this->dirty) {
             return;
         }
-
-        if (empty($this->index) || strstr($this->index, 'pref_')) {
-            return;
-        }
-
-        $fieldMapping = json_encode($this->fieldMapping);
-        if (empty($prefs['unified_field_mapping']) || $prefs['unified_field_mapping'] != $fieldMapping) {
-            TikiLib::lib('tiki')->set_preference('unified_field_mapping', $fieldMapping);
-        }
-
-        $dateFields = json_encode($this->dateFields);
-        if (empty($prefs['unified_date_fields']) || $prefs['unified_date_fields'] != $dateFields) {
-            TikiLib::lib('tiki')->set_preference('unified_date_fields', $dateFields);
-        }
+        $this->storeFieldMapping();
     }
 
     public function getClient()
@@ -217,14 +202,7 @@ class Index implements \Search_Index_Interface, \Search_Index_QueryRepository
         if ($mapping) {
             // store prefs on each index schema update as doing in __destruct is not reliable - various cases omit storing these prefs
             // and search results are missing fields later
-            $fieldMapping = json_encode($this->fieldMapping);
-            if (empty($prefs['unified_field_mapping']) || $prefs['unified_field_mapping'] != $fieldMapping) {
-                TikiLib::lib('tiki')->set_preference('unified_field_mapping', $fieldMapping);
-            }
-            $dateFields = json_encode($this->dateFields);
-            if (empty($prefs['unified_date_fields']) || $prefs['unified_date_fields'] != $dateFields) {
-                TikiLib::lib('tiki')->set_preference('unified_date_fields', $dateFields);
-            }
+            $this->storeFieldMapping();
         }
 
         $this->dirty = true;
@@ -747,6 +725,24 @@ class Index implements \Search_Index_Interface, \Search_Index_QueryRepository
         return $dateFields;
     }
 
+    protected function storeFieldMapping() {
+        global $prefs;
+
+        if (empty($this->index) || str_contains($this->index, 'pref_')) {
+            return;
+        }
+
+        $fieldMapping = json_encode($this->fieldMapping);
+        if (empty($prefs['unified_field_mapping']) || $prefs['unified_field_mapping'] != $fieldMapping) {
+            TikiLib::lib('tiki')->set_preference('unified_field_mapping', $fieldMapping);
+        }
+
+        $dateFields = json_encode($this->dateFields);
+        if (empty($prefs['unified_date_fields']) || $prefs['unified_date_fields'] != $dateFields) {
+            TikiLib::lib('tiki')->set_preference('unified_date_fields', $dateFields);
+        }
+    }
+
     protected function getWords($expr)
     {
         $words = [];



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/18d44944824cb7b7da02209368e66958c96352ea
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.