diff options
author | Alexander Moskalev <a.moskalev@corp.badoo.com> | 2013-04-10 00:12:39 +0400 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2013-08-24 23:38:33 -0700 |
commit | b378b0b081c2c3dd4a7aa25ce4d37bad48db752e (patch) | |
tree | c293ff64b2c60115f824ba4abdacd37ad48ec72d | |
parent | e22c139fe09db7e74ad027db49d76921fc1a19fd (diff) | |
download | php-git-b378b0b081c2c3dd4a7aa25ce4d37bad48db752e.tar.gz |
Fix DateInterval->days value when object was created not from DateTime::diff()
-rw-r--r-- | ext/date/php_date.c | 6 | ||||
-rw-r--r-- | ext/date/tests/DateInterval_days_prop1.phpt | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index f091fed182..1c97781763 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -3568,7 +3568,11 @@ zval *date_interval_read_property(zval *object, zval *member, int type, const ze ALLOC_INIT_ZVAL(retval); Z_SET_REFCOUNT_P(retval, 0); - ZVAL_LONG(retval, value); + if (value != -99999) { + ZVAL_LONG(retval, value); + } else { + ZVAL_FALSE(retval); + } if (member == &tmp_member) { zval_dtor(member); diff --git a/ext/date/tests/DateInterval_days_prop1.phpt b/ext/date/tests/DateInterval_days_prop1.phpt new file mode 100644 index 0000000000..627b8f0b27 --- /dev/null +++ b/ext/date/tests/DateInterval_days_prop1.phpt @@ -0,0 +1,10 @@ +--TEST-- +Wrong var_dump(DateInterval->days) value +--FILE-- +<?php + +$interval = new DateInterval('P2Y4DT6H8M'); + +var_dump($interval->days); +--EXPECT-- +bool(false) |