php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53634 unknown property when writing to DateInterval::$days
Submitted: 2010-12-30 22:15 UTC Modified: 2013-02-17 10:45 UTC
From: danielc at analysisandsolutions dot com Assigned: stas (profile)
Status: Closed Package: Date/time related
PHP Version: 5.3SVN-2010-12-30 (SVN) OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: danielc at analysisandsolutions dot com
New email:
PHP Version: OS:

 

 [2010-12-30 22:15 UTC] danielc at analysisandsolutions dot com
Description:
------------
One can not set the DateInterval::$days property.  It is readable.  All other properties of DateInterval shown in var_dump() are writeable.

While similar to Bug #52738, this involves an actual property of the DateInterval class.


Test script:
---------------
$i = new DateInterval('P1D');
$i->s = 8;
echo "S: $i->s\n";
echo "DAYS: $i->days\n";
$i->days = 6;
echo "DAYS: $i->days\n";


Expected result:
----------------
S: 8
DAYS: -99999
DAYS: 6


Actual result:
--------------
S: 8
DAYS: -99999
PHP Fatal error:  main(): Unknown property (days) in /home/danielc/test.php on line 7


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-24 03:49 UTC] stas@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: stas
 [2011-01-24 03:49 UTC] stas@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2011-01-24 18:39 UTC] danielc at analysisandsolutions dot com
-Status: Closed +Status: Assigned
 [2011-01-24 18:39 UTC] danielc at analysisandsolutions dot com
While the recent commit removes the fatal error, the property can not be written to.  Here is the output of the initial test script (above) as of svn revision 307713:

S: 8
DAYS: -99999
DAYS: -99999
 [2011-01-30 11:57 UTC] stas@php.net
Hmm... Actually you're not supposed to be writing to days property, it should be read only. I'll fix it.
 [2011-01-30 13:59 UTC] danielc at analysisandsolutions dot com
Why should days be read only?  All other properties are writable.  Days needs to be writable too.  Writing to various properties is necessary when overloading the date classes (to compensate for bugs, etc).
 [2013-02-17 10:45 UTC] stas@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

$days is not writable by design of DateInterval since it's a derived property. So 
not being able to write it is not a bug. If additional functionality is needed, 
please create FR or RFC describing how it should work.
 [2013-02-17 10:45 UTC] stas@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 18:01:31 2024 UTC