]> git.mxchange.org Git - friendica.git/commitdiff
Fix warning if author or maintainer is missing in addon info
authorArt4 <art4@wlabs.de>
Tue, 13 May 2025 08:14:09 +0000 (08:14 +0000)
committerArt4 <art4@wlabs.de>
Tue, 13 May 2025 08:14:09 +0000 (08:14 +0000)
src/Core/Addon/AddonInfo.php
tests/Unit/Core/Addon/AddonInfoTest.php

index 8b44b6f8410e4f9fc8198d56a5072a886411365a..87bb5750f52c9f34c648641bb31c6823c3478b15 100644 (file)
@@ -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);
        }
index a1887d5dfd145648f3d0bd34fdf2db94545fc742..5e9d2cc79a6bc52b6898950ebb901336f9f0b8df 100644 (file)
@@ -27,6 +27,55 @@ class AddonInfoTest extends TestCase
                                '',
                                ['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' => [
                                'test',
                                <<<TEXT