[php-src] PR #22248: ext/intl: Guard Spoofchecker restriction-level APIs at ICU 53 (fix build on ICU 50.x)
| From: | GrahamCampbell | Date: | Sun, 07 Jun 2026 19:45:46 +0000 |
| Subject: | [php-src] PR #22248: ext/intl: Guard Spoofchecker restriction-level APIs at ICU 53 (fix build on ICU 50.x) | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36334@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22248
Author: GrahamCampbell
PHP 8.4.22 fails to build the intl extension against ICU 50.x. The change that
landed for GH-22055 (fixing #22053) removed the
"#if U_ICU_VERSION_MAJOR_NUM >= 58" guards that previously wrapped the
Spoofchecker restriction-level class constants (ASCII, HIGHLY_RESTRICTIVE,
MODERATELY_RESTRICTIVE, MINIMALLY_RESTRICTIVE, UNRESTRICTIVE,
SINGLE_SCRIPT_RESTRICTIVE and MIXED_NUMBERS) together with the
setRestrictionLevel() method, so the extension now references those ICU symbols
unconditionally. That is fine on master and PHP-8.5, where build/php.m4 requires
icu-uc >= 57.1, but on PHP-8.4 the minimum is still icu-uc >= 50.1 and the
restriction-level symbols do not exist that far back. On a platform whose system
ICU is 50.x, such as Amazon Linux 2 which ships ICU 50.2 and therefore satisfies
the 50.1 requirement, configure succeeds and the compile then fails with
USPOOF_ASCII, the other restriction-level constants and URestrictionLevel
reported as undeclared.
The correct floor for these APIs is ICU 53 rather than 58. All of the constants
and the URestrictionLevel enum, along with uspoof_setRestrictionLevel(), have
existed since ICU 51; the single exception is USPOOF_SINGLE_SCRIPT_RESTRICTIVE,
which was added in ICU 53 and is referenced both as a constant and inside the
setRestrictionLevel() body. Guarding the block at ICU 53 lets it compile on every
ICU version that PHP-8.4 still supports while keeping the restriction-level API
available on ICU 53 and later. This also preserves the intent of GH-22055,
because the original >= 58 guard was itself too strict and hid the API on ICU
57.x, which is exactly the under-exposure that #22053 set out to correct.
This change reinstates the guard at "#if U_ICU_VERSION_MAJOR_NUM >= 53" around the
seven constants and the setRestrictionLevel() declaration in spoofchecker.stub.php,
regenerates spoofchecker_arginfo.h to match, and wraps the setRestrictionLevel()
method body in spoofchecker_main.c with the same condition. The unrelated
correction to the setAllowedChars() error message, which reports the PHP constant
names instead of their USET_-prefixed counterparts, is left in place because it is
not part of the build failure.