Skip to content

Commit f78e681

Browse files
committed
Fixed bug #77498
I've renamed the function to the same name as the exported symbol in master.
1 parent 3c98c2d commit f78e681

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- Core:
66
. Fixed bug #77494 (Disabling class causes segfault on member access).
77
(Dmitry)
8+
. Fixed bug #77498 (Custom extension Segmentation fault when declare static
9+
property). (Nikita)
810

911
- Mbstring:
1012
. Fixed bug #77514 (mb_ereg_replace() with trailing backslash adds null byte).
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Inherit internal static property into userland class
3+
--SKIPIF--
4+
<?php if (!extension_loaded('zend-test')) die('skip requires zend-test'); ?>
5+
--FILE--
6+
<?php
7+
8+
class Test extends _ZendTestClass {
9+
}
10+
11+
var_dump(Test::$_StaticProp);
12+
_ZendTestClass::$_StaticProp = 42;
13+
var_dump(Test::$_StaticProp);
14+
15+
?>
16+
--EXPECT--
17+
NULL
18+
int(42)

Zend/zend_inheritance.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,9 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
894894
}
895895
if (UNEXPECTED(parent_ce->type != ce->type)) {
896896
/* User class extends internal */
897+
if (CE_STATIC_MEMBERS(parent_ce) == NULL) {
898+
zend_class_init_statics(parent_ce);
899+
}
897900
if (UNEXPECTED(zend_update_class_constants(parent_ce) != SUCCESS)) {
898901
ZEND_ASSERT(0);
899902
}

Zend/zend_object_handlers.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,14 +1374,14 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
13741374
}
13751375
/* }}} */
13761376

1377-
static void zend_intenal_class_init_statics(zend_class_entry *class_type) /* {{{ */
1377+
ZEND_API void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */
13781378
{
13791379
int i;
13801380
zval *p;
13811381

13821382
if (!CE_STATIC_MEMBERS(class_type) && class_type->default_static_members_count) {
13831383
if (class_type->parent) {
1384-
zend_intenal_class_init_statics(class_type->parent);
1384+
zend_class_init_statics(class_type->parent);
13851385
}
13861386

13871387
#if ZTS
@@ -1431,7 +1431,7 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p
14311431
/* check if static properties were destoyed */
14321432
if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
14331433
if (ce->type == ZEND_INTERNAL_CLASS) {
1434-
zend_intenal_class_init_statics(ce);
1434+
zend_class_init_statics(ce);
14351435
} else {
14361436
undeclared_property:
14371437
if (!silent) {

Zend/zend_object_handlers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ extern const ZEND_API zend_object_handlers std_object_handlers;
175175
#define ZEND_PROPERTY_NOT_EMPTY ZEND_ISEMPTY /* Property is not empty */
176176
#define ZEND_PROPERTY_EXISTS 0x2 /* Property exists */
177177

178+
ZEND_API void zend_class_init_statics(zend_class_entry *ce);
178179
ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key);
179180
ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, zend_bool silent);
180181
ZEND_API ZEND_COLD zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name);

0 commit comments

Comments
 (0)