]> git.mxchange.org Git - friendica.git/commitdiff
Replace glob() with stream safe alternative scandir()
authorArt4 <art4@wlabs.de>
Wed, 14 May 2025 09:52:33 +0000 (09:52 +0000)
committerArt4 <art4@wlabs.de>
Wed, 14 May 2025 09:52:33 +0000 (09:52 +0000)
src/Core/Addon/AddonManagerHelper.php

index 66f22bf904db836e9ebf351512c38ab0620b17a3..d8873869b9691d2424c8377bfeb23f27b018bf91 100644 (file)
@@ -62,21 +62,29 @@ final class AddonManagerHelper implements AddonHelper
         */
        public function getAvailableAddons(): array
        {
-               $files = glob($this->getAddonPath() . '/*/');
+               $dirs = scandir($this->getAddonPath());
 
-               if (!is_array($files)) {
+               if (!is_array($dirs)) {
                        return [];
                }
 
-               $addons = [];
+               $files = [];
+
+               foreach ($dirs as $dirname) {
+                       if (in_array($dirname, ['.', '..'])) {
+                               continue;
+                       }
 
-               foreach ($files as $file) {
-                       if (!is_dir($file)) {
+                       if (!is_dir($this->getAddonPath() . '/' . $dirname)) {
                                continue;
                        }
 
-                       $addonId = basename($file);
+                       $files[] = $dirname;
+               }
+
+               $addons = [];
 
+               foreach ($files as $addonId) {
                        $addonInfo = $this->getAddonInfo($addonId);
 
                        if (