xref: /PHP-8.0/ext/date/tests/bug62852_var2.phpt (revision 7aacc705)
1--TEST--
2Bug #62852 (Unserialize invalid DateTime causes crash), variation 2
3--INI--
4date.timezone=GMT
5--FILE--
6<?php
7$s2 = 'O:3:"Foo":3:{s:4:"date";s:20:"10007-06-07 03:51:49";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}';
8
9global $foo;
10
11class Foo extends DateTime {
12    function __wakeup() {
13        global $foo;
14        $foo = $this;
15        parent::__wakeup();
16    }
17}
18
19try {
20    unserialize( $s2 );
21} catch ( Exception $e ) {}
22var_dump( $foo );
23?>
24--EXPECTF--
25Fatal error: Uncaught Error: Invalid serialization data for DateTime object in %sbug62852_var2.php:%d
26Stack trace:
27#0 %sbug62852_var2.php(%d): DateTime->__wakeup()
28#1 [internal function]: Foo->__wakeup()
29#2 %sbug62852_var2.php(%d): unserialize('O:3:"Foo":3:{s:...')
30#3 {main}
31  thrown in %sbug62852_var2.php on line %d
32