Skip to content

Commit

Permalink
Fix session + Serializable tests
Browse files Browse the repository at this point in the history
These were broken when the deprecation warning was added, as the
extra output prevented the session from being started.
  • Loading branch information
nikic committed Jul 30, 2021
1 parent 9ee9393 commit 1852121
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
21 changes: 8 additions & 13 deletions ext/session/tests/bug79031.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Bug #79031: Session unserialization problem
--EXTENSIONS--
session
--INI--
error_reporting=E_ALL&~E_DEPRECATED
--FILE--
<?php

Expand Down Expand Up @@ -50,29 +52,22 @@ echo "\n\n";
var_dump($_SESSION);

?>
--EXPECTF--
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d

Warning: session_start(): Session cannot be started after headers have already been sent in %s on line %d

Warning: session_encode(): Cannot encode non-existent session in %s on line %d

Warning: session_decode(): Session data cannot be decoded when there is no active session in %s on line %d

--EXPECT--
obj1|C:17:"SerializableClass":65:{a:1:{s:10:"sharedProp";O:8:"stdClass":1:{s:4:"name";s:4:"test";}}}obj2|C:17:"SerializableClass":28:{a:1:{s:10:"sharedProp";r:3;}}

array(2) {
["obj1"]=>
object(SerializableClass)#2 (1) {
object(SerializableClass)#4 (1) {
["sharedProp"]=>
object(stdClass)#1 (1) {
object(stdClass)#5 (1) {
["name"]=>
string(4) "test"
}
}
["obj2"]=>
object(SerializableClass)#3 (1) {
object(SerializableClass)#6 (1) {
["sharedProp"]=>
object(stdClass)#1 (1) {
object(stdClass)#5 (1) {
["name"]=>
string(4) "test"
}
Expand Down
8 changes: 3 additions & 5 deletions ext/standard/tests/serialize/bug70219.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Bug #70219 Use after free vulnerability in session deserializer
--EXTENSIONS--
session
--INI--
error_reporting=E_ALL&~E_DEPRECATED
--FILE--
<?php
class obj implements Serializable {
Expand All @@ -27,11 +29,7 @@ for ($i = 0; $i < 5; $i++) {
var_dump($data);
?>
--EXPECTF--
Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d

Warning: session_start(): Session cannot be started after headers have already been sent in %s on line %d

Warning: session_decode(): Session data cannot be decoded when there is no active session in %s on line %d
Warning: session_decode(): Failed to decode session object. Session has been destroyed in %s on line %d

Notice: unserialize(): Error at offset 55 of 56 bytes in %s on line %d
bool(false)

0 comments on commit 1852121

Please sign in to comment.