From 6a058793f08b0247d6c817f179346dce19ac0e7f Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 13 May 2025 08:14:09 +0000 Subject: [PATCH] Fix warning if author or maintainer is missing in addon info --- src/Core/Addon/AddonInfo.php | 12 ++++-- tests/Unit/Core/Addon/AddonInfoTest.php | 49 +++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/Core/Addon/AddonInfo.php b/src/Core/Addon/AddonInfo.php index 8b44b6f841..87bb5750f5 100644 --- a/src/Core/Addon/AddonInfo.php +++ b/src/Core/Addon/AddonInfo.php @@ -74,12 +74,16 @@ final class AddonInfo } // rename author to authors - $data['authors'] = $data['author']; - unset($data['author']); + if (array_key_exists('author', $data)) { + $data['authors'] = $data['author']; + unset($data['author']); + } // rename maintainer to maintainers - $data['maintainers'] = $data['maintainer']; - unset($data['maintainer']); + if (array_key_exists('maintainer', $data)) { + $data['maintainers'] = $data['maintainer']; + unset($data['maintainer']); + } return self::fromArray($data); } diff --git a/tests/Unit/Core/Addon/AddonInfoTest.php b/tests/Unit/Core/Addon/AddonInfoTest.php index a1887d5dfd..5e9d2cc79a 100644 --- a/tests/Unit/Core/Addon/AddonInfoTest.php +++ b/tests/Unit/Core/Addon/AddonInfoTest.php @@ -27,6 +27,55 @@ class AddonInfoTest extends TestCase '', ['id' => 'test'], ], + 'without-author' => [ + 'test', + << 'test', + 'name' => 'Test Addon', + 'description' => 'adds awesome features to friendica', + + 'maintainers' => [ + ['name' => 'Robin'], + ], + 'version' => '100.4.50-beta.5', + 'status' => 'beta', + ], + ], + 'without-maintainer' => [ + 'test', + << 'test', + 'name' => 'Test Addon', + 'description' => 'adds awesome features to friendica', + 'authors' => [ + ['name' => 'Sam'], + ], + 'version' => '100.4.50-beta.5', + 'status' => 'beta', + ], + ], 'complete' => [ 'test', <<