tpwd / ke_search

Search Extension for TYPO3 Content Management System, including faceting search functions.
https://extensions.typo3.org/extension/ke_search/
GNU General Public License v3.0
8 stars 31 forks source link

IndexRunner drops a PHP Warning #160

Closed ecosmox36 closed 1 year ago

ecosmox36 commented 1 year ago

TYPO3 11.5.27 PHP 8.0.21 ke_search 4.6.4

Debug Preset : Debug (directly in the Backend) Debug Preset : Live (Errorlog)

Message: PHP Warning: Trying to access array offset on value of type bool in /var/www/html/public/typo3conf/ext/ke_search/Classes/Indexer/IndexerRunner.php line 1159

My Mention: The Function returns a string (the value of an array) but misses a test if the array realy exists

Part: https://github.com/tpwd/ke_search/blob/b09c20b8455f0d9477baf39b3a80c712c5d47ba4/Classes/Indexer/IndexerRunner.php#L1145

(dont know the difference between the given line number in the warning and the Line number here in this file yet)

My Woraround

      * @param int $tagUid
      * @param bool $clearText . If true returns the title of the tag. false return the tag itself
      * @return string
+     * @throws DBALException
+     * @throws \Doctrine\DBAL\Driver\Exception
      */
     public function getTag($tagUid, $clearText = false)
     {
@@ -1151,12 +1153,15 @@
             ->from($table)
             ->where($where)
             ->execute()
-            ->fetch();
-
-        if ($clearText) {
-            return $row['title'];
-        }
-        return $row['tag'];
+            ->fetchAssociative();
+        if(is_array($row) && !empty($row)){
+            if ($clearText) {
+                return $row['title'];
+            }
+            return $row['tag'];
+        }else{
+            return '';
+        }
     }