Skip to content

Bug 65672 #451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -5024,7 +5024,24 @@ static zval *date_period_read_property(zval *object, zval *member, int type, con
/* {{{ 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");
zval **hnd;
zend_object_handlers *std_hnd;
int ret = FAILURE;
HashTable *properties;

if (member->type != IS_STRING) {
return;
}

properties = date_object_get_properties_period(object);
ret = zend_hash_find((HashTable *)properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &hnd);

if (ret == SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot write to read-only property");
} else {
std_hnd = zend_get_std_object_handlers();
std_hnd->write_property(object, member, value, key TSRMLS_CC);
}
}
/* }}} */

Expand Down
29 changes: 29 additions & 0 deletions ext/date/tests/bug65672.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--TEST--
Test for bug #65672: Broken classes inherited from DatePeriod
--CREDITS--
Boro Sitnikovski <buritomath@yahoo.com>
--INI--
date.timezone = UTC
--FILE--
<?php
class Period extends DatePeriod {
public $test;
}

$p = new Period(new DateTime('now'), new DateInterval('P1Y'), new DateTime('tomorrow'));

$old_recurrence = $p->recurrences;
$old_test = $p->test;

$p->recurrences = $old_recurrence + 3;
$p->test = 123;

var_dump($p->recurrences == $old_recurrence);
var_dump($p->test != $old_test);
var_dump($p->test == 123);

?>
--EXPECT--
bool(true)
bool(true)
bool(true)