Skip to content

Commit 534d28a

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: ext/intl: Sync IntlTimeZone object errors for invalid display types
2 parents 50decba + 9e68cf8 commit 534d28a

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ PHP NEWS
1414
. Fixed bug GH-22121 (Double free in gdImageSetStyle() after
1515
overflow-triggered early return). (iliaal)
1616

17+
- Intl:
18+
. Fixed IntlTimeZone::getDisplayName() to synchronize object error state
19+
for invalid display types. (Weilin Du)
20+
1721
- URI:
1822
. Add LEXBOR_STATIC to CFLAGS_URI on Windows so ext/uri does not see
1923
LXB_API as __declspec(dllimport) when linked statically into PHP.

ext/intl/tests/timezone_getDisplayName_error.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ intl
88
$tz = IntlTimeZone::createTimeZone('Europe/Lisbon');
99
var_dump($tz->getDisplayName(false, -1));
1010
echo intl_get_error_message(), PHP_EOL;
11+
var_dump($tz->getErrorCode());
12+
echo $tz->getErrorMessage(), PHP_EOL;
1113

1214
?>
1315
--EXPECT--
1416
bool(false)
1517
IntlTimeZone::getDisplayName(): wrong display type: U_ILLEGAL_ARGUMENT_ERROR
18+
int(1)
19+
IntlTimeZone::getDisplayName(): wrong display type: U_ILLEGAL_ARGUMENT_ERROR

ext/intl/timezone/timezone_methods.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,22 +483,23 @@ U_CFUNC PHP_FUNCTION(intltz_get_display_name)
483483
RETURN_THROWS();
484484
}
485485

486+
TIMEZONE_METHOD_FETCH_OBJECT;
487+
486488
bool found = false;
487489
for (int i = 0; !found && i < sizeof(display_types)/sizeof(*display_types); i++) {
488490
if (display_types[i] == display_type)
489491
found = true;
490492
}
491493
if (!found) {
492-
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "wrong display type");
494+
intl_errors_set(TIMEZONE_ERROR_P(to), U_ILLEGAL_ARGUMENT_ERROR,
495+
"wrong display type");
493496
RETURN_FALSE;
494497
}
495498

496499
if (!locale_str) {
497500
locale_str = intl_locale_get_default();
498501
}
499502

500-
TIMEZONE_METHOD_FETCH_OBJECT;
501-
502503
UnicodeString result;
503504
to->utimezone->getDisplayName((UBool)daylight, (TimeZone::EDisplayType)display_type,
504505
Locale::createFromName(locale_str), result);

0 commit comments

Comments
 (0)