Skip to content

v1.2.5 - Fix use-as-alias form in NamespaceReplacer

Choose a tag to compare

@mostafasoufi mostafasoufi released this 07 Apr 07:06
· 11 commits to main since this release

Fixed

  • use Namespace as Alias; form not prefixed

    When a use statement imported a namespace itself (no trailing class) with an alias — e.g. use Symfony\Polyfill\Mbstring as p; in Symfony polyfill bootstrap files — NamespaceReplacer left it unchanged. After scoping, the aliased reference resolved to a non-existent class and produced fatal Class not found errors at runtime on hosts where the polyfill code path actually executed (e.g. servers without the native mbstring extension).

    Pattern 3 in NamespaceReplacer now accepts an optional as <alias> group between the namespace and the trailing semicolon, and preserves the alias verbatim in the replacement.

    Regression tests added covering both the alias form and the no-double-prefix case.

Affected plugins

Any plugin scoped with wp-scoper that pulls in Symfony polyfill packages (polyfill-mbstring, polyfill-ctype, polyfill-intl-grapheme, polyfill-intl-normalizer, polyfill-php73, polyfill-php80) and runs on a host missing the corresponding native PHP extension. Symptom: fatal Class Symfony\Polyfill\<Name>\<Name> not found from cron or page load.

Action required

Re-run composer update veronalabs/wp-scoper in affected plugins to regenerate the scoped polyfill bootstraps.