php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69587 DateInterval properties and isset
Submitted: 2015-05-06 19:22 UTC Modified: 2016-04-20 15:50 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: charlesw at ex-situ dot com Assigned: jhdxr
Status: Closed Package: Date/time related
PHP Version: 7.0.5 OS: All
Private report: No CVE-ID:
 [2015-05-06 19:22 UTC] charlesw at ex-situ dot com
Description:
------------
Testing public properties on DateInterval objects with isset returns false even when they contain data. Running a print_r or var_dump on the object BEFORE testing isset will provide the desired result.

Test script:
---------------
$currentDate = new DateTime();
$targetDate = new DateTime('2015-03-05 11:11:11');
$interval = $currentDate->diff($targetDate);
// var_dump($interval); // Uncomment and isset will give the expected response
var_dump($interval->y);
var_dump($interval->m);
var_dump(isset($interval->y));
var_dump(isset($interval->m));


Expected result:
----------------
int(0)
int(2)
bool(true)
bool(true)


Actual result:
--------------
int(0)
int(2)
bool(false)
bool(false)

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-06 20:15 UTC] cmb@php.net
-Summary: SPL objects (DateInterval) and isset +Summary: DateInterval properties and isset -Status: Open +Status: Verified -Package: SPL related +Package: Date/time related
 [2015-05-06 20:15 UTC] cmb@php.net
DateTime doesn't belong to SPL, so I changed the package and the summary.

Otherwise verified: <http://3v4l.org/D7bcM>. Seems to be related to bug #67621.
 [2015-05-24 15:32 UTC] cmb@php.net
Closely related to bug #67934.
 [2016-04-20 15:50 UTC] jhdxr@php.net
-Status: Verified +Status: Assigned -Operating System: CentOS / OSX / Other +Operating System: All -PHP Version: 5.6.8 +PHP Version: 7.0.5 -Assigned To: +Assigned To: jhdxr
 [2016-11-13 05:37 UTC] krakjoe@php.net
Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=php-src.git;a=commit;h=23f9e482732b99f381e37afa77e04c2c480f372d
Log: fix bug #69587 DateInterval properties and isset
 [2016-11-13 05:37 UTC] krakjoe@php.net
-Status: Assigned +Status: Closed
 [2016-11-13 05:38 UTC] krakjoe@php.net
Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=php-src.git;a=commit;h=23f9e482732b99f381e37afa77e04c2c480f372d
Log: fix bug #69587 DateInterval properties and isset
 [2016-11-13 05:40 UTC] krakjoe@php.net
Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=php-src.git;a=commit;h=23f9e482732b99f381e37afa77e04c2c480f372d
Log: fix bug #69587 DateInterval properties and isset
 [2016-11-22 13:14 UTC] krakjoe@php.net
Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=php-src.git;a=commit;h=23f9e482732b99f381e37afa77e04c2c480f372d
Log: fix bug #69587 DateInterval properties and isset
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sat May 27 02:01:36 2017 UTC