php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71525 Calls to date_modify will mutate timelib_rel_time, causing date_date_set issues
Submitted: 2016-02-04 21:00 UTC Modified: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: seander@php.net Assigned:
Status: Closed Package: Date/time related
PHP Version: 7.0.3 OS: All
Private report: No CVE-ID: None
 [2016-02-04 21:00 UTC] seander@php.net
Description:
------------
timelib_time->timelib_rel_time is mutated by date_modify, and because it is never zero'ed out it latters causes other date operations to fail (like date_date_set)

A reproduce is attached, and I will open a PR with a possible patch. 

Test script:
---------------
<?php

$date = new DateTime('2011-12-25 00:00:00');
$date->modify('first day of next month');
$date->setDate('2012', '1', '29');
var_dump($date);
----

https://3v4l.org/PASOu

Expected result:
----------------
object(DateTime)#1 (3) {
  ["date"]=>
  string(26) "2012-01-29 00:00:00.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(16) "Europe/Amsterdam"
}

Actual result:
--------------
object(DateTime)#1 (3) {
  ["date"]=>
  string(26) "2012-01-01 00:00:00.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(16) "Europe/Amsterdam"
}

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-15 07:22 UTC] ab@php.net
Automatic comment on behalf of sean@siobud.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f31e0cd3345ab1d0b4a5f82a804b2a8868a307e1
Log: Fix bug #71525
 [2016-02-15 07:22 UTC] ab@php.net
-Status: Open +Status: Closed
 [2016-07-20 11:33 UTC] davey@php.net
Automatic comment on behalf of sean@siobud.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f31e0cd3345ab1d0b4a5f82a804b2a8868a307e1
Log: Fix bug #71525
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC