Skip to content

Commit c5caa05

Browse files
committed
Fixed bug #79740
1 parent 5435a4a commit c5caa05

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #79030 (Upgrade apache2handler's php_apache_sapi_get_request_time
77
to return usec). (Herbert256)
88

9+
- Core:
10+
. Fixed bug #79740 (serialize() and unserialize() methods can not be called
11+
statically). (Nikita)
12+
913
- FTP:
1014
. Fixed bug #55857 (ftp_size on large files). (cmb)
1115

Zend/tests/bug79740.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #79740: serialize() and unserialize() methods can not be called statically
3+
--FILE--
4+
<?php
5+
class A {
6+
public function serialize() { }
7+
public function unserialize() { }
8+
}
9+
10+
var_dump(is_callable(['A', 'serialize']));
11+
var_dump(is_callable(['A', 'unserialize']));
12+
A::serialize();
13+
A::unserialize();
14+
15+
?>
16+
--EXPECTF--
17+
bool(true)
18+
bool(true)
19+
20+
Deprecated: Non-static method A::serialize() should not be called statically in %s on line %d
21+
22+
Deprecated: Non-static method A::unserialize() should not be called statically in %s on line %d

Zend/zend_compile.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5813,8 +5813,14 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo
58135813
}
58145814
} else if (zend_string_equals_literal(lcname, "serialize")) {
58155815
ce->serialize_func = (zend_function *) op_array;
5816+
if (!is_static) {
5817+
op_array->fn_flags |= ZEND_ACC_ALLOW_STATIC;
5818+
}
58165819
} else if (zend_string_equals_literal(lcname, "unserialize")) {
58175820
ce->unserialize_func = (zend_function *) op_array;
5821+
if (!is_static) {
5822+
op_array->fn_flags |= ZEND_ACC_ALLOW_STATIC;
5823+
}
58185824
} else if (ZSTR_VAL(lcname)[0] != '_' || ZSTR_VAL(lcname)[1] != '_') {
58195825
if (!is_static) {
58205826
op_array->fn_flags |= ZEND_ACC_ALLOW_STATIC;

0 commit comments

Comments
 (0)