[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-cvs
Subject:    [PHP-CVS] [php-src] master: Show the 'have_special_relative' property in var_dumps, and disallow ser
From:       Derick Rethans <noreply () php ! net>
Date:       2022-04-29 15:38:34
Message-ID: fWTy1xIFj4U0OFNS9dGnVRZ1lSohE6S9ohiDb8QwpY () main ! php ! net
[Download RAW message or body]

Author: Derick Rethans (derickr)
Date: 2022-04-29T10:27:40+01:00

Commit: https://github.com/php/php-src/commit/f4e5010aa995862b60473376c7242422b53b8191
 Raw diff: https://github.com/php/php-src/commit/f4e5010aa995862b60473376c7242422b53b8191.diff


Show the 'have_special_relative' property in var_dumps, and disallow serialization if \
set

Changed paths:
  M  ext/date/php_date.c
  M  ext/date/tests/DatePeriod_set_state.phpt
  M  ext/date/tests/bug45682.phpt
  M  ext/date/tests/bug48678.phpt
  M  ext/date/tests/bug49081.phpt
  M  ext/date/tests/bug49778.phpt
  M  ext/date/tests/bug52113.phpt
  M  ext/date/tests/bug52738.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_var4.phpt
  M  ext/date/tests/bug53437_var5.phpt
  M  ext/date/tests/bug53437_var6.phpt
  M  ext/date/tests/bug60774.phpt
  M  ext/date/tests/bug66545.phpt
  M  ext/date/tests/bug70153.phpt
  M  ext/date/tests/bug71700.phpt
  M  ext/date/tests/bug73091.phpt
  M  ext/date/tests/bug74274.phpt
  M  ext/date/tests/bug74524.phpt
  M  ext/date/tests/bug77571.phpt
  M  ext/date/tests/bug78452.phpt
  M  ext/date/tests/bug79015.phpt
  M  ext/date/tests/date_diff1.phpt
  M  ext/date/tests/date_time_fractions.phpt


Diff:

diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 7dc885d56aae..0dff004b676c 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2093,8 +2093,9 @@ static void date_interval_object_to_hash(php_interval_obj \
*intervalobj, HashTabl  PHP_DATE_INTERVAL_ADD_PROPERTY("special_type", special.type);
 		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);
 	}
+	/* Records whether this is a special relative interval that can't be serialized */
+	PHP_DATE_INTERVAL_ADD_PROPERTY("have_special_relative", have_special_relative);
 
 #undef PHP_DATE_INTERVAL_ADD_PROPERTY
 }
@@ -4222,6 +4223,10 @@ PHP_METHOD(DateInterval, __serialize)
 	intervalobj = Z_PHPINTERVAL_P(object);
 	DATE_CHECK_INITIALIZED(intervalobj->initialized, DateInterval);
 
+	if (intervalobj->diff->have_special_relative) {
+		zend_throw_exception_ex(NULL, 0, "Serializing special relative time specifications \
is not supported"); +	}
+
 	array_init(return_value);
 	myht = Z_ARRVAL_P(return_value);
 	date_interval_object_to_hash(intervalobj, myht, true);
diff --git a/ext/date/tests/DatePeriod_set_state.phpt \
b/ext/date/tests/DatePeriod_set_state.phpt index eaf7d4dfe9e9..558afe3bea56 100644
--- a/ext/date/tests/DatePeriod_set_state.phpt
+++ b/ext/date/tests/DatePeriod_set_state.phpt
@@ -53,6 +53,8 @@ object(DatePeriod)#%d (6) {
     int(0)
     ["days"]=>
     bool(false)
+    ["have_special_relative"]=>
+    int(0)
   }
   ["recurrences"]=>
   int(25)
diff --git a/ext/date/tests/bug45682.phpt b/ext/date/tests/bug45682.phpt
index 7568fd07d9bc..989c9451614f 100644
--- a/ext/date/tests/bug45682.phpt
+++ b/ext/date/tests/bug45682.phpt
@@ -32,4 +32,6 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   int(3)
+  ["have_special_relative"]=>
+  int(0)
 }
diff --git a/ext/date/tests/bug48678.phpt b/ext/date/tests/bug48678.phpt
index df1571a82964..8ef58ca6af7e 100644
--- a/ext/date/tests/bug48678.phpt
+++ b/ext/date/tests/bug48678.phpt
@@ -19,6 +19,7 @@ DateInterval Object
     [f] => 0
     [invert] => 0
     [days] => 
+    [have_special_relative] => 0
 )
 DateInterval Object
 (
@@ -31,4 +32,5 @@ DateInterval Object
     [f] => 0
     [invert] => 0
     [days] => 
+    [have_special_relative] => 0
 )
diff --git a/ext/date/tests/bug49081.phpt b/ext/date/tests/bug49081.phpt
index c29075e17cea..0e679da8b3a0 100644
--- a/ext/date/tests/bug49081.phpt
+++ b/ext/date/tests/bug49081.phpt
@@ -20,4 +20,5 @@ DateInterval Object
     [f] => 0
     [invert] => 0
     [days] => 30
+    [have_special_relative] => 0
 )
diff --git a/ext/date/tests/bug49778.phpt b/ext/date/tests/bug49778.phpt
index cce69f8e7748..2774d1b0a724 100644
--- a/ext/date/tests/bug49778.phpt
+++ b/ext/date/tests/bug49778.phpt
@@ -27,6 +27,8 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   bool(false)
+  ["have_special_relative"]=>
+  int(0)
 }
 7
 (unknown)
diff --git a/ext/date/tests/bug52113.phpt b/ext/date/tests/bug52113.phpt
index c6e280cd4066..f973f210162a 100644
--- a/ext/date/tests/bug52113.phpt
+++ b/ext/date/tests/bug52113.phpt
@@ -52,6 +52,8 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   int(0)
+  ["have_special_relative"]=>
+  int(0)
 }
 string(332) "O:12:"DateInterval":16:{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:1:"f";d: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(
@@ -64,6 +66,7 @@ string(332) \
"O:12:"DateInterval":16:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:0;s:1:"h"  'f' => 0.0,
    'invert' => 0,
    'days' => 0,
+   'have_special_relative' => 0,
 ))object(DateInterval)#%d (%d) {
   ["y"]=>
   int(0)
@@ -83,6 +86,8 @@ string(332) \
"O:12:"DateInterval":16:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:0;s:1:"h"  int(0)
   ["days"]=>
   int(0)
+  ["have_special_relative"]=>
+  int(0)
 }
 object(DatePeriod)#%d (6) {
   ["start"]=>
@@ -118,6 +123,8 @@ object(DatePeriod)#%d (6) {
     int(0)
     ["days"]=>
     int(0)
+    ["have_special_relative"]=>
+    int(0)
   }
   ["recurrences"]=>
   int(3)
@@ -143,6 +150,8 @@ object(DateInterval)#%d (%d) {
   int(1)
   ["days"]=>
   int(2400)
+  ["have_special_relative"]=>
+  int(0)
 }
 object(DatePeriod)#%d (6) {
   ["start"]=>
@@ -178,6 +187,8 @@ object(DatePeriod)#%d (6) {
     int(0)
     ["days"]=>
     int(0)
+    ["have_special_relative"]=>
+    int(0)
   }
   ["recurrences"]=>
   int(3)
diff --git a/ext/date/tests/bug52738.phpt b/ext/date/tests/bug52738.phpt
index 46be78af1943..e4d2595e75e2 100644
--- a/ext/date/tests/bug52738.phpt
+++ b/ext/date/tests/bug52738.phpt
@@ -31,4 +31,5 @@ di Object
     [f] => 0
     [invert] => 0
     [days] => 
+    [have_special_relative] => 0
 )
diff --git a/ext/date/tests/bug52808.phpt b/ext/date/tests/bug52808.phpt
index 190d5184393d..3abd5261bd0b 100644
--- a/ext/date/tests/bug52808.phpt
+++ b/ext/date/tests/bug52808.phpt
@@ -44,6 +44,8 @@ object(DateInterval)#%d (%d) {
   int(1)
   ["days"]=>
   int(437)
+  ["have_special_relative"]=>
+  int(0)
 }
 object(DateInterval)#%d (%d) {
   ["y"]=>
@@ -64,6 +66,8 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   int(294)
+  ["have_special_relative"]=>
+  int(0)
 }
 object(DateInterval)#%d (%d) {
   ["y"]=>
@@ -84,6 +88,8 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   int(294)
+  ["have_special_relative"]=>
+  int(0)
 }
 Failed to parse interval (2007-05-11T15:30:00Z/)
 Failed to parse interval (2007-05-11T15:30:00Z)
diff --git a/ext/date/tests/bug53437.phpt b/ext/date/tests/bug53437.phpt
index 349fd5b39f0b..afb67ad41a1b 100644
--- a/ext/date/tests/bug53437.phpt
+++ b/ext/date/tests/bug53437.phpt
@@ -69,6 +69,8 @@ object(DatePeriod)#%d (6) {
     int(0)
     ["days"]=>
     bool(false)
+    ["have_special_relative"]=>
+    int(0)
   }
   ["recurrences"]=>
   int(3)
@@ -116,6 +118,8 @@ object(DatePeriod)#%d (6) {
     int(0)
     ["days"]=>
     bool(false)
+    ["have_special_relative"]=>
+    int(0)
   }
   ["recurrences"]=>
   int(3)
diff --git a/ext/date/tests/bug53437_var2.phpt b/ext/date/tests/bug53437_var2.phpt
index 23527684f39e..b625d572f7a0 100644
--- a/ext/date/tests/bug53437_var2.phpt
+++ b/ext/date/tests/bug53437_var2.phpt
@@ -1,5 +1,5 @@
 --TEST--
-Bug #53437 DateInterval basic serialization
+Bug #53437 (DateInterval basic serialization)
 --FILE--
 <?php
 $di0 = new DateInterval('P2Y4DT6H8M');
@@ -31,6 +31,8 @@ object(DateInterval)#1 (%d) {
   int(0)
   ["days"]=>
   bool(false)
+  ["have_special_relative"]=>
+  int(0)
 }
 object(DateInterval)#2 (%d) {
   ["y"]=>
@@ -51,4 +53,6 @@ object(DateInterval)#2 (%d) {
   int(0)
   ["days"]=>
   bool(false)
+  ["have_special_relative"]=>
+  int(0)
 }
diff --git a/ext/date/tests/bug53437_var4.phpt b/ext/date/tests/bug53437_var4.phpt
index 05defd24125e..7c558a24c884 100644
--- a/ext/date/tests/bug53437_var4.phpt
+++ b/ext/date/tests/bug53437_var4.phpt
@@ -40,6 +40,8 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   int(2)
+  ["have_special_relative"]=>
+  int(0)
 }
 int(0)
 int(0)
diff --git a/ext/date/tests/bug53437_var5.phpt b/ext/date/tests/bug53437_var5.phpt
index 61ebffe5237d..8e04fea933d5 100644
--- a/ext/date/tests/bug53437_var5.phpt
+++ b/ext/date/tests/bug53437_var5.phpt
@@ -1,5 +1,5 @@
 --TEST--
-Bug #53437 DateInterval unserialize bad data, 64 bit
+Bug #53437 (DateInterval unserialize bad data, 64 bit)
 --SKIPIF--
 <?php if (PHP_INT_SIZE != 8) { die('skip true 64 bit only'); } ?>
 --FILE--
@@ -30,4 +30,6 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   int(0)
+  ["have_special_relative"]=>
+  int(0)
 }
diff --git a/ext/date/tests/bug53437_var6.phpt b/ext/date/tests/bug53437_var6.phpt
index e03a28ec6b4c..aa7657eec14b 100644
--- a/ext/date/tests/bug53437_var6.phpt
+++ b/ext/date/tests/bug53437_var6.phpt
@@ -1,5 +1,5 @@
 --TEST--
-Bug #53437 DateInterval unserialize bad data, 64 bit
+Bug #53437 (DateInterval unserialize bad data, 64 bit)
 --SKIPIF--
 <?php if (PHP_INT_SIZE != 8) { die('skip true 64 bit only'); } ?>
 --FILE--
@@ -30,4 +30,6 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   int(0)
+  ["have_special_relative"]=>
+  int(0)
 }
diff --git a/ext/date/tests/bug60774.phpt b/ext/date/tests/bug60774.phpt
index 6349ee0f3734..130048e71de4 100644
--- a/ext/date/tests/bug60774.phpt
+++ b/ext/date/tests/bug60774.phpt
@@ -27,6 +27,8 @@ object(DateInterval)#1 (%d) {
   int(0)
   ["days"]=>
   bool(false)
+  ["have_special_relative"]=>
+  int(0)
 }
 2
 (unknown)
diff --git a/ext/date/tests/bug66545.phpt b/ext/date/tests/bug66545.phpt
index 85518920f433..efe3e6d1eab4 100644
--- a/ext/date/tests/bug66545.phpt
+++ b/ext/date/tests/bug66545.phpt
@@ -27,4 +27,5 @@ DateInterval Object
     [f] => 0
     [invert] => 0
     [days] => 14
+    [have_special_relative] => 0
 )
diff --git a/ext/date/tests/bug70153.phpt b/ext/date/tests/bug70153.phpt
index ca82dba980cc..556a5b4f7fd8 100644
--- a/ext/date/tests/bug70153.phpt
+++ b/ext/date/tests/bug70153.phpt
@@ -25,6 +25,7 @@ DateInterval Object
     [f] => 0
     [invert] => 0
     [days] => 
+    [have_special_relative] => 0
 )
 O:12:"DateInterval":16:{s:1:"y";i:0;s:1:"m";i:1;s:1:"d";i:0;s:1:"h";i:0;s:1:"i";i:0;s \
:1:"s";i:0;s:1:"f";d: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";b:0;s:12:"special_type";i:0;s:14:"special_amou \
nt";i:0;s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}DateInterval \
Object  (
@@ -37,6 +38,7 @@ O:12:"DateInterval":16:{s:1:"y";i:0;s:1:"m";i:1;s:1:"d";i:0;s:1:"h";i:0;s:1:"i";
  [f] => 0
     [invert] => 0
     [days] => 
+    [have_special_relative] => 0
 )
 bool(false)
 bool(false)
diff --git a/ext/date/tests/bug71700.phpt b/ext/date/tests/bug71700.phpt
index 8a9ec3992fc0..243511fbf976 100644
--- a/ext/date/tests/bug71700.phpt
+++ b/ext/date/tests/bug71700.phpt
@@ -31,4 +31,6 @@ object(DateInterval)#3 (%d) {
   int(0)
   ["days"]=>
   int(30)
+  ["have_special_relative"]=>
+  int(0)
 }
diff --git a/ext/date/tests/bug73091.phpt b/ext/date/tests/bug73091.phpt
index b75951d036e4..7f16a024ad5b 100644
--- a/ext/date/tests/bug73091.phpt
+++ b/ext/date/tests/bug73091.phpt
@@ -31,4 +31,6 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   int(-1)
+  ["have_special_relative"]=>
+  int(0)
 }
diff --git a/ext/date/tests/bug74274.phpt b/ext/date/tests/bug74274.phpt
index f5b7f6595454..b83a2b641c89 100644
--- a/ext/date/tests/bug74274.phpt
+++ b/ext/date/tests/bug74274.phpt
@@ -20,4 +20,5 @@ DateInterval Object
     [f] => 0
     [invert] => 0
     [days] => 1
+    [have_special_relative] => 0
 )
diff --git a/ext/date/tests/bug74524.phpt b/ext/date/tests/bug74524.phpt
index 40cca0210885..93f4cd920992 100644
--- a/ext/date/tests/bug74524.phpt
+++ b/ext/date/tests/bug74524.phpt
@@ -22,4 +22,5 @@ DateInterval Object
     [f] => 0.920541
     [invert] => 1
     [days] => 227
+    [have_special_relative] => 0
 )
diff --git a/ext/date/tests/bug77571.phpt b/ext/date/tests/bug77571.phpt
index 673b943256e4..bc85354002cb 100644
--- a/ext/date/tests/bug77571.phpt
+++ b/ext/date/tests/bug77571.phpt
@@ -1,5 +1,5 @@
 --TEST--
-Bug #77571 (DateTime's diff DateInterval incorrect in timezones from UTC+01:00 to \
UTC+12:00 +Bug #77571 (DateTime's diff DateInterval incorrect in timezones from \
                UTC+01:00 to UTC+12:00)
 --FILE--
 <?php
 
@@ -23,4 +23,5 @@ DateInterval Object
     [f] => 0
     [invert] => 0
     [days] => 35
+    [have_special_relative] => 0
 )
diff --git a/ext/date/tests/bug78452.phpt b/ext/date/tests/bug78452.phpt
index dec40fafea30..ac4aa887f286 100644
--- a/ext/date/tests/bug78452.phpt
+++ b/ext/date/tests/bug78452.phpt
@@ -27,4 +27,6 @@ object(DateInterval)#3 (%d) {
   int(1)
   ["days"]=>
   int(33)
+  ["have_special_relative"]=>
+  int(0)
 }
diff --git a/ext/date/tests/bug79015.phpt b/ext/date/tests/bug79015.phpt
index 2059658e1e05..69a197563ea8 100644
--- a/ext/date/tests/bug79015.phpt
+++ b/ext/date/tests/bug79015.phpt
@@ -25,4 +25,6 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   bool(false)
+  ["have_special_relative"]=>
+  int(0)
 }
diff --git a/ext/date/tests/date_diff1.phpt b/ext/date/tests/date_diff1.phpt
index e3556590f8e3..437e43fc640a 100644
--- a/ext/date/tests/date_diff1.phpt
+++ b/ext/date/tests/date_diff1.phpt
@@ -47,4 +47,6 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   int(33)
+  ["have_special_relative"]=>
+  int(0)
 }
diff --git a/ext/date/tests/date_time_fractions.phpt \
b/ext/date/tests/date_time_fractions.phpt index 215b7c92333b..ada2e3e77207 100644
--- a/ext/date/tests/date_time_fractions.phpt
+++ b/ext/date/tests/date_time_fractions.phpt
@@ -77,6 +77,8 @@ object(DateInterval)#%d (%d) {
   int(0)
   ["days"]=>
   int(0)
+  ["have_special_relative"]=>
+  int(0)
 }
 2016-10-03 13:20:06.724934
 2016-10-03 13:20:07.103123

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic