Skip to content

Commit 66bf3dc

Browse files
authored
ext/intl: correct the 8.4.0 Error normalization, it only concerns cloning (#5798)
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)
1 parent 5c52e84 commit 66bf3dc

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

appendices/migration84/other-changes.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,12 @@
551551
<title>Intl</title>
552552

553553
<simpara>
554-
The behaviour of Intl class has been normalized to always throw
555-
<exceptionname>Error</exceptionname> exceptions when attempting to use
556-
a non-initialized object, or when cloning fails.
554+
Cloning an Intl object consistently throws an
555+
<exceptionname>Error</exceptionname> when the clone cannot be performed,
556+
either because the object has not been initialized, or because the
557+
underlying ICU clone operation failed. Formerly, most of these classes
558+
threw an <exceptionname>Exception</exceptionname> instead, and
559+
<classname>Spoofchecker</classname> raised a fatal error.
557560
</simpara>
558561
</sect3>
559562

reference/intl/book.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@
9393
</listitem>
9494
</itemizedlist>
9595

96+
<note>
97+
<simpara>
98+
As of PHP 8.4.0, cloning an Intl object consistently throws an
99+
<exceptionname>Error</exceptionname> when the clone cannot be performed,
100+
either because the object has not been initialized (created without
101+
invoking its constructor), or because the underlying ICU clone operation
102+
failed. Formerly, most of these classes threw an
103+
<exceptionname>Exception</exceptionname> instead, and
104+
<classname>Spoofchecker</classname> raised a fatal error.
105+
</simpara>
106+
</note>
107+
96108
<!-- {{{ Links -->
97109
<section xml:id="intl.links">
98110
<title>Links</title>

0 commit comments

Comments
 (0)