[php-src] PR #22270: ext/intl: Sync IntlTimeZone object errors for invalid display types
| From: | LamentXU123 | Date: | Wed, 10 Jun 2026 17:22:29 +0000 |
| Subject: | [php-src] PR #22270: ext/intl: Sync IntlTimeZone object errors for invalid display types | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36362@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22270
Author: LamentXU123
Now,
IntlTimeZone::getDisplayName() handled invalid display_type values
*before* fetching the object, so it only updated the global intl error state.
That is,
```php
<?php
$tz = IntlTimeZone::createTimeZone('Europe/Lisbon');
var_dump($tz->getDisplayName(false, -1));
var_dump(intl_get_error_message());
var_dump($tz->getErrorCode());
var_dump($tz->getErrorMessage());
```
returns
```
bool(false)
string(76) "IntlTimeZone::getDisplayName(): wrong display type: U_ILLEGAL_ARGUMENT_ERROR"
int(0)
string(12) "U_ZERO_ERROR"
```
but I expect
```
bool(false)
string(76) "IntlTimeZone::getDisplayName(): wrong display type: U_ILLEGAL_ARGUMENT_ERROR"
int(1)
string(44) "wrong display type: U_ILLEGAL_ARGUMENT_ERROR"
```
The solution is to move TIMEZONE_METHOD_FETCH_OBJECT after the
intl_errors_set func being called. So the global error state is correctly changed.