Skip to content

Feature-detect GLOB_BRACE for musl-libc PHP builds (Alpine, static FrankenPHP)#135

Open
superdav42 wants to merge 1 commit into
YahnisElsts:masterfrom
superdav42:fix/glob-brace-musl
Open

Feature-detect GLOB_BRACE for musl-libc PHP builds (Alpine, static FrankenPHP)#135
superdav42 wants to merge 1 commit into
YahnisElsts:masterfrom
superdav42:fix/glob-brace-musl

Conversation

@superdav42
Copy link
Copy Markdown

Summary

Wpup_UpdateServer::findFirstAsset() references GLOB_BRACE unconditionally:

https://github.com/YahnisElsts/wp-update-server/blob/master/includes/Wpup/UpdateServer.php#L394

GLOB_BRACE is not defined on PHP builds linked against musl libc — for example Alpine container images and the official static FrankenPHP binary releases (see PHP manual note: "GLOB_BRACE is not available on some non-GNU systems, like Solaris or Alpine Linux").

In PHP 8 referencing an undefined constant is a fatal Error (not the PHP 7 warning), so every call to findFirstAsset() crashes the update API response when it tries to resolve a plugin banner or icon:

PHP Fatal error:  Uncaught Error: Undefined constant "GLOB_BRACE"
  in .../includes/Wpup/UpdateServer.php:394

Change

Switch the array-of-extensions branch to runtime feature detection:

  • When GLOB_BRACE is defined, behaviour is identical to before (single glob() with the brace pattern).
  • When it is missing, fall back to one glob() call per extension and merge results.
  • The string-extension branch no longer passes GLOB_BRACE since it was meaningless without braces.

Reproduce

# On any musl-libc PHP build (Alpine, static FrankenPHP):
php -r 'var_dump(defined("GLOB_BRACE"));'   # => bool(false)
# Hit any update API endpoint that resolves a banner/icon — fatal in error log.

Verification

  • php -l clean.
  • Smoke test exercising all branches (array+brace, array+fallback, string-extension, no-match) returns identical results under glibc system PHP and musl FrankenPHP.
  • Tested on a live install (FrankenPHP v1.4.4, PHP 8.4.5, static musl build): update API requests now respond normally; previously each one fatal-ed.

Notes

No behavioural change on glibc systems. No new dependencies. No public API changes.


aidevops.sh v3.15.38 plugin for OpenCode v1.14.48 with gpt-5.5 spent 14h 36m and 15,815 tokens on this as a headless worker.

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant