Skip to content

Commit

Permalink
Fixed bug #77498
Browse files Browse the repository at this point in the history
I've renamed the function to the same name as the exported symbol
in master.
  • Loading branch information
nikic committed Jan 25, 2019
1 parent 3c98c2d commit f78e681
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ PHP NEWS
- Core:
. Fixed bug #77494 (Disabling class causes segfault on member access).
(Dmitry)
. Fixed bug #77498 (Custom extension Segmentation fault when declare static
property). (Nikita)

- Mbstring:
. Fixed bug #77514 (mb_ereg_replace() with trailing backslash adds null byte).
Expand Down
18 changes: 18 additions & 0 deletions Zend/tests/inherit_internal_static.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Inherit internal static property into userland class
--SKIPIF--
<?php if (!extension_loaded('zend-test')) die('skip requires zend-test'); ?>
--FILE--
<?php

class Test extends _ZendTestClass {
}

var_dump(Test::$_StaticProp);
_ZendTestClass::$_StaticProp = 42;
var_dump(Test::$_StaticProp);

?>
--EXPECT--
NULL
int(42)
3 changes: 3 additions & 0 deletions Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,9 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
}
if (UNEXPECTED(parent_ce->type != ce->type)) {
/* User class extends internal */
if (CE_STATIC_MEMBERS(parent_ce) == NULL) {
zend_class_init_statics(parent_ce);
}
if (UNEXPECTED(zend_update_class_constants(parent_ce) != SUCCESS)) {
ZEND_ASSERT(0);
}
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,14 +1374,14 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
}
/* }}} */

static void zend_intenal_class_init_statics(zend_class_entry *class_type) /* {{{ */
ZEND_API void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */
{
int i;
zval *p;

if (!CE_STATIC_MEMBERS(class_type) && class_type->default_static_members_count) {
if (class_type->parent) {
zend_intenal_class_init_statics(class_type->parent);
zend_class_init_statics(class_type->parent);
}

#if ZTS
Expand Down Expand Up @@ -1431,7 +1431,7 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p
/* check if static properties were destoyed */
if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
if (ce->type == ZEND_INTERNAL_CLASS) {
zend_intenal_class_init_statics(ce);
zend_class_init_statics(ce);
} else {
undeclared_property:
if (!silent) {
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_object_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ extern const ZEND_API zend_object_handlers std_object_handlers;
#define ZEND_PROPERTY_NOT_EMPTY ZEND_ISEMPTY /* Property is not empty */
#define ZEND_PROPERTY_EXISTS 0x2 /* Property exists */

ZEND_API void zend_class_init_statics(zend_class_entry *ce);
ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key);
ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, zend_bool silent);
ZEND_API ZEND_COLD zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name);
Expand Down

0 comments on commit f78e681

Please sign in to comment.