]> git.mxchange.org Git - friendica.git/commitdiff
Check media_attributes keys before using them in Mastodon\Statuses
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 2 Dec 2023 21:51:35 +0000 (16:51 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 3 Dec 2023 14:13:34 +0000 (09:13 -0500)
- Address https://github.com/friendica/friendica/issues/13157#issuecomment-1832575517

src/Module/Api/Mastodon/Statuses.php

index 84eaadfe5ebcb7765604f7f47ec4cf184162a2d0..0ebd616089b925dc6583f941f12dbfaa6e7054f9 100644 (file)
@@ -122,8 +122,8 @@ class Statuses extends BaseApi
                $existing_media = array_column(Post\Media::getByURIId($post['uri-id'], [Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE]), 'id');
 
                foreach ($request['media_attributes'] as $attributes) {
-                       if (in_array($attributes['id'], $existing_media)) {
-                               Post\Media::updateById(['description' => $attributes['description']], $attributes['id']);
+                       if (!empty($attributes['id']) && in_array($attributes['id'], $existing_media)) {
+                               Post\Media::updateById(['description' => $attributes['description'] ?? null], $attributes['id']);
                        }
                }
 
@@ -227,7 +227,7 @@ class Statuses extends BaseApi
                                                break;
                                        }
                                }
-                       
+
                                if (!empty($owner['allow_cid'] . $owner['allow_gid'] . $owner['deny_cid'] . $owner['deny_gid'])) {
                                        $item['allow_cid'] = $owner['allow_cid'];
                                        $item['allow_gid'] = $owner['allow_gid'];
@@ -306,7 +306,7 @@ class Statuses extends BaseApi
                }
 
                $item = DI::contentItem()->expandTags($item, $request['visibility'] == 'direct');
-               
+
                if (!empty($request['media_ids'])) {
                        $item = $this->storeMediaIds($request['media_ids'], $item);
                }