From be9fb1b89974719bcd88e68218fb152e8b858509 Mon Sep 17 00:00:00 2001 From: Louis-Arnaud Date: Sun, 16 Aug 2026 19:46:09 +0200 Subject: [PATCH] ext/intl: correct the 8.4.0 Error normalization, it only concerns cloning Only the clone path changed in 8.4.0. Throwing an Error when a method is called on a non-initialized Intl object is not new: the macros doing so date back to 2012 and PHP 8.3 behaves identically. Saying the classes "always throw" is also falsifiable on 8.4: UConverter::convert() returns false, ResourceBundle::get() returns null and Collator::getAttribute() returns -1 on a non-initialized object. What 8.4.0 changed is the clone handlers, and both of their branches matter: refusing to clone a non-initialized object, and an initialized object whose ICU clone() call fails. Formerly most classes threw a base Exception there, and Spoofchecker raised an uncatchable fatal error. - reference/intl/book.xml: restate the note accordingly - appendices/migration84/other-changes.xml: fix the same overstatement in the migration entry so both places agree Sources - php-src 33f1cf202ef ("ext/intl: Various refactoring", php-src#14360): "Normalize cloning error handling behaviour - Always throw a Error exception as we cannot progress from here". Only clone paths and idn.c are touched, no INTL_METHOD_CHECK_STATUS macro. - UPGRADING (PHP 8.4) section 9, added by cd44826c1af - Pre-existing Error on use: a5d0c1e21b (2012-08-21), f5b421621d (2012-05-31) --- appendices/migration84/other-changes.xml | 9 ++++++--- reference/intl/book.xml | 12 ++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/appendices/migration84/other-changes.xml b/appendices/migration84/other-changes.xml index fa821809bb80..05ccec6d3b98 100644 --- a/appendices/migration84/other-changes.xml +++ b/appendices/migration84/other-changes.xml @@ -551,9 +551,12 @@ Intl - The behaviour of Intl class has been normalized to always throw - Error exceptions when attempting to use - a non-initialized object, or when cloning fails. + Cloning an Intl object consistently throws an + Error when the clone cannot be performed, + either because the object has not been initialized, or because the + underlying ICU clone operation failed. Formerly, most of these classes + threw an Exception instead, and + Spoofchecker raised a fatal error. diff --git a/reference/intl/book.xml b/reference/intl/book.xml index 45e180457831..eadb85ce721c 100644 --- a/reference/intl/book.xml +++ b/reference/intl/book.xml @@ -93,6 +93,18 @@ + + + As of PHP 8.4.0, cloning an Intl object consistently throws an + Error when the clone cannot be performed, + either because the object has not been initialized (created without + invoking its constructor), or because the underlying ICU clone operation + failed. Formerly, most of these classes threw an + Exception instead, and + Spoofchecker raised a fatal error. + + +
Links