1
0
mirror of https://github.com/rlanvin/php-rrule.git synced 2025-02-20 09:54:16 +01:00

Always cloning Datetime passed to parseDate to avoid any reference bug

This commit is contained in:
rlanvin 2016-03-24 09:27:25 +02:00
parent 3a84bcc6be
commit b527621fa5
2 changed files with 14 additions and 0 deletions

View File

@ -1032,6 +1032,9 @@ class RRule implements RRuleInterface
);
}
}
else {
$date = clone $date; // avoid reference problems
}
return $date;
}

View File

@ -1876,6 +1876,17 @@ class RRuleTest extends PHPUnit_Framework_TestCase
public function testDateTimeMutableReferenceBug()
{
$date = date_create('2007-01-01');
$rrule = new RRule(array(
'freq' => 'daily',
'count' => 10,
'dtstart' => $date
));
$this->assertEquals(date_create('2007-01-01'), $rrule[0]);
$date->modify('+1day');
$rrule->clearCache();
$this->assertEquals(date_create('2007-01-01'), $rrule[0], 'No modification possible of dtstart');
$rrule = new RRule(array(
'freq' => 'daily',
'count' => 10,