diff --git a/php-84/Dockerfile b/php-84/Dockerfile index cf4004fb..8de53f4b 100644 --- a/php-84/Dockerfile +++ b/php-84/Dockerfile @@ -4,7 +4,7 @@ ARG IMAGE_VERSION_SUFFIX # https://www.php.net/downloads -ARG VERSION_PHP=8.4.21 +ARG VERSION_PHP=8.4.22 # Lambda uses a custom AMI named Amazon Linux 2 @@ -430,6 +430,13 @@ ARG VERSION_PHP RUN curl --location --silent --show-error --fail https://www.php.net/get/php-${VERSION_PHP}.tar.gz/from/this/mirror \ | tar xzC . --strip-components=1 +# Restore the ICU >= 53 guard around Spoofchecker's restriction-level APIs so that +# ext/intl compiles against Amazon Linux 2's ICU 50.x (backport of +# https://github.com/php/php-src/pull/22248). Remove once the layers use a PHP 8.4 +# release that already contains the fix. +COPY php-84/spoofchecker-icu53.patch /tmp/spoofchecker-icu53.patch +RUN patch -p1 < /tmp/spoofchecker-icu53.patch + # Configure the build # -fstack-protector-strong : Be paranoid about stack overflows # -fpic : Make PHP's main executable position-independent (improves ASLR security mechanism, and has no performance impact on x86_64) diff --git a/php-84/spoofchecker-icu53.patch b/php-84/spoofchecker-icu53.patch new file mode 100644 index 00000000..47d52e46 --- /dev/null +++ b/php-84/spoofchecker-icu53.patch @@ -0,0 +1,134 @@ +Backport of https://github.com/php/php-src/pull/22248 + +PHP 8.4.22 (GH-22055) dropped the ICU version guard around Spoofchecker's +restriction-level constants and setRestrictionLevel(), so ext/intl no longer +compiles against ICU older than 53 (e.g. Amazon Linux 2 ships ICU 50.2). This +restores the guard at the correct floor, ICU 53. Remove once the build uses a +PHP 8.4 release that already contains the fix. + +diff --git a/ext/intl/spoofchecker/spoofchecker_arginfo.h b/ext/intl/spoofchecker/spoofchecker_arginfo.h +index 99a211b260d..e6b53829081 100644 +--- a/ext/intl/spoofchecker/spoofchecker_arginfo.h ++++ b/ext/intl/spoofchecker/spoofchecker_arginfo.h +@@ -1,5 +1,5 @@ + /* This is a generated file, edit the .stub.php file instead. +- * Stub hash: 4634f8ef9157fb3670a2ddc5e3246340660fc68c */ ++ * Stub hash: d01a6d58d52e8b38a7854626d9649d5915ec7e5c */ + + ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Spoofchecker___construct, 0, 0, 0) + ZEND_END_ARG_INFO() +@@ -23,9 +23,11 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Spoofchecker_set + ZEND_ARG_TYPE_INFO(0, checks, IS_LONG, 0) + ZEND_END_ARG_INFO() + ++#if U_ICU_VERSION_MAJOR_NUM >= 53 + ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Spoofchecker_setRestrictionLevel, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, level, IS_LONG, 0) + ZEND_END_ARG_INFO() ++#endif + + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Spoofchecker_setAllowedChars, 0, 1, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) +@@ -37,7 +39,9 @@ ZEND_METHOD(Spoofchecker, isSuspicious); + ZEND_METHOD(Spoofchecker, areConfusable); + ZEND_METHOD(Spoofchecker, setAllowedLocales); + ZEND_METHOD(Spoofchecker, setChecks); ++#if U_ICU_VERSION_MAJOR_NUM >= 53 + ZEND_METHOD(Spoofchecker, setRestrictionLevel); ++#endif + ZEND_METHOD(Spoofchecker, setAllowedChars); + + static const zend_function_entry class_Spoofchecker_methods[] = { +@@ -46,7 +50,9 @@ static const zend_function_entry class_Spoofchecker_methods[] = { + ZEND_ME(Spoofchecker, areConfusable, arginfo_class_Spoofchecker_areConfusable, ZEND_ACC_PUBLIC) + ZEND_ME(Spoofchecker, setAllowedLocales, arginfo_class_Spoofchecker_setAllowedLocales, ZEND_ACC_PUBLIC) + ZEND_ME(Spoofchecker, setChecks, arginfo_class_Spoofchecker_setChecks, ZEND_ACC_PUBLIC) ++#if U_ICU_VERSION_MAJOR_NUM >= 53 + ZEND_ME(Spoofchecker, setRestrictionLevel, arginfo_class_Spoofchecker_setRestrictionLevel, ZEND_ACC_PUBLIC) ++#endif + ZEND_ME(Spoofchecker, setAllowedChars, arginfo_class_Spoofchecker_setAllowedChars, ZEND_ACC_PUBLIC) + ZEND_FE_END + }; +@@ -99,48 +105,62 @@ static zend_class_entry *register_class_Spoofchecker(void) + zend_string *const_CHAR_LIMIT_name = zend_string_init_interned("CHAR_LIMIT", sizeof("CHAR_LIMIT") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_CHAR_LIMIT_name, &const_CHAR_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_CHAR_LIMIT_name); ++#if U_ICU_VERSION_MAJOR_NUM >= 53 + + zval const_ASCII_value; + ZVAL_LONG(&const_ASCII_value, USPOOF_ASCII); + zend_string *const_ASCII_name = zend_string_init_interned("ASCII", sizeof("ASCII") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_ASCII_name, &const_ASCII_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_ASCII_name); ++#endif ++#if U_ICU_VERSION_MAJOR_NUM >= 53 + + zval const_HIGHLY_RESTRICTIVE_value; + ZVAL_LONG(&const_HIGHLY_RESTRICTIVE_value, USPOOF_HIGHLY_RESTRICTIVE); + zend_string *const_HIGHLY_RESTRICTIVE_name = zend_string_init_interned("HIGHLY_RESTRICTIVE", sizeof("HIGHLY_RESTRICTIVE") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_HIGHLY_RESTRICTIVE_name, &const_HIGHLY_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_HIGHLY_RESTRICTIVE_name); ++#endif ++#if U_ICU_VERSION_MAJOR_NUM >= 53 + + zval const_MODERATELY_RESTRICTIVE_value; + ZVAL_LONG(&const_MODERATELY_RESTRICTIVE_value, USPOOF_MODERATELY_RESTRICTIVE); + zend_string *const_MODERATELY_RESTRICTIVE_name = zend_string_init_interned("MODERATELY_RESTRICTIVE", sizeof("MODERATELY_RESTRICTIVE") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_MODERATELY_RESTRICTIVE_name, &const_MODERATELY_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_MODERATELY_RESTRICTIVE_name); ++#endif ++#if U_ICU_VERSION_MAJOR_NUM >= 53 + + zval const_MINIMALLY_RESTRICTIVE_value; + ZVAL_LONG(&const_MINIMALLY_RESTRICTIVE_value, USPOOF_MINIMALLY_RESTRICTIVE); + zend_string *const_MINIMALLY_RESTRICTIVE_name = zend_string_init_interned("MINIMALLY_RESTRICTIVE", sizeof("MINIMALLY_RESTRICTIVE") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_MINIMALLY_RESTRICTIVE_name, &const_MINIMALLY_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_MINIMALLY_RESTRICTIVE_name); ++#endif ++#if U_ICU_VERSION_MAJOR_NUM >= 53 + + zval const_UNRESTRICTIVE_value; + ZVAL_LONG(&const_UNRESTRICTIVE_value, USPOOF_UNRESTRICTIVE); + zend_string *const_UNRESTRICTIVE_name = zend_string_init_interned("UNRESTRICTIVE", sizeof("UNRESTRICTIVE") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_UNRESTRICTIVE_name, &const_UNRESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_UNRESTRICTIVE_name); ++#endif ++#if U_ICU_VERSION_MAJOR_NUM >= 53 + + zval const_SINGLE_SCRIPT_RESTRICTIVE_value; + ZVAL_LONG(&const_SINGLE_SCRIPT_RESTRICTIVE_value, USPOOF_SINGLE_SCRIPT_RESTRICTIVE); + zend_string *const_SINGLE_SCRIPT_RESTRICTIVE_name = zend_string_init_interned("SINGLE_SCRIPT_RESTRICTIVE", sizeof("SINGLE_SCRIPT_RESTRICTIVE") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_SINGLE_SCRIPT_RESTRICTIVE_name, &const_SINGLE_SCRIPT_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_SINGLE_SCRIPT_RESTRICTIVE_name); ++#endif ++#if U_ICU_VERSION_MAJOR_NUM >= 53 + + zval const_MIXED_NUMBERS_value; + ZVAL_LONG(&const_MIXED_NUMBERS_value, USPOOF_MIXED_NUMBERS); + zend_string *const_MIXED_NUMBERS_name = zend_string_init_interned("MIXED_NUMBERS", sizeof("MIXED_NUMBERS") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_MIXED_NUMBERS_name, &const_MIXED_NUMBERS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_MIXED_NUMBERS_name); ++#endif + #if U_ICU_VERSION_MAJOR_NUM >= 62 + + zval const_HIDDEN_OVERLAY_value; +diff --git a/ext/intl/spoofchecker/spoofchecker_main.c b/ext/intl/spoofchecker/spoofchecker_main.c +index 13ac6739264..b03f73103b3 100644 +--- a/ext/intl/spoofchecker/spoofchecker_main.c ++++ b/ext/intl/spoofchecker/spoofchecker_main.c +@@ -135,6 +135,7 @@ PHP_METHOD(Spoofchecker, setChecks) + } + /* }}} */ + ++#if U_ICU_VERSION_MAJOR_NUM >= 53 + /* TODO Document this method on PHP.net */ + /* {{{ Set the loosest restriction level allowed for strings. */ + PHP_METHOD(Spoofchecker, setRestrictionLevel) +@@ -163,6 +164,7 @@ PHP_METHOD(Spoofchecker, setRestrictionLevel) + uspoof_setRestrictionLevel(co->uspoof, (URestrictionLevel)level); + } + /* }}} */ ++#endif + + PHP_METHOD(Spoofchecker, setAllowedChars) + {