@@ -5310,12 +5310,35 @@ PHP_METHOD(DatePeriod, __wakeup)
5310
5310
}
5311
5311
/* }}} */
5312
5312
5313
+ /* {{{ date_period_is_magic_property
5314
+ * Common for date_period_read_property() and date_period_write_property() functions
5315
+ */
5316
+ static int date_period_is_magic_property (zend_string * name )
5317
+ {
5318
+ if (zend_string_equals_literal (name , "recurrences" )
5319
+ || zend_string_equals_literal (name , "include_start_date" )
5320
+ || zend_string_equals_literal (name , "start" )
5321
+ || zend_string_equals_literal (name , "current" )
5322
+ || zend_string_equals_literal (name , "end" )
5323
+ || zend_string_equals_literal (name , "interval" )
5324
+ ) {
5325
+ return 1 ;
5326
+ }
5327
+ return 0 ;
5328
+ }
5329
+ /* }}} */
5330
+
5313
5331
/* {{{ date_period_read_property */
5314
5332
static zval * date_period_read_property (zval * object , zval * member , int type , void * * cache_slot , zval * rv )
5315
5333
{
5316
5334
if (type != BP_VAR_IS && type != BP_VAR_R ) {
5317
- zend_throw_error (NULL , "Retrieval of DatePeriod properties for modification is unsupported" );
5318
- return & EG (uninitialized_zval );
5335
+ zend_string * name = zval_get_string (member );
5336
+ if (date_period_is_magic_property (name )) {
5337
+ zend_throw_error (NULL , "Retrieval of DatePeriod->%s for modification is unsupported" , ZSTR_VAL (name ));
5338
+ zend_string_release (name );
5339
+ return & EG (uninitialized_zval );
5340
+ }
5341
+ zend_string_release (name );
5319
5342
}
5320
5343
5321
5344
Z_OBJPROP_P (object ); /* build properties hash table */
@@ -5327,7 +5350,15 @@ static zval *date_period_read_property(zval *object, zval *member, int type, voi
5327
5350
/* {{{ date_period_write_property */
5328
5351
static void date_period_write_property (zval * object , zval * member , zval * value , void * * cache_slot )
5329
5352
{
5330
- zend_throw_error (NULL , "Writing to DatePeriod properties is unsupported" );
5353
+ zend_string * name = zval_get_string (member );
5354
+ if (date_period_is_magic_property (name )) {
5355
+ zend_throw_error (NULL , "Writing to DatePeriod->%s is unsupported" , ZSTR_VAL (name ));
5356
+ zend_string_release (name );
5357
+ return ;
5358
+ }
5359
+ zend_string_release (name );
5360
+
5361
+ std_object_handlers .write_property (object , member , value , cache_slot );
5331
5362
}
5332
5363
/* }}} */
5333
5364
0 commit comments