1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

Check __set_state structure

Fix Bug #79521.

Closes GH-5462.
This commit is contained in:
Gabriel Caruso
2020-04-26 04:31:47 +02:00
parent f545ee2c6c
commit 34c460f329
4 changed files with 20 additions and 3 deletions

1
NEWS
View File

@@ -23,6 +23,7 @@ PHP NEWS
. Fixed bug #36365 (scandir duplicates file name at every 65535th file).
(cmb)
. Use SSE2 instructions do locale independent strtolower. (Laruence)
. Fixed bug #79521 (Check __set_state structure). (carusogabriel)
- BZ2:
. Fixed bug #71263 (fread() does not report bzip2.decompress errors). (cmb)

View File

@@ -0,0 +1,14 @@
--TEST--
Testing __set_state() declaration with wrong modifier
--FILE--
<?php
class Foo {
function __set_state()
{
}
}
?>
--EXPECTF--
Warning: The magic method Foo::__set_state() must be static in %s on line %d

View File

@@ -6170,6 +6170,8 @@ zend_string *zend_begin_method_decl(zend_op_array *op_array, zend_string *name,
zend_check_magic_method_attr(fn_flags, ce, "__serialize", 0);
} else if (zend_string_equals_literal(lcname, "__unserialize")) {
zend_check_magic_method_attr(fn_flags, ce, "__unserialize", 0);
} else if (zend_string_equals_literal(lcname, "__set_state")) {
zend_check_magic_method_attr(fn_flags, ce, "__set_state", 1);
}
return lcname;

View File

@@ -52,7 +52,7 @@ class TestClass
public function __wakeup() {}
public function __set_state() {}
public static function __set_state() {}
public function __autoload() {}
}
@@ -143,7 +143,7 @@ Modifiers for method TestClass::__wakeup():
Modifiers for method TestClass::__set_state():
0x00000001
0x00000011
Modifiers for method TestClass::__autoload():
@@ -207,7 +207,7 @@ Modifiers for method TestClass::__wakeup():
Modifiers for method TestClass::__set_state():
0x00000001
0x00000011
Modifiers for method TestClass::__autoload():