stas Mon, 24 Jan 2011 02:31:48 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=307689
Log: Fixed bug #5273 (Can't use new properties in class extended from DateInterval) Bug: http://bugs.php.net/5273 (Closed) ISAPI crash on shutdown Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/date/php_date.c A php/php-src/branches/PHP_5_3/ext/date/tests/bug52738.phpt U php/php-src/trunk/ext/date/php_date.c A php/php-src/trunk/ext/date/tests/bug52738.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2011-01-24 01:15:41 UTC (rev 307688) +++ php/php-src/branches/PHP_5_3/NEWS 2011-01-24 02:31:48 UTC (rev 307689) @@ -36,6 +36,8 @@ no effect. (Derick) . Fixed bug #53729 (DatePeriod fails to initialize recurrences on 64bit big-endian systems). (Derick, r...@basefarm.no) + . Fixed bug #52738 (Can't use new properties in class extended from + DateInterval). (Stas) . Fixed bug #52063 (DateTime constructor's second argument doesn't have a null default value). (Gustavo, Stas) Modified: php/php-src/branches/PHP_5_3/ext/date/php_date.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/date/php_date.c 2011-01-24 01:15:41 UTC (rev 307688) +++ php/php-src/branches/PHP_5_3/ext/date/php_date.c 2011-01-24 02:31:48 UTC (rev 307689) @@ -1029,7 +1029,7 @@ offset->offset = (t->z) * -60; offset->leap_secs = 0; offset->is_dst = 0; - offset->abbr = malloc(9); /* GMT±xxxx\0 */ + offset->abbr = malloc(9); /* GMT�xxxx\0 */ snprintf(offset->abbr, 9, "GMT%c%02d%02d", localtime ? ((offset->offset < 0) ? '-' : '+') : '+', localtime ? abs(offset->offset / 3600) : 0, @@ -1238,7 +1238,7 @@ offset->offset = (t->z - (t->dst * 60)) * -60; offset->leap_secs = 0; offset->is_dst = t->dst; - offset->abbr = malloc(9); /* GMT±xxxx\0 */ + offset->abbr = malloc(9); /* GMT�xxxx\0 */ snprintf(offset->abbr, 9, "GMT%c%02d%02d", !localtime ? ((offset->offset < 0) ? '-' : '+') : '+', !localtime ? abs(offset->offset / 3600) : 0, @@ -1997,6 +1997,7 @@ date_object_handlers_interval.read_property = date_interval_read_property; date_object_handlers_interval.write_property = date_interval_write_property; date_object_handlers_interval.get_properties = date_object_get_properties_interval; + date_object_handlers_interval.get_property_ptr_ptr = NULL; INIT_CLASS_ENTRY(ce_period, "DatePeriod", date_funcs_period); ce_period.create_object = date_object_new_period; @@ -3487,23 +3488,30 @@ #define GET_VALUE_FROM_STRUCT(n,m) \ if (strcmp(Z_STRVAL_P(member), m) == 0) { \ value = obj->diff->n; \ + break; \ } - GET_VALUE_FROM_STRUCT(y, "y"); - GET_VALUE_FROM_STRUCT(m, "m"); - GET_VALUE_FROM_STRUCT(d, "d"); - GET_VALUE_FROM_STRUCT(h, "h"); - GET_VALUE_FROM_STRUCT(i, "i"); - GET_VALUE_FROM_STRUCT(s, "s"); - GET_VALUE_FROM_STRUCT(invert, "invert"); - GET_VALUE_FROM_STRUCT(days, "days"); + do { + GET_VALUE_FROM_STRUCT(y, "y"); + GET_VALUE_FROM_STRUCT(m, "m"); + GET_VALUE_FROM_STRUCT(d, "d"); + GET_VALUE_FROM_STRUCT(h, "h"); + GET_VALUE_FROM_STRUCT(i, "i"); + GET_VALUE_FROM_STRUCT(s, "s"); + GET_VALUE_FROM_STRUCT(invert, "invert"); + GET_VALUE_FROM_STRUCT(days, "days"); + /* didn't find any */ + retval = (zend_get_std_object_handlers())->read_property(object, member, type TSRMLS_CC); + if (member == &tmp_member) { + zval_dtor(member); + } + + return retval; + } while(0); + ALLOC_INIT_ZVAL(retval); Z_SET_REFCOUNT_P(retval, 0); - if (value == -1) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unknown property (%s)", Z_STRVAL_P(member)); - } - ZVAL_LONG(retval, value); if (member == &tmp_member) { @@ -3537,25 +3545,25 @@ convert_to_long(&tmp_value); \ value = &tmp_value; \ } \ - found = 1; \ - obj->diff->n = Z_LVAL_P(value); \ - if (value == &tmp_value) { \ - zval_dtor(value); \ - } \ + obj->diff->n = Z_LVAL_P(value); \ + if (value == &tmp_value) { \ + zval_dtor(value); \ + } \ + break; \ } - SET_VALUE_FROM_STRUCT(y, "y"); - SET_VALUE_FROM_STRUCT(m, "m"); - SET_VALUE_FROM_STRUCT(d, "d"); - SET_VALUE_FROM_STRUCT(h, "h"); - SET_VALUE_FROM_STRUCT(i, "i"); - SET_VALUE_FROM_STRUCT(s, "s"); - SET_VALUE_FROM_STRUCT(invert, "invert"); + do { + SET_VALUE_FROM_STRUCT(y, "y"); + SET_VALUE_FROM_STRUCT(m, "m"); + SET_VALUE_FROM_STRUCT(d, "d"); + SET_VALUE_FROM_STRUCT(h, "h"); + SET_VALUE_FROM_STRUCT(i, "i"); + SET_VALUE_FROM_STRUCT(s, "s"); + SET_VALUE_FROM_STRUCT(invert, "invert"); + /* didn't find any */ + (zend_get_std_object_handlers())->write_property(object, member, value TSRMLS_CC); + } while(0); - if (!found) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unknown property (%s)", Z_STRVAL_P(member)); - } - if (member == &tmp_member) { zval_dtor(member); } Added: php/php-src/branches/PHP_5_3/ext/date/tests/bug52738.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/date/tests/bug52738.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/date/tests/bug52738.phpt 2011-01-24 02:31:48 UTC (rev 307689) @@ -0,0 +1,32 @@ +--TEST-- +Bug #52738 (Can't use new properties in class extended from DateInterval) +--FILE-- +<?php +class di extends DateInterval { + public $unit = 1; +} + +$I = new di('P10D'); +echo $I->unit."\n"; +$I->unit++; +echo $I->unit."\n"; +$I->unit = 42; +echo $I->unit."\n"; +$I->d++; +print_r($I); +--EXPECT-- +1 +2 +42 +di Object +( + [unit] => 42 + [y] => 0 + [m] => 0 + [d] => 11 + [h] => 0 + [i] => 0 + [s] => 0 + [invert] => 0 + [days] => +) Modified: php/php-src/trunk/ext/date/php_date.c =================================================================== --- php/php-src/trunk/ext/date/php_date.c 2011-01-24 01:15:41 UTC (rev 307688) +++ php/php-src/trunk/ext/date/php_date.c 2011-01-24 02:31:48 UTC (rev 307689) @@ -1029,7 +1029,7 @@ offset->offset = (t->z) * -60; offset->leap_secs = 0; offset->is_dst = 0; - offset->abbr = malloc(9); /* GMT±xxxx\0 */ + offset->abbr = malloc(9); /* GMT�xxxx\0 */ snprintf(offset->abbr, 9, "GMT%c%02d%02d", localtime ? ((offset->offset < 0) ? '-' : '+') : '+', localtime ? abs(offset->offset / 3600) : 0, @@ -1237,7 +1237,7 @@ offset->offset = (t->z - (t->dst * 60)) * -60; offset->leap_secs = 0; offset->is_dst = t->dst; - offset->abbr = malloc(9); /* GMT±xxxx\0 */ + offset->abbr = malloc(9); /* GMT�xxxx\0 */ snprintf(offset->abbr, 9, "GMT%c%02d%02d", !localtime ? ((offset->offset < 0) ? '-' : '+') : '+', !localtime ? abs(offset->offset / 3600) : 0, @@ -1996,6 +1996,7 @@ date_object_handlers_interval.read_property = date_interval_read_property; date_object_handlers_interval.write_property = date_interval_write_property; date_object_handlers_interval.get_properties = date_object_get_properties_interval; + date_object_handlers_interval.get_property_ptr_ptr = NULL; INIT_CLASS_ENTRY(ce_period, "DatePeriod", date_funcs_period); ce_period.create_object = date_object_new_period; @@ -3482,23 +3483,30 @@ #define GET_VALUE_FROM_STRUCT(n,m) \ if (strcmp(Z_STRVAL_P(member), m) == 0) { \ value = obj->diff->n; \ + break; \ } - GET_VALUE_FROM_STRUCT(y, "y"); - GET_VALUE_FROM_STRUCT(m, "m"); - GET_VALUE_FROM_STRUCT(d, "d"); - GET_VALUE_FROM_STRUCT(h, "h"); - GET_VALUE_FROM_STRUCT(i, "i"); - GET_VALUE_FROM_STRUCT(s, "s"); - GET_VALUE_FROM_STRUCT(invert, "invert"); - GET_VALUE_FROM_STRUCT(days, "days"); + do { + GET_VALUE_FROM_STRUCT(y, "y"); + GET_VALUE_FROM_STRUCT(m, "m"); + GET_VALUE_FROM_STRUCT(d, "d"); + GET_VALUE_FROM_STRUCT(h, "h"); + GET_VALUE_FROM_STRUCT(i, "i"); + GET_VALUE_FROM_STRUCT(s, "s"); + GET_VALUE_FROM_STRUCT(invert, "invert"); + GET_VALUE_FROM_STRUCT(days, "days"); + /* didn't find any */ + retval = (zend_get_std_object_handlers())->read_property(object, member, type, key TSRMLS_CC); + if (member == &tmp_member) { + zval_dtor(member); + } + + return retval; + } while(0); + ALLOC_INIT_ZVAL(retval); Z_SET_REFCOUNT_P(retval, 0); - if (value == -1) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unknown property (%s)", Z_STRVAL_P(member)); - } - ZVAL_LONG(retval, value); if (member == &tmp_member) { @@ -3532,25 +3540,25 @@ convert_to_long(&tmp_value); \ value = &tmp_value; \ } \ - found = 1; \ - obj->diff->n = Z_LVAL_P(value); \ - if (value == &tmp_value) { \ - zval_dtor(value); \ - } \ + obj->diff->n = Z_LVAL_P(value); \ + if (value == &tmp_value) { \ + zval_dtor(value); \ + } \ + break; \ } - SET_VALUE_FROM_STRUCT(y, "y"); - SET_VALUE_FROM_STRUCT(m, "m"); - SET_VALUE_FROM_STRUCT(d, "d"); - SET_VALUE_FROM_STRUCT(h, "h"); - SET_VALUE_FROM_STRUCT(i, "i"); - SET_VALUE_FROM_STRUCT(s, "s"); - SET_VALUE_FROM_STRUCT(invert, "invert"); + do { + SET_VALUE_FROM_STRUCT(y, "y"); + SET_VALUE_FROM_STRUCT(m, "m"); + SET_VALUE_FROM_STRUCT(d, "d"); + SET_VALUE_FROM_STRUCT(h, "h"); + SET_VALUE_FROM_STRUCT(i, "i"); + SET_VALUE_FROM_STRUCT(s, "s"); + SET_VALUE_FROM_STRUCT(invert, "invert"); + /* didn't find any */ + (zend_get_std_object_handlers())->write_property(object, member, value, key TSRMLS_CC); + } while(0); - if (!found) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unknown property (%s)", Z_STRVAL_P(member)); - } - if (member == &tmp_member) { zval_dtor(member); } Added: php/php-src/trunk/ext/date/tests/bug52738.phpt =================================================================== --- php/php-src/trunk/ext/date/tests/bug52738.phpt (rev 0) +++ php/php-src/trunk/ext/date/tests/bug52738.phpt 2011-01-24 02:31:48 UTC (rev 307689) @@ -0,0 +1,32 @@ +--TEST-- +Bug #52738 (Can't use new properties in class extended from DateInterval) +--FILE-- +<?php +class di extends DateInterval { + public $unit = 1; +} + +$I = new di('P10D'); +echo $I->unit."\n"; +$I->unit++; +echo $I->unit."\n"; +$I->unit = 42; +echo $I->unit."\n"; +$I->d++; +print_r($I); +--EXPECT-- +1 +2 +42 +di Object +( + [unit] => 42 + [y] => 0 + [m] => 0 + [d] => 11 + [h] => 0 + [i] => 0 + [s] => 0 + [invert] => 0 + [days] => +)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php