[php-src] PR #24356: date: Validate nanoseconds range and normalize negative zero duration
| From: | adapik | Date: | Thu, 15 Oct 2026 16:03:06 +0000 |
| Subject: | [php-src] PR #24356: date: Validate nanoseconds range and normalize negative zero duration | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-39473@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/24356
Author: adapik
Follow-up to #23629 and #23759.
```php
// 1. Previously accepted: nanoseconds is 4294967301 (2^32 + 5), but the
// internal value is 5, so it compares equal to a 5ns duration.
unserialize('O:13:"Time\Duration":3:{s:7:"seconds";i:0;s:11:"nanoseconds";i:4294967301;s:8:"negative";b:0;}');
// Now: Exception: Invalid serialization data for Time\Duration object
// 2. Previously ->negative stayed true and serialize() round-tripped b:1.
$d =
unserialize('O:13:"Time\Duration":3:{s:7:"seconds";i:0;s:11:"nanoseconds";i:0;s:8:"negative";b:1;}');
var_dump($d->negative); // Now: bool(false), like Duration::fromSeconds(0)->negate()
```