Fix warning if author or maintainer is missing in addon info

This commit is contained in:
Art4 2025-05-13 08:14:09 +00:00
parent d88119139f
commit 6a058793f0
2 changed files with 57 additions and 4 deletions

View file

@ -74,12 +74,16 @@ final class AddonInfo
} }
// rename author to authors // rename author to authors
if (array_key_exists('author', $data)) {
$data['authors'] = $data['author']; $data['authors'] = $data['author'];
unset($data['author']); unset($data['author']);
}
// rename maintainer to maintainers // rename maintainer to maintainers
if (array_key_exists('maintainer', $data)) {
$data['maintainers'] = $data['maintainer']; $data['maintainers'] = $data['maintainer'];
unset($data['maintainer']); unset($data['maintainer']);
}
return self::fromArray($data); return self::fromArray($data);
} }

View file

@ -27,6 +27,55 @@ class AddonInfoTest extends TestCase
'', '',
['id' => 'test'], ['id' => 'test'],
], ],
'without-author' => [
'test',
<<<TEXT
<?php
/*
* Name: Test Addon
* Description: adds awesome features to friendica
* Version: 100.4.50-beta.5
* Maintainer: Robin
* Status: beta
* Ignore: The "ignore" key is unsupported and will be ignored
*/
TEXT,
[
'id' => 'test',
'name' => 'Test Addon',
'description' => 'adds awesome features to friendica',
'maintainers' => [
['name' => 'Robin'],
],
'version' => '100.4.50-beta.5',
'status' => 'beta',
],
],
'without-maintainer' => [
'test',
<<<TEXT
<?php
/*
* Name: Test Addon
* Description: adds awesome features to friendica
* Version: 100.4.50-beta.5
* Author: Sam
* Status: beta
* Ignore: The "ignore" key is unsupported and will be ignored
*/
TEXT,
[
'id' => 'test',
'name' => 'Test Addon',
'description' => 'adds awesome features to friendica',
'authors' => [
['name' => 'Sam'],
],
'version' => '100.4.50-beta.5',
'status' => 'beta',
],
],
'complete' => [ 'complete' => [
'test', 'test',
<<<TEXT <<<TEXT