php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | |
Patch glopes_date_5.3.patch for Date/time related Bug #53437Patch version 2013-03-05 11:19 UTC Return to Bug #53437 | Download this patchThis patch is obsolete Obsoleted by patches:
Developer: ab@php.netdiff --git a/ext/date/php_date.c b/ext/date/php_date.c index 2e616b1..e9d9f17 100644 index 2e616b1..e9aa7b0 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -23,6 +23,7 @@ #include "php_main.h" +static HashTable *date_object_get_properties_period(zval *object TSRMLS_DC); zval *date_interval_read_property(zval *object, zval *member, int type TSRMLS_DC); void date_interval_write_property(zval *object, zval *member, zval *value TSRMLS_DC); +static zval *date_period_read_property(zval *object, zval *member, int type TSRMLS_DC); +static zval **date_period_get_property_ptr_ptr(zval *object, zval *member TSRMLS_DC); +static void date_period_write_property(zval *object, zval *member, zval *value TSRMLS_DC); +static zval *date_period_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC); +static zval **date_period_get_property_ptr_ptr(zval *object, zval *member, const zend_literal *key TSRMLS_DC); +static void date_period_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC); + +static int php_date_interval_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC); +static int php_date_interval_unserialize(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC); break; } - zend_hash_update(props, "timezone", 9, &zv, sizeof(zval), NULL); + zend_hash_update(out_container, "timezone", 9, &zv, sizeof(zval), NULL); } + } +} + + +static HashTable *date_object_get_properties(zval *object TSRMLS_DC) +{ + HashTable *props; + php_date_obj *dateobj; + + + + dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); + + props = zend_std_get_properties(object TSRMLS_CC); + + if (!dateobj->time || GC_G(gc_active)) { + return props; + } + } + date_object_to_serializable_elements(dateobj->time, props); + return props; } @@ -2246,11 +2268,10 @@ static zend_object_value date_object_clone_interval(zval *this_ptr TSRMLS_DC) + return props; } @@ -2246,11 +2268,10 @@ static zend_object_value date_object_clone_interval(zval *this_ptr TSRMLS_DC) static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC) { - HashTable *props; MAKE_STD_ZVAL(zv); \ ZVAL_LONG(zv, intervalobj->diff->f); \ - zend_hash_update(props, n, strlen(n) + 1, &zv, sizeof(zval), NULL); + zend_hash_update(props, n, sizeof(n), &zv, sizeof(zval), NULL); PHP_DATE_INTERVAL_ADD_PROPERTY("y", y); PHP_DATE_INTERVAL_ADD_PROPERTY("m", m); @@ -2279,6 +2300,8 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC) zend_hash_update(props, "days", 5, &zv, sizeof(zval), NULL); + 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); + 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); Line 295 (now 295), was 30 lines, now 9 lines + php_date_initialize_from_hash(dateobj, myht TSRMLS_CC); } /* }}} */ @@ -3691,20 +3786,6 @@ PHP_METHOD(DateInterval, __set_state) } /* }}} */ -/* {{{ proto DateInterval::__wakeup() -*/ -PHP_METHOD(DateInterval, __wakeup) -{ - zval *object = getThis(); - php_interval_obj *intobj; - HashTable *myht; - - intobj = (php_interval_obj *) zend_object_store_get_object(object TSRMLS_CC); - - myht = Z_OBJPROP_P(object); - - php_date_interval_initialize_from_hash(&return_value, &intobj, myht TSRMLS_CC); -} /* }}} */ /* {{{ proto DateInterval date_interval_create_from_date_string(string time) Uses the normal date parsers and sets up a DateInterval from the relative parts of the parsed string @@ -3732,6 +3813,187 @@ PHP_FUNCTION(date_interval_create_from_date_string) @@ -3732,6 +3827,187 @@ PHP_FUNCTION(date_interval_create_from_date_string) } /* }}} */ +#define PHP_DATE_INTERVAL_UNSER_RAW_SIZE 92 /* 6 * 8 + 4 * 4 + 8 + (4 + 8) + 2 * 4; not null-terminated */ + /* {{{ date_interval_format - */ static char *date_interval_format(char *format, int format_len, timelib_rel_time *t) { @@ -3838,6 +4100,43 @@ static int date_period_initialize(timelib_time **st, timelib_time **et, timelib_ @@ -3838,6 +4114,43 @@ static int date_period_initialize(timelib_time **st, timelib_time **et, timelib_ return retval; } +/* {{{ date_period_read_property */ +static zval *date_period_read_property(zval *object, zval *member, int type TSRMLS_DC) +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 TSRMLS_CC); + 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); +} +/* }}} */ + +/* {{{ date_period_get_property_ptr_ptr */ +static zval **date_period_get_property_ptr_ptr(zval *object, zval *member TSRMLS_DC) +static zval **date_period_get_property_ptr_ptr(zval *object, zval *member, const zend_literal *key TSRMLS_DC) +{ + return NULL; /* force fallback to read_property */ +} +/* }}} */ + +/* {{{ date_period_write_property */ +static void date_period_write_property(zval *object, zval *member, zval *value TSRMLS_DC) +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"); +} +/* }}} */ + /* {{{ proto DatePeriod::__construct(DateTime $start, DateInterval $interval, int recurrences|DateTime $end) Creates new DatePeriod object. */ @@ -3924,6 +4223,119 @@ PHP_METHOD(DatePeriod, __construct) @@ -3924,6 +4237,119 @@ PHP_METHOD(DatePeriod, __construct) } /* }}} */ +static int php_date_period_initialize_from_hash(php_period_obj *period_obj, HashTable *myht TSRMLS_DC) |
Copyright © 2001-2024 The PHP Group All rights reserved. |
Last updated: Wed Apr 24 19:01:31 2024 UTC |