Commit:    02f39220470d82066965b7d4657cadf40ac3dd6f
Author:    Anatol Belski <a...@php.net>         Mon, 10 Jun 2013 17:48:13 +0200
Parents:   a9d005c04e73621f81d441ef7afaae0dca18a58c
Branches:  PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=02f39220470d82066965b7d4657cadf40ac3dd6f

Log:
Fix a BC breach related to bug #53437

days and special_amount properties are exported as int again

Bugs:
https://bugs.php.net/53437

Changed paths:
  M  ext/date/php_date.c
  M  ext/date/tests/bug45682.phpt
  M  ext/date/tests/bug49778.phpt
  M  ext/date/tests/bug52113.phpt
  M  ext/date/tests/bug52808.phpt
  M  ext/date/tests/bug53437.phpt
  M  ext/date/tests/bug53437_var2.phpt
  M  ext/date/tests/bug53437_var3.phpt
  A  ext/date/tests/bug53437_var4.phpt
  M  ext/date/tests/bug60774.phpt
  M  ext/date/tests/date_diff1.phpt

diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index d09d254..28ac86b 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2384,18 +2384,9 @@ static HashTable 
*date_object_get_properties_interval(zval *object TSRMLS_DC)
                return props;
        }
 
-#define PHP_DATE_INTERVAL_ADD_PROPERTY_I64(n, f) \
-       do { \
-               char i64_buf[DATE_I64_BUF_LEN]; \
-               MAKE_STD_ZVAL(zv); \
-               DATE_I64A(intervalobj->diff->f, i64_buf, DATE_I64_BUF_LEN); \
-               ZVAL_STRING(zv, i64_buf, 1); \
-               zend_hash_update(props, n, strlen(n) + 1, &zv, sizeof(zval), 
NULL); \
-       } while(0);
-
 #define PHP_DATE_INTERVAL_ADD_PROPERTY(n,f) \
        MAKE_STD_ZVAL(zv); \
-       ZVAL_LONG(zv, intervalobj->diff->f); \
+       ZVAL_LONG(zv, (long)intervalobj->diff->f); \
        zend_hash_update(props, n, strlen(n) + 1, &zv, sizeof(zval), NULL);
 
        PHP_DATE_INTERVAL_ADD_PROPERTY("y", y);
@@ -2409,14 +2400,14 @@ static HashTable 
*date_object_get_properties_interval(zval *object TSRMLS_DC)
        PHP_DATE_INTERVAL_ADD_PROPERTY("first_last_day_of", first_last_day_of);
        PHP_DATE_INTERVAL_ADD_PROPERTY("invert", invert);
        if (intervalobj->diff->days != -99999) {
-               PHP_DATE_INTERVAL_ADD_PROPERTY_I64("days", days);
+               PHP_DATE_INTERVAL_ADD_PROPERTY("days", days);
        } else {
                MAKE_STD_ZVAL(zv);
                ZVAL_FALSE(zv);
                zend_hash_update(props, "days", 5, &zv, sizeof(zval), NULL);
        }
        PHP_DATE_INTERVAL_ADD_PROPERTY("special_type", special.type);
-       PHP_DATE_INTERVAL_ADD_PROPERTY_I64("special_amount", special.amount);
+       PHP_DATE_INTERVAL_ADD_PROPERTY("special_amount", special.amount);
        PHP_DATE_INTERVAL_ADD_PROPERTY("have_weekday_relative", 
have_weekday_relative);
        PHP_DATE_INTERVAL_ADD_PROPERTY("have_special_relative", 
have_special_relative);
 
diff --git a/ext/date/tests/bug45682.phpt b/ext/date/tests/bug45682.phpt
index 094c7fd..ea8fa94 100644
--- a/ext/date/tests/bug45682.phpt
+++ b/ext/date/tests/bug45682.phpt
@@ -34,11 +34,11 @@ object(DateInterval)#%d (15) {
   ["invert"]=>
   int(0)
   ["days"]=>
-  string(1) "3"
+  int(3)
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(1) "0"
+  int(0)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
diff --git a/ext/date/tests/bug49778.phpt b/ext/date/tests/bug49778.phpt
index cc52a23..2062d69 100644
--- a/ext/date/tests/bug49778.phpt
+++ b/ext/date/tests/bug49778.phpt
@@ -34,7 +34,7 @@ object(DateInterval)#1 (15) {
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(1) "0"
+  int(0)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
diff --git a/ext/date/tests/bug52113.phpt b/ext/date/tests/bug52113.phpt
index 862e92e..f4730c6 100644
--- a/ext/date/tests/bug52113.phpt
+++ b/ext/date/tests/bug52113.phpt
@@ -54,17 +54,17 @@ object(DateInterval)#3 (15) {
   ["invert"]=>
   int(0)
   ["days"]=>
-  string(1) "0"
+  int(0)
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(1) "0"
+  int(0)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
   int(0)
 }
-string(328) 
"O:12:"DateInterval":15:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:0;s:1:"h";i:4;s:1:"i";i:0;s:1:"s";i:0;s:7:"weekday";i:0;s:16:"weekday_behavior";i:0;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";s:1:"0";s:12:"special_type";i:0;s:14:"special_amount";s:1:"0";s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}"
+string(320) 
"O:12:"DateInterval":15:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:0;s:1:"h";i:4;s:1:"i";i:0;s:1:"s";i:0;s:7:"weekday";i:0;s:16:"weekday_behavior";i:0;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";i:0;s:12:"special_type";i:0;s:14:"special_amount";i:0;s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}"
 DateInterval::__set_state(array(
    'y' => 0,
    'm' => 0,
@@ -76,9 +76,9 @@ DateInterval::__set_state(array(
    'weekday_behavior' => 0,
    'first_last_day_of' => 0,
    'invert' => 0,
-   'days' => '0',
+   'days' => 0,
    'special_type' => 0,
-   'special_amount' => '0',
+   'special_amount' => 0,
    'have_weekday_relative' => 0,
    'have_special_relative' => 0,
 ))object(DateInterval)#5 (15) {
@@ -103,11 +103,11 @@ DateInterval::__set_state(array(
   ["invert"]=>
   int(0)
   ["days"]=>
-  string(1) "0"
+  int(0)
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(1) "0"
+  int(0)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
@@ -150,11 +150,11 @@ object(DatePeriod)#6 (6) {
     ["invert"]=>
     int(0)
     ["days"]=>
-    string(1) "0"
+    int(0)
     ["special_type"]=>
     int(0)
     ["special_amount"]=>
-    string(1) "0"
+    int(0)
     ["have_weekday_relative"]=>
     int(0)
     ["have_special_relative"]=>
@@ -187,11 +187,11 @@ object(DateInterval)#8 (15) {
   ["invert"]=>
   int(1)
   ["days"]=>
-  string(4) "2400"
+  int(2400)
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(2) "-1"
+  int(-1)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
@@ -234,11 +234,11 @@ object(DatePeriod)#9 (6) {
     ["invert"]=>
     int(0)
     ["days"]=>
-    string(1) "0"
+    int(0)
     ["special_type"]=>
     int(0)
     ["special_amount"]=>
-    string(1) "0"
+    int(0)
     ["have_weekday_relative"]=>
     int(0)
     ["have_special_relative"]=>
diff --git a/ext/date/tests/bug52808.phpt b/ext/date/tests/bug52808.phpt
index e3b38bb..1f0fc84 100644
--- a/ext/date/tests/bug52808.phpt
+++ b/ext/date/tests/bug52808.phpt
@@ -47,11 +47,11 @@ object(DateInterval)#%d (15) {
   ["invert"]=>
   int(1)
   ["days"]=>
-  string(3) "437"
+  int(437)
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(1) "0"
+  int(0)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
@@ -79,11 +79,11 @@ object(DateInterval)#%d (15) {
   ["invert"]=>
   int(0)
   ["days"]=>
-  string(3) "294"
+  int(294)
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(1) "0"
+  int(0)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
@@ -111,11 +111,11 @@ object(DateInterval)#%d (15) {
   ["invert"]=>
   int(0)
   ["days"]=>
-  string(3) "294"
+  int(294)
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(1) "0"
+  int(0)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
diff --git a/ext/date/tests/bug53437.phpt b/ext/date/tests/bug53437.phpt
index 7a282ab..2ea0914 100644
--- a/ext/date/tests/bug53437.phpt
+++ b/ext/date/tests/bug53437.phpt
@@ -77,7 +77,7 @@ object(DatePeriod)#1 (6) {
     ["special_type"]=>
     int(0)
     ["special_amount"]=>
-    string(1) "0"
+    int(0)
     ["have_weekday_relative"]=>
     int(0)
     ["have_special_relative"]=>
@@ -132,11 +132,11 @@ object(DatePeriod)#5 (6) {
     ["invert"]=>
     int(0)
     ["days"]=>
-    string(1) "0"
+    int(0)
     ["special_type"]=>
     int(0)
     ["special_amount"]=>
-    string(1) "0"
+    int(0)
     ["have_weekday_relative"]=>
     int(0)
     ["have_special_relative"]=>
diff --git a/ext/date/tests/bug53437_var2.phpt 
b/ext/date/tests/bug53437_var2.phpt
index 7056596..50aebda 100644
--- a/ext/date/tests/bug53437_var2.phpt
+++ b/ext/date/tests/bug53437_var2.phpt
@@ -39,7 +39,7 @@ object(DateInterval)#1 (15) {
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(1) "0"
+  int(0)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
@@ -67,11 +67,11 @@ object(DateInterval)#2 (15) {
   ["invert"]=>
   int(0)
   ["days"]=>
-  string(1) "0"
+  int(0)
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(1) "0"
+  int(0)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
diff --git a/ext/date/tests/bug53437_var3.phpt 
b/ext/date/tests/bug53437_var3.phpt
index 06f68df..da7d0bd 100644
--- a/ext/date/tests/bug53437_var3.phpt
+++ b/ext/date/tests/bug53437_var3.phpt
@@ -32,11 +32,11 @@ object(DateInterval)#1 (15) {
   ["invert"]=>
   int(0)
   ["days"]=>
-  string(1) "0"
+  int(0)
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(19) "9223372036854775807"
+  int(-1)
   ["have_weekday_relative"]=>
   int(9)
   ["have_special_relative"]=>
diff --git a/ext/date/tests/bug53437_var4.phpt 
b/ext/date/tests/bug53437_var4.phpt
new file mode 100644
index 0000000..03b0a54
--- /dev/null
+++ b/ext/date/tests/bug53437_var4.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Bug #53437 (Check that var_dump out is the same using the whole object or it's 
single properties), variation 4
+--FILE--
+<?php
+$dt = new DateTime('2009-10-11');
+
+$df = $dt->diff(new DateTime('2009-10-13'));
+
+var_dump($df,
+       $df->y,
+       $df->m,
+       $df->d,
+       $df->h,
+       $df->i,
+       $df->s,
+       $df->invert,
+       $df->days);
+
+?>
+==DONE==
+--EXPECTF--
+object(DateInterval)#%d (15) {
+  ["y"]=>
+  int(0)
+  ["m"]=>
+  int(0)
+  ["d"]=>
+  int(2)
+  ["h"]=>
+  int(0)
+  ["i"]=>
+  int(0)
+  ["s"]=>
+  int(0)
+  ["weekday"]=>
+  int(0)
+  ["weekday_behavior"]=>
+  int(0)
+  ["first_last_day_of"]=>
+  int(0)
+  ["invert"]=>
+  int(0)
+  ["days"]=>
+  int(2)
+  ["special_type"]=>
+  int(0)
+  ["special_amount"]=>
+  int(0)
+  ["have_weekday_relative"]=>
+  int(0)
+  ["have_special_relative"]=>
+  int(0)
+}
+int(0)
+int(0)
+int(2)
+int(0)
+int(0)
+int(0)
+int(0)
+int(2)
+==DONE==
diff --git a/ext/date/tests/bug60774.phpt b/ext/date/tests/bug60774.phpt
index 865928d..7045cd7 100644
--- a/ext/date/tests/bug60774.phpt
+++ b/ext/date/tests/bug60774.phpt
@@ -34,7 +34,7 @@ object(DateInterval)#1 (%d) {
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(1) "0"
+  int(0)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
diff --git a/ext/date/tests/date_diff1.phpt b/ext/date/tests/date_diff1.phpt
index 3f3d1da..a908cdb 100644
--- a/ext/date/tests/date_diff1.phpt
+++ b/ext/date/tests/date_diff1.phpt
@@ -50,11 +50,11 @@ object(DateInterval)#3 (15) {
   ["invert"]=>
   int(0)
   ["days"]=>
-  string(2) "33"
+  int(33)
   ["special_type"]=>
   int(0)
   ["special_amount"]=>
-  string(1) "0"
+  int(0)
   ["have_weekday_relative"]=>
   int(0)
   ["have_special_relative"]=>
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to