From d820e0f55d01998a9b2b67e47d94dfa6da4a318d Mon Sep 17 00:00:00 2001 From: David Stone Date: Wed, 13 May 2026 02:14:33 -0600 Subject: [PATCH] Feature-detect GLOB_BRACE for musl-libc PHP builds GLOB_BRACE is undefined on PHP builds linked against musl libc (Alpine, the official static FrankenPHP releases). In PHP 8, referencing an undefined constant is a fatal Error, which crashes findFirstAsset() every time the update API tries to resolve a plugin banner or icon. Switch to runtime feature detection: - When GLOB_BRACE is defined, behaviour is identical to before. - When it is missing, fall back to one glob() call per extension and merge the results. - The string-extension branch no longer passes GLOB_BRACE since it is meaningless without braces. Reproduce on any musl-libc PHP: php -r 'var_dump(defined("GLOB_BRACE"));' # => bool(false) --- includes/Wpup/UpdateServer.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/includes/Wpup/UpdateServer.php b/includes/Wpup/UpdateServer.php index 4160a200..eb77ebec 100644 --- a/includes/Wpup/UpdateServer.php +++ b/includes/Wpup/UpdateServer.php @@ -385,13 +385,28 @@ protected function findFirstAsset( ) { $pattern = $this->assetDirectories[$assetType] . '/' . $package->slug . $suffix; + //GLOB_BRACE is not defined on every libc (e.g. musl, used by Alpine/static + //FrankenPHP builds). When it's missing, fall back to one glob() call per + //extension and merge the results. Behaviour is identical otherwise. if ( is_array($extensions) ) { - $extensionPattern = '{' . implode(',', $extensions) . '}'; + if ( defined('GLOB_BRACE') ) { + $assets = glob( + $pattern . '.{' . implode(',', $extensions) . '}', + GLOB_BRACE | GLOB_NOESCAPE + ); + } else { + $assets = array(); + foreach ($extensions as $extension) { + $matches = glob($pattern . '.' . $extension, GLOB_NOESCAPE); + if ( !empty($matches) ) { + $assets = array_merge($assets, $matches); + } + } + } } else { - $extensionPattern = $extensions; + $assets = glob($pattern . '.' . $extensions, GLOB_NOESCAPE); } - $assets = glob($pattern . '.' . $extensionPattern, GLOB_BRACE | GLOB_NOESCAPE); if ( !empty($assets) ) { $firstFile = basename(reset($assets)); return $this->generateAssetUrl($assetType, $firstFile);