Browse Source

Backported the fix for bug #53437

PHP-5.4.17
Anatol Belski 13 years ago
parent
commit
0f9cf35315
  1. 4
      NEWS
  2. 317
      ext/date/php_date.c
  3. 2
      ext/date/php_date.h
  4. 18
      ext/date/tests/bug45682.phpt
  5. 18
      ext/date/tests/bug48678.phpt
  6. 7
      ext/date/tests/bug49081.phpt
  7. 16
      ext/date/tests/bug49778.phpt
  8. 161
      ext/date/tests/bug52113.phpt
  9. 7
      ext/date/tests/bug52738.phpt
  10. 48
      ext/date/tests/bug52808.phpt
  11. 134
      ext/date/tests/bug53437.phpt
  12. 16
      ext/date/tests/date_diff1.phpt

4
NEWS

@ -8,6 +8,10 @@ PHP NEWS
. Fixed bug #64960 (Segfault in gc_zval_possible_root). (Laruence)
. Fixed bug #64934 (Apache2 TS crash with get_browser()). (Anatol)
- DateTime:
. Fixed bug #53437 (Crash when using unserialized DatePeriod instance).
(Gustavo, Derick, Anatol)
- FPM:
. Fixed Bug #64915 (error_log ignored when daemonize=0). (Remi)

317
ext/date/php_date.c

@ -39,6 +39,20 @@ static __inline __int64_t php_date_llabs( __int64_t i ) { return i >= 0 ? i : -i
static inline long long php_date_llabs( long long i ) { return i >= 0 ? i : -i; }
#endif
#ifdef PHP_WIN32
#define DATE_I64_BUF_LEN 65
# define DATE_I64A(i, s, len) _i64toa_s(i, s, len, 10)
# define DATE_A64I(i, s) i = _atoi64(s)
#else
#define DATE_I64_BUF_LEN 65
# define DATE_I64A(i, s, len) \
do { \
int st = snprintf(s, len, "%lld", i); \
s[st] = '\0'; \
} while (0);
# define DATE_A64I(i, s) i = atoll(s)
#endif
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX(arginfo_date, 0, 0, 1)
ZEND_ARG_INFO(0, format)
@ -472,6 +486,8 @@ const zend_function_entry date_funcs_interval[] = {
const zend_function_entry date_funcs_period[] = {
PHP_ME(DatePeriod, __construct, arginfo_date_period_construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
PHP_ME(DatePeriod, __wakeup, NULL, ZEND_ACC_PUBLIC)
PHP_ME(DatePeriod, __set_state, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_FE_END
};
@ -569,9 +585,13 @@ static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_
static HashTable *date_object_get_properties(zval *object TSRMLS_DC);
static HashTable *date_object_get_gc_interval(zval *object, zval ***table, int *n TSRMLS_DC);
static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC);
static HashTable *date_object_get_gc_period(zval *object, zval ***table, int *n TSRMLS_DC);
static HashTable *date_object_get_properties_period(zval *object TSRMLS_DC);
zval *date_interval_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC);
void date_interval_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC);
static zval *date_period_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC);
static void date_period_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC);
/* {{{ Module struct */
zend_module_entry date_module_entry = {
@ -1982,6 +2002,11 @@ static void date_register_classes(TSRMLS_D)
zend_class_implements(date_ce_period TSRMLS_CC, 1, zend_ce_traversable);
memcpy(&date_object_handlers_period, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_period.clone_obj = date_object_clone_period;
date_object_handlers_period.get_properties = date_object_get_properties_period;
date_object_handlers_period.get_property_ptr_ptr = NULL;
date_object_handlers_period.get_gc = date_object_get_gc_period;
date_object_handlers_period.read_property = date_period_read_property;
date_object_handlers_period.write_property = date_period_write_property;
#define REGISTER_PERIOD_CLASS_CONST_STRING(const_name, value) \
zend_declare_class_constant_long(date_ce_period, const_name, sizeof(const_name)-1, value TSRMLS_CC);
@ -2081,7 +2106,7 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
props = zend_std_get_properties(object TSRMLS_CC);
if (!dateobj->time) {
if (!dateobj->time || GC_G(gc_active)) {
return props;
}
@ -2229,7 +2254,6 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
zval *zv;
php_interval_obj *intervalobj;
intervalobj = (php_interval_obj *) zend_object_store_get_object(object TSRMLS_CC);
props = zend_std_get_properties(object TSRMLS_CC);
@ -2240,7 +2264,7 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
#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);
@ -2249,6 +2273,9 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
PHP_DATE_INTERVAL_ADD_PROPERTY("h", h);
PHP_DATE_INTERVAL_ADD_PROPERTY("i", i);
PHP_DATE_INTERVAL_ADD_PROPERTY("s", s);
PHP_DATE_INTERVAL_ADD_PROPERTY("weekday", weekday);
PHP_DATE_INTERVAL_ADD_PROPERTY("weekday_behavior", weekday_behavior);
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("days", days);
@ -2257,6 +2284,10 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
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("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);
return props;
}
@ -2358,6 +2389,7 @@ PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC)
object_init_ex(object, pce);
Z_SET_REFCOUNT_P(object, 1);
Z_UNSET_ISREF_P(object);
return object;
}
@ -3629,30 +3661,48 @@ PHP_METHOD(DateInterval, __construct)
}
/* }}} */
static long php_date_long_from_hash_element(HashTable *myht, char *element, size_t size)
{
zval **z_arg = NULL;
if (zend_hash_find(myht, element, size + 1, (void**) &z_arg) == SUCCESS) {
convert_to_long(*z_arg);
return Z_LVAL_PP(z_arg);
} else {
return -1;
}
}
static int php_date_interval_initialize_from_hash(zval **return_value, php_interval_obj **intobj, HashTable *myht TSRMLS_DC)
{
(*intobj)->diff = timelib_rel_time_ctor();
(*intobj)->diff->y = php_date_long_from_hash_element(myht, "y", 1);
(*intobj)->diff->m = php_date_long_from_hash_element(myht, "m", 1);
(*intobj)->diff->d = php_date_long_from_hash_element(myht, "d", 1);
(*intobj)->diff->h = php_date_long_from_hash_element(myht, "h", 1);
(*intobj)->diff->i = php_date_long_from_hash_element(myht, "i", 1);
(*intobj)->diff->s = php_date_long_from_hash_element(myht, "s", 1);
(*intobj)->diff->invert = php_date_long_from_hash_element(myht, "invert", 6);
(*intobj)->diff->days = php_date_long_from_hash_element(myht, "days", 4);
#define PHP_DATE_INTERVAL_READ_PROPERTY(element, member, itype, def) \
do { \
zval **z_arg = NULL; \
if (zend_hash_find(myht, element, strlen(element) + 1, (void**) &z_arg) == SUCCESS) { \
convert_to_long(*z_arg); \
(*intobj)->diff->member = (itype)Z_LVAL_PP(z_arg); \
} else { \
(*intobj)->diff->member = (itype)def; \
} \
} while (0);
#define PHP_DATE_INTERVAL_READ_PROPERTY_I64(element, member) \
do { \
zval **z_arg = NULL; \
if (zend_hash_find(myht, element, strlen(element) + 1, (void**) &z_arg) == SUCCESS) { \
convert_to_string(*z_arg); \
DATE_A64I((*intobj)->diff->member, Z_STRVAL_PP(z_arg)); \
} else { \
(*intobj)->diff->member = -1LL; \
} \
} while (0);
PHP_DATE_INTERVAL_READ_PROPERTY("y", y, timelib_sll, -1)
PHP_DATE_INTERVAL_READ_PROPERTY("m", m, timelib_sll, -1)
PHP_DATE_INTERVAL_READ_PROPERTY("d", d, timelib_sll, -1)
PHP_DATE_INTERVAL_READ_PROPERTY("h", h, timelib_sll, -1)
PHP_DATE_INTERVAL_READ_PROPERTY("i", i, timelib_sll, -1)
PHP_DATE_INTERVAL_READ_PROPERTY("s", s, timelib_sll, -1)
PHP_DATE_INTERVAL_READ_PROPERTY("weekday", weekday, int, -1)
PHP_DATE_INTERVAL_READ_PROPERTY("weekday_behavior", weekday_behavior, int, -1)
PHP_DATE_INTERVAL_READ_PROPERTY("first_last_day_of", first_last_day_of, int, -1)
PHP_DATE_INTERVAL_READ_PROPERTY("invert", invert, int, 0);
PHP_DATE_INTERVAL_READ_PROPERTY_I64("days", days);
PHP_DATE_INTERVAL_READ_PROPERTY("special_type", special.type, unsigned int, 0);
PHP_DATE_INTERVAL_READ_PROPERTY_I64("special_amount", special.amount);
PHP_DATE_INTERVAL_READ_PROPERTY("have_weekday_relative", have_weekday_relative, unsigned int, 0);
PHP_DATE_INTERVAL_READ_PROPERTY("have_special_relative", have_special_relative, unsigned int, 0);
(*intobj)->initialized = 1;
return 0;
@ -4256,6 +4306,229 @@ PHP_FUNCTION(date_sun_info)
timelib_time_dtor(t2);
}
/* }}} */
static HashTable *date_object_get_gc_period(zval *object, zval ***table, int *n TSRMLS_DC)
{
*table = NULL;
*n = 0;
return zend_std_get_properties(object TSRMLS_CC);
}
static HashTable *date_object_get_properties_period(zval *object TSRMLS_DC)
{
HashTable *props;
zval *zv;
php_period_obj *period_obj;
period_obj = zend_object_store_get_object(object TSRMLS_CC);
props = zend_std_get_properties(object TSRMLS_CC);
if (!period_obj->start || GC_G(gc_active)) {
return props;
}
MAKE_STD_ZVAL(zv);
if (period_obj->start) {
php_date_obj *date_obj;
object_init_ex(zv, date_ce_date);
date_obj = zend_object_store_get_object(zv TSRMLS_CC);
date_obj->time = timelib_time_clone(period_obj->start);
} else {
ZVAL_NULL(zv);
}
zend_hash_update(props, "start", sizeof("start"), &zv, sizeof(zv), NULL);
MAKE_STD_ZVAL(zv);
if (period_obj->current) {
php_date_obj *date_obj;
object_init_ex(zv, date_ce_date);
date_obj = zend_object_store_get_object(zv TSRMLS_CC);
date_obj->time = timelib_time_clone(period_obj->current);
} else {
ZVAL_NULL(zv);
}
zend_hash_update(props, "current", sizeof("current"), &zv, sizeof(zv), NULL);
MAKE_STD_ZVAL(zv);
if (period_obj->end) {
php_date_obj *date_obj;
object_init_ex(zv, date_ce_date);
date_obj = zend_object_store_get_object(zv TSRMLS_CC);
date_obj->time = timelib_time_clone(period_obj->end);
} else {
ZVAL_NULL(zv);
}
zend_hash_update(props, "end", sizeof("end"), &zv, sizeof(zv), NULL);
MAKE_STD_ZVAL(zv);
if (period_obj->interval) {
php_interval_obj *interval_obj;
object_init_ex(zv, date_ce_interval);
interval_obj = zend_object_store_get_object(zv TSRMLS_CC);
interval_obj->diff = timelib_rel_time_clone(period_obj->interval);
interval_obj->initialized = 1;
} else {
ZVAL_NULL(zv);
}
zend_hash_update(props, "interval", sizeof("interval"), &zv, sizeof(zv), NULL);
/* converted to larger type (int->long); must check when unserializing */
MAKE_STD_ZVAL(zv);
ZVAL_LONG(zv, (long) period_obj->recurrences);
zend_hash_update(props, "recurrences", sizeof("recurrences"), &zv, sizeof(zv), NULL);
MAKE_STD_ZVAL(zv);
ZVAL_BOOL(zv, period_obj->include_start_date);
zend_hash_update(props, "include_start_date", sizeof("include_start_date"), &zv, sizeof(zv), NULL);
return props;
}
static int php_date_period_initialize_from_hash(php_period_obj *period_obj, HashTable *myht TSRMLS_DC)
{
zval **ht_entry;
/* this function does no rollback on error */
if (zend_hash_find(myht, "start", sizeof("start"), (void**) &ht_entry) == SUCCESS) {
if (Z_TYPE_PP(ht_entry) == IS_OBJECT && Z_OBJCE_PP(ht_entry) == date_ce_date) {
php_date_obj *date_obj;
date_obj = zend_object_store_get_object(*ht_entry TSRMLS_CC);
period_obj->start = timelib_time_clone(date_obj->time);
} else if (Z_TYPE_PP(ht_entry) != IS_NULL) {
return 0;
}
} else {
return 0;
}
if (zend_hash_find(myht, "end", sizeof("end"), (void**) &ht_entry) == SUCCESS) {
if (Z_TYPE_PP(ht_entry) == IS_OBJECT && Z_OBJCE_PP(ht_entry) == date_ce_date) {
php_date_obj *date_obj;
date_obj = zend_object_store_get_object(*ht_entry TSRMLS_CC);
period_obj->end = timelib_time_clone(date_obj->time);
} else if (Z_TYPE_PP(ht_entry) != IS_NULL) {
return 0;
}
} else {
return 0;
}
if (zend_hash_find(myht, "current", sizeof("current"), (void**) &ht_entry) == SUCCESS) {
if (Z_TYPE_PP(ht_entry) == IS_OBJECT && Z_OBJCE_PP(ht_entry) == date_ce_date) {
php_date_obj *date_obj;
date_obj = zend_object_store_get_object(*ht_entry TSRMLS_CC);
period_obj->current = timelib_time_clone(date_obj->time);
} else if (Z_TYPE_PP(ht_entry) != IS_NULL) {
return 0;
}
} else {
return 0;
}
if (zend_hash_find(myht, "interval", sizeof("interval"), (void**) &ht_entry) == SUCCESS) {
if (Z_TYPE_PP(ht_entry) == IS_OBJECT && Z_OBJCE_PP(ht_entry) == date_ce_interval) {
php_interval_obj *interval_obj;
interval_obj = zend_object_store_get_object(*ht_entry TSRMLS_CC);
period_obj->interval = timelib_rel_time_clone(interval_obj->diff);
} else { /* interval is required */
return 0;
}
} else {
return 0;
}
if (zend_hash_find(myht, "recurrences", sizeof("recurrences"), (void**) &ht_entry) == SUCCESS &&
Z_TYPE_PP(ht_entry) == IS_LONG && Z_LVAL_PP(ht_entry) >= 0 && Z_LVAL_PP(ht_entry) <= INT_MAX) {
period_obj->recurrences = Z_LVAL_PP(ht_entry);
} else {
return 0;
}
if (zend_hash_find(myht, "include_start_date", sizeof("include_start_date"), (void**) &ht_entry) == SUCCESS &&
Z_TYPE_PP(ht_entry) == IS_BOOL) {
period_obj->include_start_date = Z_BVAL_PP(ht_entry);
} else {
return 0;
}
period_obj->initialized = 1;
return 1;
}
/* {{{ proto DatePeriod::__set_state()
*/
PHP_METHOD(DatePeriod, __set_state)
{
php_period_obj *period_obj;
zval *array;
HashTable *myht;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
RETURN_FALSE;
}
myht = Z_ARRVAL_P(array);
object_init_ex(return_value, date_ce_period);
period_obj = zend_object_store_get_object(return_value TSRMLS_CC);
if (!php_date_period_initialize_from_hash(period_obj, myht TSRMLS_CC)) {
php_error(E_ERROR, "Invalid serialization data for DatePeriod object");
}
}
/* }}} */
/* {{{ proto DatePeriod::__wakeup()
*/
PHP_METHOD(DatePeriod, __wakeup)
{
zval *object = getThis();
php_period_obj *period_obj;
HashTable *myht;
period_obj = zend_object_store_get_object(object TSRMLS_CC);
myht = Z_OBJPROP_P(object);
if (!php_date_period_initialize_from_hash(period_obj, myht TSRMLS_CC)) {
php_error(E_ERROR, "Invalid serialization data for DatePeriod object");
}
}
/* }}} */
/* {{{ date_period_read_property */
static zval *date_period_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC)
{
zval *zv;
if (type != BP_VAR_IS && type != BP_VAR_R) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Retrieval of DatePeriod properties for modification is unsupported");
}
Z_OBJPROP_P(object); /* build properties hash table */
zv = std_object_handlers.read_property(object, member, type, key TSRMLS_CC);
if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJ_HANDLER_P(zv, clone_obj)) {
/* defensive copy */
zend_object_value zov = Z_OBJ_HANDLER_P(zv, clone_obj)(zv TSRMLS_CC);
MAKE_STD_ZVAL(zv);
Z_TYPE_P(zv) = IS_OBJECT;
Z_OBJVAL_P(zv) = zov;
}
return zv;
}
/* }}} */
/* {{{ date_period_write_property */
static void date_period_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC)
{
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Writing to DatePeriod properties is unsupported");
}
/* }}} */
/*
* Local variables:
* tab-width: 4

2
ext/date/php_date.h

@ -88,6 +88,8 @@ PHP_FUNCTION(date_interval_format);
PHP_FUNCTION(date_interval_create_from_date_string);
PHP_METHOD(DatePeriod, __construct);
PHP_METHOD(DatePeriod, __wakeup);
PHP_METHOD(DatePeriod, __set_state);
/* Options and Configuration */
PHP_FUNCTION(date_default_timezone_set);

18
ext/date/tests/bug45682.phpt

@ -11,8 +11,8 @@ $other = new DateTime("31-July-2008");
$diff = date_diff($date, $other);
var_dump($diff);
--EXPECT--
object(DateInterval)#3 (8) {
--EXPECTF--
object(DateInterval)#%d (15) {
["y"]=>
int(0)
["m"]=>
@ -25,8 +25,22 @@ object(DateInterval)#3 (8) {
int(0)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(3)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}

18
ext/date/tests/bug48678.phpt

@ -15,8 +15,15 @@ DateInterval Object
[h] => 12
[i] => 30
[s] => 5
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] =>%s
[days] =>
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
DateInterval Object
(
@ -26,6 +33,13 @@ DateInterval Object
[h] => 12
[i] => 30
[s] => 5
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] =>%s
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)

7
ext/date/tests/bug49081.phpt

@ -17,6 +17,13 @@ DateInterval Object
[h] => 4
[i] => 0
[s] => 0
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] => 30
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)

16
ext/date/tests/bug49778.phpt

@ -8,7 +8,7 @@ echo $i->format("%d"), "\n";
echo $i->format("%a"), "\n";
?>
--EXPECT--
object(DateInterval)#1 (8) {
object(DateInterval)#1 (15) {
["y"]=>
int(0)
["m"]=>
@ -21,10 +21,24 @@ object(DateInterval)#1 (8) {
int(0)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
bool(false)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
7
(unknown)

161
ext/date/tests/bug52113.phpt

@ -32,7 +32,7 @@ var_dump($unser, $p);
?>
--EXPECT--
object(DateInterval)#3 (8) {
object(DateInterval)#3 (15) {
["y"]=>
int(0)
["m"]=>
@ -45,12 +45,26 @@ object(DateInterval)#3 (8) {
int(0)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
string(128) "O:12:"DateInterval":8:{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:6:"invert";i:0;s:4:"days";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,
@ -58,9 +72,16 @@ DateInterval::__set_state(array(
'h' => 4,
'i' => 0,
's' => 0,
'weekday' => 0,
'weekday_behavior' => 0,
'first_last_day_of' => 0,
'invert' => 0,
'days' => 0,
))object(DateInterval)#5 (8) {
'special_type' => 0,
'special_amount' => 0,
'have_weekday_relative' => 0,
'have_special_relative' => 0,
))object(DateInterval)#5 (15) {
["y"]=>
int(0)
["m"]=>
@ -73,14 +94,78 @@ DateInterval::__set_state(array(
int(0)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
object(DatePeriod)#6 (0) {
object(DatePeriod)#6 (6) {
["start"]=>
object(DateTime)#4 (3) {
["date"]=>
string(19) "2003-01-02 08:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["current"]=>
NULL
["end"]=>
NULL
["interval"]=>
object(DateInterval)#7 (15) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(4)
["i"]=>
int(0)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
["recurrences"]=>
int(3)
["include_start_date"]=>
bool(true)
}
object(DateInterval)#4 (8) {
object(DateInterval)#8 (15) {
["y"]=>
int(7)
["m"]=>
@ -93,10 +178,74 @@ object(DateInterval)#4 (8) {
int(3)
["s"]=>
int(2)
["weekday"]=>
int(-1)
["weekday_behavior"]=>
int(-1)
["first_last_day_of"]=>
int(-1)
["invert"]=>
int(1)
["days"]=>
int(2400)
["special_type"]=>
int(0)
["special_amount"]=>
int(-1)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
object(DatePeriod)#7 (0) {
object(DatePeriod)#9 (6) {
["start"]=>
object(DateTime)#6 (3) {
["date"]=>
string(19) "2003-01-02 08:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["current"]=>
NULL
["end"]=>
NULL
["interval"]=>
object(DateInterval)#7 (15) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(4)
["i"]=>
int(0)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
["recurrences"]=>
int(3)
["include_start_date"]=>
bool(true)
}

7
ext/date/tests/bug52738.phpt

@ -27,6 +27,13 @@ di Object
[h] => 0
[i] => 0
[s] => 0
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] =>
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)

48
ext/date/tests/bug52808.phpt

@ -25,7 +25,7 @@ foreach($intervals as $iv) {
echo "==DONE==\n";
?>
--EXPECTF--
object(DateInterval)#%d (8) {
object(DateInterval)#%d (15) {
["y"]=>
int(1)
["m"]=>
@ -38,12 +38,26 @@ object(DateInterval)#%d (8) {
int(30)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(1)
["days"]=>
int(437)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
object(DateInterval)#%d (8) {
object(DateInterval)#%d (15) {
["y"]=>
int(0)
["m"]=>
@ -56,12 +70,26 @@ object(DateInterval)#%d (8) {
int(30)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(294)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
object(DateInterval)#%d (8) {
object(DateInterval)#%d (15) {
["y"]=>
int(0)
["m"]=>
@ -74,10 +102,24 @@ object(DateInterval)#%d (8) {
int(30)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(294)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
DateInterval::__construct(): Failed to parse interval (2007-05-11T15:30:00Z/)
DateInterval::__construct(): Failed to parse interval (2007-05-11T15:30:00Z)

134
ext/date/tests/bug53437.phpt

@ -1,7 +1,5 @@
--TEST--
Bug #53437 (Crash when using unserialized DatePeriod instance)
--XFAIL--
Bug #53437 Not fixed yet
Bug #53437 (Crash when using unserialized DatePeriod instance), variation 1
--FILE--
<?php
$dp = new DatePeriod(new DateTime('2010-01-01 UTC'), new DateInterval('P1D'), 2);
@ -20,9 +18,137 @@ $dpu = unserialize($ser); // $dpu has invalid values???
var_dump($dpu);
echo "Unserialized:\r\n";
// ???which leads to CRASH:
foreach($dpu as $dt) {
echo $dt->format('Y-m-d H:i:s')."\r\n";
}
?>
==DONE==
--EXPECT--
Original:
2010-01-01 00:00:00
2010-01-02 00:00:00
2010-01-03 00:00:00
object(DatePeriod)#1 (6) {
["start"]=>
object(DateTime)#2 (3) {
["date"]=>
string(19) "2010-01-01 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["current"]=>
object(DateTime)#4 (3) {
["date"]=>
string(19) "2010-01-04 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["end"]=>
NULL
["interval"]=>
object(DateInterval)#5 (15) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(1)
["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"]=>
bool(false)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
["recurrences"]=>
int(3)
["include_start_date"]=>
bool(true)
}
object(DatePeriod)#5 (6) {
["start"]=>
object(DateTime)#10 (3) {
["date"]=>
string(19) "2010-01-01 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["current"]=>
object(DateTime)#7 (3) {
["date"]=>
string(19) "2010-01-04 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["end"]=>
NULL
["interval"]=>
object(DateInterval)#8 (15) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(1)
["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(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
["recurrences"]=>
int(3)
["include_start_date"]=>
bool(true)
}
Unserialized:
2010-01-01 00:00:00
2010-01-02 00:00:00
2010-01-03 00:00:00
==DONE==

16
ext/date/tests/date_diff1.phpt

@ -28,7 +28,7 @@ object(DateTime)#2 (3) {
["timezone"]=>
string(3) "EDT"
}
object(DateInterval)#3 (8) {
object(DateInterval)#3 (15) {
["y"]=>
int(0)
["m"]=>
@ -41,8 +41,22 @@ object(DateInterval)#3 (8) {
int(19)
["s"]=>
int(40)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(33)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
Loading…
Cancel
Save