Bug #65654 [Opn]: Extending DateInterval and unable to use $this->days
| From: | derick@php.net | Date: | Wed, 11 Sep 2013 13:36:48 +0000 |
| Subject: | Bug #65654 [Opn]: Extending DateInterval and unable to use $this->days | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-181523@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65654&edit=1
ID: 65654
Updated by: derick@php.net
Reported by: steven at gowebprint dot com
Summary: Extending DateInterval and unable to use $this->days
Status: Open
Type: Bug
Package: Date/time related
Operating System: Cent OS 6.4
PHP Version: 5.4.19
Block user comment: N
Private report: N
New Comment:
"I am trying to extend DateTime and DaveInterval to add extra functionality to the core
classes, but I have been unable to write to $this->days internally to the object."
That's not really a bug. "days" is a calculated version that only make sense in the
context of having compared two other DateTime objects. Without those other two objects presents, its
value makes no sense.
Previous Comments:
------------------------------------------------------------------------
[2013-09-11 13:26:49] steven at gowebprint dot com
Description:
------------
I am trying to extend DateTime and DaveInterval to add extra functionality to the core classes, but
I have been unable to write to $this->days internally to the object.
As a side note, I have been able to cause a seg fault within our application when writing to
$interval->days = 100 externally, but unable to reproduce on a small script.
Test script:
---------------
http://pastebin.com/tBay704K
Expected result:
----------------
object(DateInterval)[3]
public 'y' => int 1
public 'm' => int 0
public 'd' => int 0
public 'h' => int 0
public 'i' => int 0
public 's' => int 0
public 'weekday' => int 0
public 'weekday_behavior' => int 0
public 'first_last_day_of' => int 0
public 'invert' => int 1
public 'days' => int 365
public 'special_type' => int 0
public 'special_amount' => int 0
public 'have_weekday_relative' => int 0
public 'have_special_relative' => int 0
object(test\DateInterval)[4]
public 'days' => int 365
public 'y' => int 1
public 'm' => int 0
public 'd' => int 0
public 'h' => int 0
public 'i' => int 0
public 's' => int 0
public 'weekday' => int 0
public 'weekday_behavior' => int 0
public 'first_last_day_of' => int 0
public 'invert' => int 1
public 'special_type' => int 0
public 'special_amount' => int 0
public 'have_weekday_relative' => int 0
public 'have_special_relative' => int 0
Actual result:
--------------
object(DateInterval)[3]
public 'y' => int 1
public 'm' => int 0
public 'd' => int 0
public 'h' => int 0
public 'i' => int 0
public 's' => int 0
public 'weekday' => int 0
public 'weekday_behavior' => int 0
public 'first_last_day_of' => int 0
public 'invert' => int 1
public 'days' => int 365
public 'special_type' => int 0
public 'special_amount' => int 0
public 'have_weekday_relative' => int 0
public 'have_special_relative' => int 0
object(test\DateInterval)[4]
public 'days' => boolean false
public 'y' => int 1
public 'm' => int 0
public 'd' => int 0
public 'h' => int 0
public 'i' => int 0
public 's' => int 0
public 'weekday' => int 0
public 'weekday_behavior' => int 0
public 'first_last_day_of' => int 0
public 'invert' => int 1
public 'special_type' => int 0
public 'special_amount' => int 0
public 'have_weekday_relative' => int 0
public 'have_special_relative' => int 0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65654&edit=1