Skip to content

ext/intl: Sync IntlTimeZone object errors for invalid display types#22270

Open
LamentXU123 wants to merge 2 commits into
php:PHP-8.4from
LamentXU123:fix-timezone-error-code
Open

ext/intl: Sync IntlTimeZone object errors for invalid display types#22270
LamentXU123 wants to merge 2 commits into
php:PHP-8.4from
LamentXU123:fix-timezone-error-code

Conversation

@LamentXU123

@LamentXU123 LamentXU123 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Now, IntlTimeZone::getDisplayName() handled invalid display_type values before fetching the object, so it only updated the global intl error state.

That is,

<?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 object error state is correctly changed.

@LamentXU123 LamentXU123 marked this pull request as ready for review June 10, 2026 17:22
@LamentXU123 LamentXU123 requested a review from devnexen as a code owner June 10, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant