From 69f67f990dd3b2eeed9e2687a528b7a00fc2671a Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sat, 9 Aug 2025 16:28:47 +0100 Subject: [PATCH] ext/intl: Deprecate intl.error_level INI setting (#19430) RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_intlerror_level_ini_setting --- ext/intl/php_intl.c | 16 +++++++++++++++- ext/intl/tests/gh17469.phpt | 3 ++- ext/intl/tests/ini_use_exceptions_basic.phpt | 2 ++ ...one_createTimeZoneIDEnumeration_variant2.phpt | 1 - php.ini-development | 6 +++++- php.ini-production | 6 +++++- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index 68fd2dedfba..28debad4133 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -98,10 +98,24 @@ const char *intl_locale_get_default( void ) return INTL_G(default_locale); } +static PHP_INI_MH(OnUpdateErrorLevel) +{ + zend_long *p = (zend_long *) ZEND_INI_GET_ADDR(); + *p = zend_ini_parse_quantity_warn(new_value, entry->name); + if (*p) { + php_error_docref("session.configuration", E_DEPRECATED, + "Using a value different than 0 for intl.error_level is deprecated," + " as the intl.error_level INI setting is deprecated." + " Instead the intl.use_exceptions INI setting should be enabled to throw exceptions on errors" + " or intl_get_error_code()/intl_get_error_message() should be used to manually deal with errors"); + } + return SUCCESS; +} + /* {{{ INI Settings */ PHP_INI_BEGIN() STD_PHP_INI_ENTRY(LOCALE_INI_NAME, NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_locale, zend_intl_globals, intl_globals) - STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateLong, error_level, zend_intl_globals, intl_globals) + STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateErrorLevel, error_level, zend_intl_globals, intl_globals) STD_PHP_INI_BOOLEAN("intl.use_exceptions", "0", PHP_INI_ALL, OnUpdateBool, use_exceptions, zend_intl_globals, intl_globals) PHP_INI_END() /* }}} */ diff --git a/ext/intl/tests/gh17469.phpt b/ext/intl/tests/gh17469.phpt index ab222ff89f4..5a226368442 100644 --- a/ext/intl/tests/gh17469.phpt +++ b/ext/intl/tests/gh17469.phpt @@ -28,9 +28,10 @@ try { } ?> --EXPECTF-- +Deprecated: ini_set(): Using a value different than 0 for intl.error_level is deprecated, as the intl.error_level INI setting is deprecated. Instead the intl.use_exceptions INI setting should be enabled to throw exceptions on errors or intl_get_error_code()/intl_get_error_message() should be used to manually deal with errors in %s on line %d Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line %d -Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line 5 +Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line %d UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR diff --git a/ext/intl/tests/ini_use_exceptions_basic.phpt b/ext/intl/tests/ini_use_exceptions_basic.phpt index b6471795dd7..e03c991ae05 100644 --- a/ext/intl/tests/ini_use_exceptions_basic.phpt +++ b/ext/intl/tests/ini_use_exceptions_basic.phpt @@ -18,5 +18,7 @@ var_dump($t->transliterate('a', 3)); --EXPECTF-- string(133) "Transliterator::transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)" +Deprecated: ini_set(): Using a value different than 0 for intl.error_level is deprecated, as the intl.error_level INI setting is deprecated. Instead the intl.use_exceptions INI setting should be enabled to throw exceptions on errors or intl_get_error_code()/intl_get_error_message() should be used to manually deal with errors in %s on line %d + Notice: Transliterator::transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d bool(false) diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt index 8acf604ec7f..6c53055086f 100644 --- a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt @@ -4,7 +4,6 @@ IntlTimeZone::createTimeZoneIDEnumeration(): variant without region intl --FILE--