]> git.mxchange.org Git - friendica.git/commitdiff
Rework Hashtag module to avoid undefined key error
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 7 May 2023 03:55:34 +0000 (23:55 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 7 May 2023 03:55:41 +0000 (23:55 -0400)
- Address https://github.com/friendica/friendica/issues/13025#issuecomment-1537143590

src/Module/Hashtag.php

index dd0c94d8fa33d1e891fffdace52bc03f38c874a1..0c4c41c7e17c002334069025c9a17b8f82ed2333 100644 (file)
@@ -31,23 +31,25 @@ use Friendica\Util\Strings;
  */
 class Hashtag extends BaseModule
 {
-       protected function content(array $request = []): string
+       protected function rawContent(array $request = [])
        {
                $result = [];
 
-               $t = Strings::escapeHtml($_REQUEST['t']);
-               if (empty($t)) {
+               if (empty($request['t'])) {
                        System::jsonExit($result);
                }
 
-               $taglist = DBA::select('tag', ['name'], ["`name` LIKE ?", $t . "%"], ['order' => ['name'], 'limit' => 100]);
+               $taglist = DBA::select(
+                       'tag',
+                       ['name'],
+                       ["`name` LIKE ?", Strings::escapeHtml($request['t']) . "%"],
+                       ['order' => ['name'], 'limit' => 100]
+               );
                while ($tag = DBA::fetch($taglist)) {
                        $result[] = ['text' => $tag['name']];
                }
                DBA::close($taglist);
 
                System::jsonExit($result);
-
-               return '';
        }
 }