mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.2' into PHP-8.3
This commit is contained in:
@@ -704,8 +704,11 @@ static zend_string *date_format(const char *format, size_t format_len, timelib_t
|
||||
(offset->offset < 0) ? '-' : '+',
|
||||
abs(offset->offset / 3600),
|
||||
abs((offset->offset % 3600) / 60));
|
||||
} else {
|
||||
} else if (t->zone_type == TIMELIB_ZONETYPE_ID) {
|
||||
offset = timelib_get_time_zone_info(t->sse, t->tz_info);
|
||||
} else {
|
||||
/* Shouldn't happen, but code defensively */
|
||||
offset = timelib_time_offset_ctor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2446,6 +2449,9 @@ PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, siz
|
||||
new_dst = tzobj->tzi.z.dst;
|
||||
new_abbr = timelib_strdup(tzobj->tzi.z.abbr);
|
||||
break;
|
||||
default:
|
||||
zend_throw_error(NULL, "The DateTimeZone object has not been correctly initialized by its constructor");
|
||||
return 0;
|
||||
}
|
||||
type = tzobj->type;
|
||||
} else if (dateobj->time->tz_info) {
|
||||
|
||||
21
ext/date/tests/bug-gh15582.phpt
Normal file
21
ext/date/tests/bug-gh15582.phpt
Normal file
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Bug GH-15582: Crash when not calling parent constructor of DateTimeZone
|
||||
--FILE--
|
||||
<?php
|
||||
class MyDateTimeZone extends DateTimeZone
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
$mdtz = new MyDateTimeZone();
|
||||
$fusion = $mdtz;
|
||||
try {
|
||||
date_create("2005-07-14 22:30:41", $fusion);
|
||||
} catch (Error $e) {
|
||||
echo get_class($e), ': ', $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Error: The DateTimeZone object has not been correctly initialized by its constructor
|
||||
Reference in New Issue
Block a user