[php-src] PR #26040: ext/intl: Reset the intl error in Locale::isRightToLeft()
| From: | ChrisAbner | Date: | Wed, 02 Dec 2026 22:23:09 +0000 |
| Subject: | [php-src] PR #26040: ext/intl: Reset the intl error in Locale::isRightToLeft() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41378@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/26040
Author: ChrisAbner
### The problem
Locale::isRightToLeft() (new in 8.5, GH-18345) does not reset the global intl error.
After a failed call, a
successful isRightToLeft() still shows the old error:
```php
$df = new IntlDateFormatter('en_US', IntlDateFormatter::NONE, IntlDateFormatter::NONE,
'UTC', IntlDateFormatter::GREGORIAN, 'yyyy');
$df->parse('x'); // fails with U_PARSE_ERROR
var_dump(Locale::isRightToLeft('ar'));
var_dump(intl_error_name(intl_get_error_code()));
```
```
bool(true)
string(13) "U_PARSE_ERROR" // expected: U_ZERO_ERROR
```
### The cause and the fix
locale_is_right_to_left() does not call ICU with a status, so nothing resets the error.
The fix calls
intl_error_reset(NULL) on entry, as the other Locale functions do.
This is the 8.5 part of #26039, which fixes the same problem in MessageFormatter and
IntlDateFormatter::formatObject() on PHP-8.4. isRightToLeft()
does not exist in 8.4, so it goes here.
### Verification
- Debug build with ASan and UBSan (GCC 13.3), PHP-8.5 at da933134970, ICU
74.2.
- The new test fails without the fix and passes with it.
- ext/intl tests: 471 passed, 0 failed (dateformat_format_variant3.phpt is
an expected failure, as before).