[TikiWiki-commits] [Git][tikiwiki/tiki][30.x] [BP][FIX] Inconsistency of result in the Search (Formatter) when using more than one filter

"Elifeleti Mukisa Dan \(@Danelif\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69da249624a40_3b18ec8c3181d@gitlab-sidekiq-low-urgency-cpu-bound-v2-7476b97c7c-gt8sj.mail>

Elifeleti Mukisa Dan pushed to branch 30.x at Tiki Wiki CMS Groupware / Tiki


Commits:
99394c28 by Elifeleti Mukisa Dan at 2026-04-11T10:31:04+00:00
[BP][FIX] Inconsistency of result in the Search (Formatter) when using more than one filter
---
* [FIX] Inconsistency of result in the Search (Formatter) when using more than one filter
---
* [FIX] Allow multiples filter work for plugin customsearch

See merge request tikiwiki/tiki!9173


(cherry picked from commit f5db1c8231126e5eb38cc0654b3501b49c99484d)

07385fbd [FIX] Allow multiples filter work for plugin customsearch

Co-authored-by: Elifeleti Mukisa Dan <[email protected]>

See merge request tikiwiki/tiki!9991

- - - - -


2 changed files:

- lib/core/Search/Formatter/ValueFormatter/Trackerrender.php
- lib/core/Tracker/Filter/Collection.php


Changes:

=====================================
lib/core/Search/Formatter/ValueFormatter/Trackerrender.php
=====================================
@@ -36,6 +36,12 @@ class Search_Formatter_ValueFormatter_Trackerrender extends Search_Formatter_Val
     public function render($name, $value, array $entry)
     {
         if ($name === 'tracker_status') {
+            if (empty($entry['tracker_id'])) {
+                if (($entry['object_type'] ?? '') === 'trackeritem') {
+                    trigger_error('Trackerrender: tracker_id missing for tracker_status rendering of item ' . ($entry['object_id'] ?? 'unknown'), E_USER_WARNING);
+                }
+                return $value;
+            }
             $options  = TikiLib::lib('trk')->get_tracker_options($entry['tracker_id']);
             switch ($value) {
                 case 'o':
@@ -60,22 +66,25 @@ class Search_Formatter_ValueFormatter_Trackerrender extends Search_Formatter_Val
             return $value;
         }
 
-        $tracker = Tracker_Definition::get($entry['tracker_id']);
+        try {
+            $tracker = Tracker_Definition::get($entry['tracker_id']);
+        } catch (\Exception $e) {
+            if (($entry['object_type'] ?? '') === 'trackeritem') {
+                trigger_error('Trackerrender: ' . $e->getMessage() . ' for item ' . ($entry['object_id'] ?? 'unknown'), E_USER_WARNING);
+            }
+            return $value;
+        }
         if (! is_object($tracker)) {
             return $value;
         }
         if ($name === 'title') {
             // function getField works with either id of permName
-            $nameOrId = $tracker->getMainFieldId($entry['tracker_id']);
+            $nameOrId = $tracker->getMainFieldId();
         } else {
             $nameOrId = substr($name, 14);
         }
         $field = $tracker->getField($nameOrId);
 
-        if ($name === 'title') {
-            $name = 'tracker_field_' . $field['permName'];
-        }
-
         if (! $field) {
             if (Perms::get()->tracker_admin) {
                 return '~np~' . tr('Field rendering requested but field not found: %0', $name) . '~/np~';
@@ -84,6 +93,10 @@ class Search_Formatter_ValueFormatter_Trackerrender extends Search_Formatter_Val
             }
         }
 
+        if ($name === 'title') {
+            $name = 'tracker_field_' . $field['permName'];
+        }
+
         // check translations of multilingual fields
         global $prefs;
         if ($field['isMultilingual'] === 'y' && isset($entry[$name . '_' . $prefs['language']])) {


=====================================
lib/core/Tracker/Filter/Collection.php
=====================================
@@ -40,6 +40,24 @@ class Collection
                 return $item['label'];
             }, $types);
 
+            if ($mode === 'multiselect' || $mode === 'checkboxes') {
+                $controlClass = $mode === 'checkboxes' ? Control\InlineCheckboxes::class : Control\MultiSelect::class;
+                $controlField = $mode === 'checkboxes' ? 'tfc_status' : 'tfms_status';
+                $filter = new Filter($fieldName, $mode);
+                $filter->setLabel(tr('Status'))
+                    ->setControl(new $controlClass($controlField, $possibilities))
+                    ->setApplyCondition(function ($control, Search_Query $query) {
+                        $values = $control->getValues();
+                        if (! empty($values)) {
+                            $sub = $query->getSubQuery("tfms_status");
+                            foreach ($values as $v) {
+                                $sub->filterIdentifier((string) $v, 'tracker_status');
+                            }
+                        }
+                    });
+                return $filter;
+            }
+
             $filter = new Filter($fieldName, 'default');
             $filter->setLabel(tr('Status'))
                 ->setControl(new Control\DropDown("tracker_status_dd", $possibilities))



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/99394c28c97e3adc0ca5eb799a73161c9f7664aa
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
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.