[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] index: Ensure `$data` is checked before processing and report error if missing

"Jonny Bradley \(@jonnybradley\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a3142aea624b_38d5442c6950@gitlab-sidekiq-low-urgency-cpu-bound-v2-7d87cb8569-2dhd8.mail>

Jonny Bradley pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
2b794d01 by Jonny Bradley at 2026-06-16T12:16:04+00:00
[FIX] index: Ensure `$data` is checked before processing and report error if missing
---
* [FIX] index: Ensure `$data` is checked before processing and report error if missing

See merge request tikiwiki/tiki!10533

- - - - -


1 changed file:

- lib/core/Search/Formatter/DataSource/Declarative.php


Changes:

=====================================
lib/core/Search/Formatter/DataSource/Declarative.php
=====================================
@@ -59,22 +59,25 @@ class Search_Formatter_DataSource_Declarative implements Search_Formatter_DataSo
 
             if ($this->sourceProvidesValue($contentSource, $missingFields)) {
                 $data = $contentSource->getDocument($object, new Search_Type_Factory_Direct());
-                $used = $data;
 
-                if (is_int(key($data)) && ! is_null($hash)) {
-                    $used = reset($data);
+                if ($data) {
+                    $used = $data;
+                    if (is_int(key($data)) && ! is_null($hash)) {
+                        $used = reset($data);
 
-                    foreach ($data as $entry) {
-                        if (isset($entry['hash']) && $entry['hash']->getValue() == $hash) {
-                            $used = $entry;
-                            break;
+                        foreach ($data as $entry) {
+                            if (isset($entry['hash']) && $entry['hash']->getValue() == $hash) {
+                                $used = $entry;
+                                break;
+                            }
                         }
+                    } elseif (is_int(key($data))) {
+                        $used = reset($data);
                     }
-                } elseif (is_int(key($data))) {
-                    $used = reset($data);
+                    return $this->getRaw($used, $missingFields);
+                } else {
+                    Feedback::error(tr('No data found for %0 %1', $type, $object));
                 }
-
-                return $this->getRaw($used, $missingFields);
             }
         }
 



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

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