Reset the external timezone database pointer and enabled flag before
registering the date INI entries. Registering date.timezone invokes its
update handler, which validates the timezone against DATE_TIMEZONEDB.
After an in-process engine shutdown, the external database may still point
into an unloaded timezonedb shared library. Resetting the state first avoids
reading unmapped memory during the next startup while allowing the external
database to be installed again when its extension starts.
Fixes GH-24350.
Closes#24354
Headers required by the generated code (zend_attributes.h, zend_constants.h, zend_enum.h) are collected during generation and emitted as includes at the top of the arginfo file, with the same preprocessor conditions and PHP version guards as the code that needs them.
Removes the manual zend_attributes.h and zend_enum.h includes from sources that only needed them for the arginfo file they include.
* date: Add `Time\Duration`
RFC: https://wiki.php.net/rfc/duration_class
* date: Cache the most recently `Time\Duration` object created with `from*()`
This is useful for patterns like the following:
for (;;) {
$watchers = $poll->wait(Time\Duration::fromSeconds(1));
// …
}
which is repeatedly creating identical duration objects for every loop
iteration.
* date: Add `Z_PARAM_ULONG()` helper to `time_duration.c`
* date: Make `tests/time/duration/helper.inc` compatible with PHP < 8.6
This will allow polyfills to more easily consume the upstream tests.
* NEWS / UPGRADING
Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
* Fix GH-11310: __debugInfo does nothing on userland classes extending Date classes
* Add tests to make sure not calling the parent constructor has any effect
Now the address is being checked instead of the value, but I believe the
value should be checked against 0, not the pointer against NULL.
Closes GH-22253.
php_date_llabs negated its argument with -i, which is UB when i is
LLONG_MIN. Cast to uint64_t before negating and use stdint types
throughout. Updated Y/x/X format call sites to PRIu64.
Fixes GH-18422
Closes GH-21638
There are several issues with this macro:
- It is incorrectly named: It's not an empty default case. It's an unreachable
default case.
- It is hiding control flow in its definition, which can be confusing for
humans and tools (such as Coccinelle) alike, because it looks like it would
be a statement that belongs to the "current" case rather than opening a new
one.
Since this macro is exactly as long as explicitly spelling out its definition
(excluding the useless `break;`), it is not even making the code any more
succinct.
Audit zend_ini_string(), INI_STR(), and related functions and macros, and all other INI_* macros.
The primary motivation is that these APIs should return a `const char*` because the `char*` is owned by a zend_string, and thus should never be released.
Moreover, the INI_STR() API doesn't follow our usual naming scheme as it returns a char* rather than a zend_string*.
In this PR new zend_ini_{bool|long|double|str|string}_literal() macros are introduced replacing the INI_{BOOL|INT|FLT|STR} macros which follow our more modern naming convention.
Moreover, the INI_BOOL() macro didn't produce correct values if the INI string is a word like "true" or "on".
The INI_ORIG_* APIs are removed because a Sourcegraph search shows 0 results, other than the one case used in ext/tidy that we fix using the typical API.
Add some additional checks for the value of an INI string to ensure it doesn't contain a nul byte when describing a path.
There are two issues:
1. The 'e' formatter doesn't output the seconds of the timezone even if
it has seconds.
2. var_dump(), (array) cast, serialization, ... don't include the
timezone second offset in the output. This means that, for example,
serializing and then unserializing a date object loses the seconds of
the timezone. This can be observed by comparing the output of
getTimezone() for `$dt` vs the unserialized object in the provided test.
Closes GH-20764.
The "current" and "end" field also rely on start_ce, which is set by
"start". Therefore, if "current" or "end" are provided, so must "start"
be provided.
Closes GH-20939.