Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Bug GH-11416: Crash with DatePeriod when uninitialised objects are passed in --IN..

Decoded Output download

--TEST--
Bug GH-11416: Crash with DatePeriod when uninitialised objects are passed in
--INI--
date.timezone=UTC
--FILE--
<?php
$now = new DateTimeImmutable();

$date = (new ReflectionClass(DateTime::class))->newInstanceWithoutConstructor();
try {
	new DatePeriod($date, new DateInterval('P1D'), 2);
} catch (Error $e) {
	echo get_class($e), ': ', $e->getMessage(), "
";
}

$date = (new ReflectionClass(DateTime::class))->newInstanceWithoutConstructor();
try {
	new DatePeriod($now, new DateInterval('P1D'), $date);
} catch (Error $e) {
	echo get_class($e), ': ', $e->getMessage(), "
";
}

echo "OK
";
?>
--EXPECT--
Error: The DateTimeInterface object has not been correctly initialized by its constructor
Error: The DateTimeInterface object has not been correctly initialized by its constructor
OK

Did this file decode correctly?

Original Code

--TEST--
Bug GH-11416: Crash with DatePeriod when uninitialised objects are passed in
--INI--
date.timezone=UTC
--FILE--
<?php
$now = new DateTimeImmutable();

$date = (new ReflectionClass(DateTime::class))->newInstanceWithoutConstructor();
try {
	new DatePeriod($date, new DateInterval('P1D'), 2);
} catch (Error $e) {
	echo get_class($e), ': ', $e->getMessage(), "\n";
}

$date = (new ReflectionClass(DateTime::class))->newInstanceWithoutConstructor();
try {
	new DatePeriod($now, new DateInterval('P1D'), $date);
} catch (Error $e) {
	echo get_class($e), ': ', $e->getMessage(), "\n";
}

echo "OK\n";
?>
--EXPECT--
Error: The DateTimeInterface object has not been correctly initialized by its constructor
Error: The DateTimeInterface object has not been correctly initialized by its constructor
OK

Function Calls

None

Variables

None

Stats

MD5 ecf9bfc51210d0961946590767256aa0
Eval Count 0
Decode Time 85 ms