From: Art4 Date: Wed, 14 May 2025 09:52:33 +0000 (+0000) Subject: Replace glob() with stream safe alternative scandir() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=88dcd755a90001ca1ea87607d7f7121845278b63;p=friendica.git Replace glob() with stream safe alternative scandir() --- diff --git a/src/Core/Addon/AddonManagerHelper.php b/src/Core/Addon/AddonManagerHelper.php index 66f22bf904..d8873869b9 100644 --- a/src/Core/Addon/AddonManagerHelper.php +++ b/src/Core/Addon/AddonManagerHelper.php @@ -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 (