Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ PHP NEWS
left busy for the next fetch, and rows delivered from a result another
statement took over. (KentarouTakeda)

- Intl:
. Fixed a double-free when Calendar::createInstance() or
IntlCalendar::fromDateTime() fails after adopting a TimeZone. (iliaal)

- Phar:
. Fixed Phar archives being automatically detected when ".phar" only occurs
in a directory name or is not a filename extension in an included file's
Expand Down
2 changes: 0 additions & 2 deletions ext/intl/calendar/calendar_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ PHP_INTL_FUNCTION_WITH_ERROR_RESET(intlcal_create_instance)
Calendar *cal = Calendar::createInstance(timeZone,
Locale::createFromName(locale_str), status);
if (UNEXPECTED(cal == NULL)) {
delete timeZone;
intl_error_set(NULL, status, "Error creating ICU Calendar object");
RETURN_NULL();
}
Expand Down Expand Up @@ -1073,7 +1072,6 @@ PHP_INTL_FUNCTION_WITH_ERROR_RESET(intlcal_from_date_time)
cal = Calendar::createInstance(timeZone,
Locale::createFromName(locale_str), status);
if (UNEXPECTED(cal == NULL)) {
delete timeZone;
intl_error_set(NULL, status,
"error creating ICU Calendar object");
goto error;
Expand Down
24 changes: 24 additions & 0 deletions ext/intl/tests/calendar_createinstance_adopt_timezone.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is kinda of useless, I would suggest to drop it.

IntlCalendar::createInstance() and fromDateTime() adopt the TimeZone
--EXTENSIONS--
intl
--INI--
date.timezone=UTC
--FILE--
<?php

$cal = IntlCalendar::createInstance('Europe/Amsterdam', 'en_US');
echo $cal->getTimeZone()->getID(), "\n";
echo $cal->getType(), "\n";

$dt = new DateTime('2024-01-15 12:00:00', new DateTimeZone('America/New_York'));
$cal2 = IntlCalendar::fromDateTime($dt, 'en_US');
echo $cal2->getTimeZone()->getID(), "\n";
echo $cal2->getType(), "\n";

?>
--EXPECT--
Europe/Amsterdam
gregorian
America/New_York
gregorian
Loading