]> git.mxchange.org Git - friendica.git/commitdiff
Change return value to stdClass of Module\Api\Mastodon\Markers->fetchTimelines
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 27 Nov 2023 21:10:15 +0000 (16:10 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 27 Nov 2023 21:10:15 +0000 (16:10 -0500)
- This ensures the JSON serialization of timeline markers is an object even when no markers are set

src/Module/Api/Mastodon/Markers.php

index 4bd714c1173ce303d8f45c798d7feb3bf1ed7c12..6a4422bffa223c4f9a033d0339f214f91052fd3c 100644 (file)
@@ -21,9 +21,7 @@
 
 namespace Friendica\Module\Api\Mastodon;
 
-use Friendica\Core\System;
 use Friendica\Database\DBA;
-use Friendica\DI;
 use Friendica\Module\BaseApi;
 use Friendica\Util\DateTimeFormat;
 
@@ -76,12 +74,12 @@ class Markers extends BaseApi
                $this->jsonExit($this->fetchTimelines($application['id'], $uid));
        }
 
-       private function fetchTimelines(int $application_id, int $uid)
+       private function fetchTimelines(int $application_id, int $uid): \stdClass
        {
-               $values = [];
+               $values = new \stdClass();
                $markers = DBA::select('application-marker', [], ['application-id' => $application_id, 'uid' => $uid]);
                while ($marker = DBA::fetch($markers)) {
-                       $values[$marker['timeline']] = [
+                       $values->{$marker['timeline']} = [
                                'last_read_id' => $marker['last_read_id'],
                                'version'      => $marker['version'],
                                'updated_at'   => $marker['updated_at']