Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexRunner drops a PHP Warning #160

Closed
ecosmox36 opened this issue May 12, 2023 · 0 comments
Closed

IndexRunner drops a PHP Warning #160

ecosmox36 opened this issue May 12, 2023 · 0 comments

Comments

@ecosmox36
Copy link

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:

return $row['tag'];

(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 '';
+        }
     }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant