From cc3f18b76507c5b3268362977bfd25e10dc2b730 Mon Sep 17 00:00:00 2001 From: Dreamszhu Date: Sat, 19 Oct 2019 18:04:36 +0800 Subject: [PATCH 1/2] Re fix #1961 --- ext/config.m4 | 1 + ext/config.w32 | 2 +- ext/kernel/main.c | 8 ++- ext/test.c | 2 + ext/test.h | 1 + ext/test/globals/server.zep.c | 82 +++++++++++++++++++++++++ ext/test/globals/server.zep.h | 37 +++++++++++ ext/test/oo/oodestruct.zep.c | 32 +++++----- ext/test/optimizers/strreplace.zep.c | 2 +- ext/test/properties/propertyarray.zep.c | 6 +- ext/test/quantum.zep.c | 4 +- ext/test/range.zep.c | 4 +- ext/test/regexdna.zep.c | 4 +- ext/test/requires.zep.c | 2 +- ext/test/requires/external3.zep.c | 4 +- ext/test/resourcetest.zep.c | 2 +- ext/test/router.zep.c | 6 +- ext/test/scall.zep.c | 8 +-- ext/test/scope.zep.c | 4 +- ext/test/sort.zep.c | 6 +- ext/test/spectralnorm.zep.c | 32 +++++----- ext/test/strings.zep.c | 8 +-- ext/test/trytest.zep.c | 12 ++-- kernels/ZendEngine3/main.c | 8 ++- test/globals/server.zep | 21 +++++++ 25 files changed, 226 insertions(+), 72 deletions(-) create mode 100644 ext/test/globals/server.zep.c create mode 100644 ext/test/globals/server.zep.h create mode 100644 test/globals/server.zep diff --git a/ext/config.m4 b/ext/config.m4 index bccd6f23a9..8075ac8ce2 100644 --- a/ext/config.m4 +++ b/ext/config.m4 @@ -73,6 +73,7 @@ if test "$PHP_TEST" = "yes"; then test/globals.zep.c test/globals/env.zep.c test/globals/post.zep.c + test/globals/server.zep.c test/globals/serverrequestfactory.zep.c test/globals/session/child.zep.c test/instance.zep.c diff --git a/ext/config.w32 b/ext/config.w32 index 34662a7f19..b37269ec67 100644 --- a/ext/config.w32 +++ b/ext/config.w32 @@ -22,7 +22,7 @@ if (PHP_TEST != "no") { ADD_SOURCES(configure_module_dirname + "/test/bench", "foo.zep.c", "test"); ADD_SOURCES(configure_module_dirname + "/test/builtin", "arraymethods.zep.c charmethods.zep.c intmethods.zep.c stringmethods.zep.c", "test"); ADD_SOURCES(configure_module_dirname + "/test/flow", "switchflow.zep.c", "test"); - ADD_SOURCES(configure_module_dirname + "/test/globals", "env.zep.c post.zep.c serverrequestfactory.zep.c", "test"); + ADD_SOURCES(configure_module_dirname + "/test/globals", "env.zep.c post.zep.c server.zep.c serverrequestfactory.zep.c", "test"); ADD_SOURCES(configure_module_dirname + "/test/integration/psr/http/message", "messageinterfaceex.zep.c", "test"); ADD_SOURCES(configure_module_dirname + "/test/mcall", "caller.zep.c", "test"); ADD_SOURCES(configure_module_dirname + "/test/oo/extend/db/query/placeholder", "exception.zep.c", "test"); diff --git a/ext/kernel/main.c b/ext/kernel/main.c index 8c27575fa2..c689b71aa1 100644 --- a/ext/kernel/main.c +++ b/ext/kernel/main.c @@ -100,8 +100,12 @@ int zephir_get_global(zval *arr, const char *global, unsigned int global_length) if ((gv = zend_hash_find_ind(&EG(symbol_table), str)) != NULL) { ZVAL_DEREF(gv); if (Z_TYPE_P(gv) == IS_ARRAY) { - ZVAL_DUP(arr, gv); - zend_hash_update(&EG(symbol_table), str, arr); + if (Z_REFCOUNTED_P(gv)) { + ZVAL_COPY_VALUE(arr, gv); + } else { + ZVAL_DUP(arr, gv); + zend_hash_update(&EG(symbol_table), str, arr); + } // See: https://github.com/phalcon/zephir/pull/1965#issuecomment-541299003 // ZVAL_COPY_VALUE(arr, gv); diff --git a/ext/test.c b/ext/test.c index 5a19bdb057..5637bd4717 100644 --- a/ext/test.c +++ b/ext/test.c @@ -102,6 +102,7 @@ zend_class_entry *test_geometry_ce; zend_class_entry *test_globals_ce; zend_class_entry *test_globals_env_ce; zend_class_entry *test_globals_post_ce; +zend_class_entry *test_globals_server_ce; zend_class_entry *test_globals_serverrequestfactory_ce; zend_class_entry *test_globals_session_child_ce; zend_class_entry *test_instance_ce; @@ -296,6 +297,7 @@ static PHP_MINIT_FUNCTION(test) ZEPHIR_INIT(Test_Globals); ZEPHIR_INIT(Test_Globals_Env); ZEPHIR_INIT(Test_Globals_Post); + ZEPHIR_INIT(Test_Globals_Server); ZEPHIR_INIT(Test_Globals_ServerRequestFactory); ZEPHIR_INIT(Test_Globals_Session_Child); ZEPHIR_INIT(Test_Instance); diff --git a/ext/test.h b/ext/test.h index abe6d9ca50..c624dc9fc3 100644 --- a/ext/test.h +++ b/ext/test.h @@ -68,6 +68,7 @@ #include "test/globals.zep.h" #include "test/globals/env.zep.h" #include "test/globals/post.zep.h" +#include "test/globals/server.zep.h" #include "test/globals/serverrequestfactory.zep.h" #include "test/globals/session/child.zep.h" #include "test/instance.zep.h" diff --git a/ext/test/globals/server.zep.c b/ext/test/globals/server.zep.c new file mode 100644 index 0000000000..f764fa296e --- /dev/null +++ b/ext/test/globals/server.zep.c @@ -0,0 +1,82 @@ + +#ifdef HAVE_CONFIG_H +#include "../../ext_config.h" +#endif + +#include +#include "../../php_ext.h" +#include "../../ext.h" + +#include +#include +#include + +#include "kernel/main.h" +#include "kernel/array.h" +#include "kernel/fcall.h" +#include "kernel/object.h" +#include "kernel/memory.h" + + +ZEPHIR_INIT_CLASS(Test_Globals_Server) { + + ZEPHIR_REGISTER_CLASS(Test\\Globals, Server, test, globals_server, test_globals_server_method_entry, 0); + + return SUCCESS; + +} + +PHP_METHOD(Test_Globals_Server, f1) { + + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval _SERVER, _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_SERVER); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + + ZEPHIR_MM_GROW(); + zephir_get_global(&_SERVER, SL("_SERVER")); + + zephir_array_fetch_string(&_0, &_SERVER, SL("PHP_SELF"), PH_NOISY | PH_READONLY, "test/globals/server.zep", 8); + zend_print_zval(&_0, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "f2", NULL, 0); + zephir_check_call_status(); + zephir_array_fetch_string(&_1, &_SERVER, SL("PHP_SELF"), PH_NOISY | PH_READONLY, "test/globals/server.zep", 10); + zend_print_zval(&_1, 0); + ZEPHIR_MM_RESTORE(); + +} + +PHP_METHOD(Test_Globals_Server, f2) { + + zval _SERVER, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_SERVER); + ZVAL_UNDEF(&_0); + + zephir_get_global(&_SERVER, SL("_SERVER")); + + zephir_array_fetch_string(&_0, &_SERVER, SL("SCRIPT_NAME"), PH_NOISY | PH_READONLY, "test/globals/server.zep", 15); + zend_print_zval(&_0, 0); + +} + +PHP_METHOD(Test_Globals_Server, check) { + + zval _SERVER, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_SERVER); + ZVAL_UNDEF(&_0); + + zephir_get_global(&_SERVER, SL("_SERVER")); + + zephir_array_fetch_string(&_0, &_SERVER, SL("HTTP_USER_AGENT"), PH_NOISY | PH_READONLY, "test/globals/server.zep", 19); + RETURN_CTORW(&_0); + +} + diff --git a/ext/test/globals/server.zep.h b/ext/test/globals/server.zep.h new file mode 100644 index 0000000000..e94484513b --- /dev/null +++ b/ext/test/globals/server.zep.h @@ -0,0 +1,37 @@ + +extern zend_class_entry *test_globals_server_ce; + +ZEPHIR_INIT_CLASS(Test_Globals_Server); + +PHP_METHOD(Test_Globals_Server, f1); +PHP_METHOD(Test_Globals_Server, f2); +PHP_METHOD(Test_Globals_Server, check); + +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_server_f1, 0, 0, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_server_f1, 0, 0, IS_VOID, NULL, 0) +#endif +ZEND_END_ARG_INFO() +#else +#define arginfo_test_globals_server_f1 NULL +#endif + +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_server_f2, 0, 0, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_server_f2, 0, 0, IS_VOID, NULL, 0) +#endif +ZEND_END_ARG_INFO() +#else +#define arginfo_test_globals_server_f2 NULL +#endif + +ZEPHIR_INIT_FUNCS(test_globals_server_method_entry) { + PHP_ME(Test_Globals_Server, f1, arginfo_test_globals_server_f1, ZEND_ACC_PUBLIC) + PHP_ME(Test_Globals_Server, f2, arginfo_test_globals_server_f2, ZEND_ACC_PUBLIC) + PHP_ME(Test_Globals_Server, check, NULL, ZEND_ACC_PUBLIC) + PHP_FE_END +}; diff --git a/ext/test/oo/oodestruct.zep.c b/ext/test/oo/oodestruct.zep.c index a50a44d30d..ff5abf8884 100644 --- a/ext/test/oo/oodestruct.zep.c +++ b/ext/test/oo/oodestruct.zep.c @@ -160,9 +160,8 @@ PHP_METHOD(Test_Oo_OoDestruct, __construct) { zend_bool _30$$13; zend_class_entry *_26$$11 = NULL, *_22$$12 = NULL, *_32$$14 = NULL; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_29 = NULL; zend_long width, height, ZEPHIR_LAST_CALL_STATUS; - zval *file_param = NULL, *width_param = NULL, *height_param = NULL, __$true, imageinfo, _0, _1, _2$$4, _3$$4, _4$$4, _9$$4, _28$$4, _5$$5, _6$$5, _7$$5, _8$$5, _10$$6, _11$$6, _12$$7, _13$$7, _14$$8, _15$$8, _16$$9, _17$$9, _18$$10, _19$$10, _20$$11, _25$$11, _27$$11, _21$$12, _23$$12, _24$$12, _35$$13, _36$$13, _37$$13, _38$$13, _39$$13, _40$$13, _31$$14, _33$$14, _34$$14; + zval *file_param = NULL, *width_param = NULL, *height_param = NULL, __$true, imageinfo, _0, _1, _2$$4, _3$$4, _4$$4, _9$$4, _28$$4, _29$$4, _5$$5, _6$$5, _7$$5, _8$$5, _10$$6, _11$$6, _12$$7, _13$$7, _14$$8, _15$$8, _16$$9, _17$$9, _18$$10, _19$$10, _20$$11, _25$$11, _27$$11, _21$$12, _23$$12, _24$$12, _35$$13, _36$$13, _37$$13, _38$$13, _39$$13, _40$$13, _31$$14, _33$$14, _34$$14; zval file; zval *this_ptr = getThis(); @@ -176,6 +175,7 @@ PHP_METHOD(Test_Oo_OoDestruct, __construct) { ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&_9$$4); ZVAL_UNDEF(&_28$$4); + ZVAL_UNDEF(&_29$$4); ZVAL_UNDEF(&_5$$5); ZVAL_UNDEF(&_6$$5); ZVAL_UNDEF(&_7$$5); @@ -260,35 +260,35 @@ PHP_METHOD(Test_Oo_OoDestruct, __construct) { do { if (ZEPHIR_IS_LONG(&_9$$4, 1)) { zephir_read_property(&_10$$6, this_ptr, SL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_11$$6, "imagecreatefromgif", NULL, 60, &_10$$6); + ZEPHIR_CALL_FUNCTION(&_11$$6, "imagecreatefromgif", NULL, 0, &_10$$6); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("image"), &_11$$6); break; } if (ZEPHIR_IS_LONG(&_9$$4, 2)) { zephir_read_property(&_12$$7, this_ptr, SL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_13$$7, "imagecreatefromjpeg", NULL, 61, &_12$$7); + ZEPHIR_CALL_FUNCTION(&_13$$7, "imagecreatefromjpeg", NULL, 0, &_12$$7); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("image"), &_13$$7); break; } if (ZEPHIR_IS_LONG(&_9$$4, 3)) { zephir_read_property(&_14$$8, this_ptr, SL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_15$$8, "imagecreatefrompng", NULL, 62, &_14$$8); + ZEPHIR_CALL_FUNCTION(&_15$$8, "imagecreatefrompng", NULL, 0, &_14$$8); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("image"), &_15$$8); break; } if (ZEPHIR_IS_LONG(&_9$$4, 15)) { zephir_read_property(&_16$$9, this_ptr, SL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_17$$9, "imagecreatefromwbmp", NULL, 63, &_16$$9); + ZEPHIR_CALL_FUNCTION(&_17$$9, "imagecreatefromwbmp", NULL, 0, &_16$$9); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("image"), &_17$$9); break; } if (ZEPHIR_IS_LONG(&_9$$4, 16)) { zephir_read_property(&_18$$10, this_ptr, SL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_19$$10, "imagecreatefromxbm", NULL, 64, &_18$$10); + ZEPHIR_CALL_FUNCTION(&_19$$10, "imagecreatefromxbm", NULL, 0, &_18$$10); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("image"), &_19$$10); break; @@ -328,7 +328,8 @@ PHP_METHOD(Test_Oo_OoDestruct, __construct) { } while(0); zephir_read_property(&_28$$4, this_ptr, SL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", &_29, 65, &_28$$4, &__$true); + ZVAL_BOOL(&_29$$4, 1); + ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 0, &_28$$4, &_29$$4); zephir_check_call_status(); } else { _30$$13 = !width; @@ -354,14 +355,15 @@ PHP_METHOD(Test_Oo_OoDestruct, __construct) { } ZVAL_LONG(&_35$$13, width); ZVAL_LONG(&_36$$13, height); - ZEPHIR_CALL_FUNCTION(&_37$$13, "imagecreatetruecolor", NULL, 66, &_35$$13, &_36$$13); + ZEPHIR_CALL_FUNCTION(&_37$$13, "imagecreatetruecolor", NULL, 0, &_35$$13, &_36$$13); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("image"), &_37$$13); zephir_read_property(&_35$$13, this_ptr, SL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 67, &_35$$13, &__$true); + ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 60, &_35$$13, &__$true); zephir_check_call_status(); zephir_read_property(&_36$$13, this_ptr, SL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", &_29, 65, &_36$$13, &__$true); + ZVAL_BOOL(&_38$$13, 1); + ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 0, &_36$$13, &_38$$13); zephir_check_call_status(); zephir_read_property(&_38$$13, this_ptr, SL("file"), PH_NOISY_CC | PH_READONLY); zephir_update_property_zval(this_ptr, SL("realpath"), &_38$$13); @@ -398,7 +400,7 @@ PHP_METHOD(Test_Oo_OoDestruct, __destruct) { zephir_read_property(&_0, this_ptr, SL("image"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CPY_WRT(&image, &_0); if (Z_TYPE_P(&image) == IS_RESOURCE) { - ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 68, &image); + ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 0, &image); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); @@ -453,7 +455,7 @@ PHP_METHOD(Test_Oo_OoDestruct, check) { ZVAL_STRING(&_4, "2.0.1"); ZEPHIR_INIT_VAR(&_5); ZVAL_STRING(&_5, ">="); - ZEPHIR_CALL_FUNCTION(&_6, "version_compare", NULL, 69, &version, &_4, &_5); + ZEPHIR_CALL_FUNCTION(&_6, "version_compare", NULL, 61, &version, &_4, &_5); zephir_check_call_status(); if (UNEXPECTED(!zephir_is_true(&_6))) { ZEPHIR_INIT_VAR(&_7$$5); @@ -519,13 +521,13 @@ PHP_METHOD(Test_Oo_OoDestruct, getVersion) { ZVAL_NULL(&version); ZEPHIR_INIT_VAR(&_3); ZVAL_STRING(&_3, "GD_VERSION"); - ZEPHIR_CALL_FUNCTION(&_4, "defined", NULL, 70, &_3); + ZEPHIR_CALL_FUNCTION(&_4, "defined", NULL, 62, &_3); zephir_check_call_status(); if (zephir_is_true(&_4)) { ZEPHIR_INIT_NVAR(&version); ZEPHIR_GET_CONSTANT(&version, "GD_VERSION"); } else { - ZEPHIR_CALL_FUNCTION(&info, "gd_info", NULL, 71); + ZEPHIR_CALL_FUNCTION(&info, "gd_info", NULL, 63); zephir_check_call_status(); ZEPHIR_INIT_VAR(&matches); ZVAL_NULL(&matches); diff --git a/ext/test/optimizers/strreplace.zep.c b/ext/test/optimizers/strreplace.zep.c index 09c723aacb..accd5a1d07 100644 --- a/ext/test/optimizers/strreplace.zep.c +++ b/ext/test/optimizers/strreplace.zep.c @@ -209,7 +209,7 @@ PHP_METHOD(Test_Optimizers_StrReplace, issue732B) { zephir_array_fast_append(&replacements, &_0); ZEPHIR_INIT_VAR(&subject); ZVAL_STRING(&subject, "The quick brown fox jumped over the lazy dog."); - ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", NULL, 72, &patterns, &replacements, &subject); + ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", NULL, 64, &patterns, &replacements, &subject); zephir_check_call_status(); RETURN_MM(); diff --git a/ext/test/properties/propertyarray.zep.c b/ext/test/properties/propertyarray.zep.c index f05aad2039..cc81036519 100644 --- a/ext/test/properties/propertyarray.zep.c +++ b/ext/test/properties/propertyarray.zep.c @@ -138,12 +138,12 @@ PHP_METHOD(Test_Properties_PropertyArray, testIssues1831) { } zephir_read_property(&_0$$3, this_ptr, SL("otherArray"), PH_NOISY_CC | PH_READONLY); ZEPHIR_MAKE_REF(&_0$$3); - ZEPHIR_CALL_FUNCTION(&info, "array_shift", &_1, 73, &_0$$3); + ZEPHIR_CALL_FUNCTION(&info, "array_shift", &_1, 65, &_0$$3); ZEPHIR_UNREF(&_0$$3); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_2$$3); ZVAL_STRING(&_2$$3, "header"); - ZEPHIR_CALL_FUNCTION(&_3$$3, "stripos", &_4, 74, &info, &_2$$3); + ZEPHIR_CALL_FUNCTION(&_3$$3, "stripos", &_4, 66, &info, &_2$$3); zephir_check_call_status(); if (!ZEPHIR_IS_FALSE_IDENTICAL(&_3$$3)) { zephir_array_append(&headers, &info, PH_SEPARATE, "test/properties/propertyarray.zep", 51); @@ -151,7 +151,7 @@ PHP_METHOD(Test_Properties_PropertyArray, testIssues1831) { } else { zephir_read_property(&_5$$5, this_ptr, SL("otherArray"), PH_NOISY_CC | PH_READONLY); ZEPHIR_MAKE_REF(&_5$$5); - ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", &_6, 75, &_5$$5, &info); + ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", &_6, 67, &_5$$5, &info); ZEPHIR_UNREF(&_5$$5); zephir_check_call_status(); break; diff --git a/ext/test/quantum.zep.c b/ext/test/quantum.zep.c index 4751023948..d5a8967374 100644 --- a/ext/test/quantum.zep.c +++ b/ext/test/quantum.zep.c @@ -340,13 +340,13 @@ PHP_METHOD(Test_Quantum, harmos) { ZVAL_STRING(&_52$$9, "%16.8lf %16.8lf %16.8lf \n"); ZVAL_DOUBLE(&_53$$9, ((double) i * dx)); ZVAL_DOUBLE(&_54$$9, ((double) n * dt)); - ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_55, 76, &fp, &_52$$9, &_53$$9, &_54$$9, &_51$$9); + ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_55, 68, &fp, &_52$$9, &_53$$9, &_54$$9, &_51$$9); zephir_check_call_status(); i = (i + 10); } ZEPHIR_INIT_NVAR(&_56$$8); ZVAL_STRING(&_56$$8, "\n"); - ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_55, 76, &fp, &_56$$8); + ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_55, 68, &fp, &_56$$8); zephir_check_call_status(); } j = 1; diff --git a/ext/test/range.zep.c b/ext/test/range.zep.c index 02133778e7..c062bf6524 100644 --- a/ext/test/range.zep.c +++ b/ext/test/range.zep.c @@ -46,7 +46,7 @@ PHP_METHOD(Test_Range, inclusive1) { ZVAL_LONG(&_0, 0); ZVAL_LONG(&_1, 10); - ZEPHIR_CALL_FUNCTION(&_2, "range", NULL, 77, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "range", NULL, 69, &_0, &_1); zephir_check_call_status(); zephir_get_arrval(&_3, &_2); RETURN_CTOR(&_3); @@ -70,7 +70,7 @@ PHP_METHOD(Test_Range, exclusive1) { ZVAL_LONG(&_0, 0); ZVAL_LONG(&_1, 10); - ZEPHIR_CALL_FUNCTION(&_2, "range", NULL, 77, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "range", NULL, 69, &_0, &_1); zephir_check_call_status(); zephir_get_arrval(&_3, &_2); RETURN_CTOR(&_3); diff --git a/ext/test/regexdna.zep.c b/ext/test/regexdna.zep.c index 3c95c2bf34..f0605a871b 100644 --- a/ext/test/regexdna.zep.c +++ b/ext/test/regexdna.zep.c @@ -179,7 +179,7 @@ PHP_METHOD(Test_RegexDNA, process) { ZEPHIR_CONCAT_SVS(&_1, "/", &stuffToRemove, "/mS"); ZEPHIR_INIT_NVAR(&_0); ZVAL_STRING(&_0, ""); - ZEPHIR_CALL_FUNCTION(&_2, "preg_replace", &_3, 72, &_1, &_0, &contents); + ZEPHIR_CALL_FUNCTION(&_2, "preg_replace", &_3, 64, &_1, &_0, &contents); zephir_check_call_status(); ZEPHIR_CPY_WRT(&contents, &_2); ZEPHIR_INIT_VAR(&codeLength); @@ -223,7 +223,7 @@ PHP_METHOD(Test_RegexDNA, process) { } } ZEPHIR_INIT_NVAR(®ex); - ZEPHIR_CALL_FUNCTION(&_2, "preg_replace", &_3, 72, &vIUB, &vIUBnew, &contents); + ZEPHIR_CALL_FUNCTION(&_2, "preg_replace", &_3, 64, &vIUB, &vIUBnew, &contents); zephir_check_call_status(); ZEPHIR_CPY_WRT(&contents, &_2); php_printf("%c", '\n'); diff --git a/ext/test/requires.zep.c b/ext/test/requires.zep.c index 6c52b7e929..8f0bb9c28d 100644 --- a/ext/test/requires.zep.c +++ b/ext/test/requires.zep.c @@ -96,7 +96,7 @@ PHP_METHOD(Test_Requires, requireExternal3) { ZEPHIR_CALL_METHOD(NULL, &external3, "__construct", NULL, 0); zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(NULL, &external3, "req", NULL, 78, path, this_ptr); + ZEPHIR_CALL_METHOD(NULL, &external3, "req", NULL, 70, path, this_ptr); zephir_check_call_status(); RETURN_MM_MEMBER(getThis(), "content"); diff --git a/ext/test/requires/external3.zep.c b/ext/test/requires/external3.zep.c index b0b0267dc3..a981f2448f 100644 --- a/ext/test/requires/external3.zep.c +++ b/ext/test/requires/external3.zep.c @@ -47,12 +47,12 @@ PHP_METHOD(Test_Requires_External3, req) { - ZEPHIR_CALL_FUNCTION(NULL, "ob_clean", NULL, 79); + ZEPHIR_CALL_FUNCTION(NULL, "ob_clean", NULL, 71); zephir_check_call_status(); if (zephir_require_zval(path) == FAILURE) { RETURN_MM_NULL(); } - ZEPHIR_CALL_FUNCTION(&_0, "ob_get_contents", NULL, 80); + ZEPHIR_CALL_FUNCTION(&_0, "ob_get_contents", NULL, 72); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, requires, "setcontent", NULL, 0, &_0); zephir_check_call_status(); diff --git a/ext/test/resourcetest.zep.c b/ext/test/resourcetest.zep.c index 63f8b87dfd..8823334a46 100644 --- a/ext/test/resourcetest.zep.c +++ b/ext/test/resourcetest.zep.c @@ -123,7 +123,7 @@ PHP_METHOD(Test_ResourceTest, testFunctionsForSTDIN) { ZEPHIR_INIT_VAR(&a); ZEPHIR_GET_CONSTANT(&a, "STDIN"); ZVAL_LONG(&_0, 1); - ZEPHIR_CALL_FUNCTION(NULL, "stream_set_blocking", NULL, 81, &a, &_0); + ZEPHIR_CALL_FUNCTION(NULL, "stream_set_blocking", NULL, 73, &a, &_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); diff --git a/ext/test/router.zep.c b/ext/test/router.zep.c index 01706e0b86..f98da501a6 100644 --- a/ext/test/router.zep.c +++ b/ext/test/router.zep.c @@ -139,7 +139,7 @@ PHP_METHOD(Test_Router, __construct) { add_assoc_long_ex(&_1$$3, SL("controller"), 1); ZEPHIR_INIT_VAR(&_2$$3); ZVAL_STRING(&_2$$3, "#^/([a-zA-Z0-9\\_\\-]+)[/]{0,1}$#"); - ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", &_3, 82, &_2$$3, &_1$$3); + ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", &_3, 74, &_2$$3, &_1$$3); zephir_check_call_status(); zephir_array_append(&routes, &_0$$3, PH_SEPARATE, "test/router.zep", 89); ZEPHIR_INIT_NVAR(&_2$$3); @@ -151,7 +151,7 @@ PHP_METHOD(Test_Router, __construct) { add_assoc_long_ex(&_4$$3, SL("params"), 3); ZEPHIR_INIT_VAR(&_5$$3); ZVAL_STRING(&_5$$3, "#^/([a-zA-Z0-9\\_\\-]+)/([a-zA-Z0-9\\.\\_]+)(/.*)*$#"); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", &_3, 82, &_5$$3, &_4$$3); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", &_3, 74, &_5$$3, &_4$$3); zephir_check_call_status(); zephir_array_append(&routes, &_2$$3, PH_SEPARATE, "test/router.zep", 95); } @@ -1036,7 +1036,7 @@ PHP_METHOD(Test_Router, add) { ZEPHIR_INIT_VAR(&route); object_init_ex(&route, test_router_route_ce); - ZEPHIR_CALL_METHOD(NULL, &route, "__construct", NULL, 82, pattern, paths, httpMethods); + ZEPHIR_CALL_METHOD(NULL, &route, "__construct", NULL, 74, pattern, paths, httpMethods); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_routes"), &route); RETURN_CCTOR(&route); diff --git a/ext/test/scall.zep.c b/ext/test/scall.zep.c index 6a92442149..7d4dc0ecde 100644 --- a/ext/test/scall.zep.c +++ b/ext/test/scall.zep.c @@ -157,7 +157,7 @@ PHP_METHOD(Test_Scall, testCall3) { ZEPHIR_MM_GROW(); - ZEPHIR_RETURN_CALL_SELF("testmethod3", &_0, 83); + ZEPHIR_RETURN_CALL_SELF("testmethod3", &_0, 75); zephir_check_call_status(); RETURN_MM(); @@ -221,7 +221,7 @@ PHP_METHOD(Test_Scall, testCall6) { - ZEPHIR_RETURN_CALL_SELF("testmethod6", &_0, 84, a, b); + ZEPHIR_RETURN_CALL_SELF("testmethod6", &_0, 76, a, b); zephir_check_call_status(); RETURN_MM(); @@ -267,7 +267,7 @@ PHP_METHOD(Test_Scall, testCall9) { ZEPHIR_MM_GROW(); - ZEPHIR_RETURN_CALL_SELF("testmethod3", &_0, 83); + ZEPHIR_RETURN_CALL_SELF("testmethod3", &_0, 75); zephir_check_call_status(); RETURN_MM(); @@ -331,7 +331,7 @@ PHP_METHOD(Test_Scall, testCall12) { - ZEPHIR_RETURN_CALL_SELF("testmethod6", &_0, 84, a, b); + ZEPHIR_RETURN_CALL_SELF("testmethod6", &_0, 76, a, b); zephir_check_call_status(); RETURN_MM(); diff --git a/ext/test/scope.zep.c b/ext/test/scope.zep.c index 03f2ceab1f..5aac6c1382 100644 --- a/ext/test/scope.zep.c +++ b/ext/test/scope.zep.c @@ -75,7 +75,7 @@ PHP_METHOD(Test_Scope, test1) { ZEPHIR_INIT_VAR(&ret); ZVAL_STRING(&ret, ""); - ZEPHIR_CALL_SELF(&k, "getstr", &_0, 85); + ZEPHIR_CALL_SELF(&k, "getstr", &_0, 77); zephir_check_call_status(); r = 1; if (r == 1) { @@ -171,7 +171,7 @@ PHP_METHOD(Test_Scope, test3) { } ZEPHIR_INIT_NVAR(&c); ZVAL_LONG(&c, _1); - ZEPHIR_CALL_SELF(&str$$3, "getdystr", &_3, 86, &c); + ZEPHIR_CALL_SELF(&str$$3, "getdystr", &_3, 78, &c); zephir_check_call_status(); zephir_concat_self(&k, &str$$3); } diff --git a/ext/test/sort.zep.c b/ext/test/sort.zep.c index e00b05508c..f3fbdee1dc 100644 --- a/ext/test/sort.zep.c +++ b/ext/test/sort.zep.c @@ -94,16 +94,16 @@ PHP_METHOD(Test_Sort, quick) { } } } - ZEPHIR_CALL_METHOD(&_7, this_ptr, "quick", &_8, 87, &left); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "quick", &_8, 79, &left); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_9); zephir_create_array(&_9, 1, 0); ZEPHIR_INIT_VAR(&_10); ZVAL_LONG(&_10, pivot); zephir_array_fast_append(&_9, &_10); - ZEPHIR_CALL_METHOD(&_11, this_ptr, "quick", &_8, 87, &right); + ZEPHIR_CALL_METHOD(&_11, this_ptr, "quick", &_8, 79, &right); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("array_merge", NULL, 88, &_7, &_9, &_11); + ZEPHIR_RETURN_CALL_FUNCTION("array_merge", NULL, 80, &_7, &_9, &_11); zephir_check_call_status(); RETURN_MM(); diff --git a/ext/test/spectralnorm.zep.c b/ext/test/spectralnorm.zep.c index 5c7f4f0bb3..13349236c9 100644 --- a/ext/test/spectralnorm.zep.c +++ b/ext/test/spectralnorm.zep.c @@ -113,7 +113,7 @@ PHP_METHOD(Test_SpectralNorm, Au) { j = _4$$3; ZVAL_LONG(&_7$$4, i); ZVAL_LONG(&_8$$4, j); - ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "ax", &_9, 89, &_7$$4, &_8$$4); + ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "ax", &_9, 81, &_7$$4, &_8$$4); zephir_check_call_status(); ZVAL_LONG(&_7$$4, j); ZEPHIR_CALL_METHOD(&_10$$4, u, "offsetget", &_11, 0, &_7$$4); @@ -189,7 +189,7 @@ PHP_METHOD(Test_SpectralNorm, Atu) { j = _4$$3; ZVAL_LONG(&_7$$4, j); ZVAL_LONG(&_8$$4, i); - ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "ax", &_9, 89, &_7$$4, &_8$$4); + ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "ax", &_9, 81, &_7$$4, &_8$$4); zephir_check_call_status(); ZVAL_LONG(&_7$$4, j); ZEPHIR_CALL_METHOD(&_10$$4, u, "offsetget", &_11, 0, &_7$$4); @@ -226,9 +226,9 @@ PHP_METHOD(Test_SpectralNorm, AtAu) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "au", NULL, 90, n, u, w); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "au", NULL, 82, n, u, w); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "atu", NULL, 91, n, w, v); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "atu", NULL, 83, n, w, v); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -267,17 +267,17 @@ PHP_METHOD(Test_SpectralNorm, process) { ZEPHIR_INIT_VAR(&u); object_init_ex(&u, spl_ce_SplFixedArray); ZVAL_LONG(&_0, n); - ZEPHIR_CALL_METHOD(NULL, &u, "__construct", NULL, 92, &_0); + ZEPHIR_CALL_METHOD(NULL, &u, "__construct", NULL, 84, &_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(&v); object_init_ex(&v, spl_ce_SplFixedArray); ZVAL_LONG(&_0, n); - ZEPHIR_CALL_METHOD(NULL, &v, "__construct", NULL, 92, &_0); + ZEPHIR_CALL_METHOD(NULL, &v, "__construct", NULL, 84, &_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(&w); object_init_ex(&w, spl_ce_SplFixedArray); ZVAL_LONG(&_0, n); - ZEPHIR_CALL_METHOD(NULL, &w, "__construct", NULL, 92, &_0); + ZEPHIR_CALL_METHOD(NULL, &w, "__construct", NULL, 84, &_0); zephir_check_call_status(); _3 = (n - 1); _2 = 0; @@ -295,15 +295,15 @@ PHP_METHOD(Test_SpectralNorm, process) { i = _2; ZVAL_LONG(&_4$$3, i); ZVAL_LONG(&_5$$3, 1); - ZEPHIR_CALL_METHOD(NULL, &u, "offsetset", &_6, 93, &_4$$3, &_5$$3); + ZEPHIR_CALL_METHOD(NULL, &u, "offsetset", &_6, 85, &_4$$3, &_5$$3); zephir_check_call_status(); ZVAL_LONG(&_4$$3, i); ZVAL_LONG(&_5$$3, 1); - ZEPHIR_CALL_METHOD(NULL, &v, "offsetset", &_6, 93, &_4$$3, &_5$$3); + ZEPHIR_CALL_METHOD(NULL, &v, "offsetset", &_6, 85, &_4$$3, &_5$$3); zephir_check_call_status(); ZVAL_LONG(&_4$$3, i); ZVAL_LONG(&_5$$3, 1); - ZEPHIR_CALL_METHOD(NULL, &w, "offsetset", &_6, 93, &_4$$3, &_5$$3); + ZEPHIR_CALL_METHOD(NULL, &w, "offsetset", &_6, 85, &_4$$3, &_5$$3); zephir_check_call_status(); } } @@ -322,10 +322,10 @@ PHP_METHOD(Test_SpectralNorm, process) { } i = _8; ZVAL_LONG(&_10$$4, n); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "atau", &_11, 94, &_10$$4, &u, &v, &w); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "atau", &_11, 86, &_10$$4, &u, &v, &w); zephir_check_call_status(); ZVAL_LONG(&_10$$4, n); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "atau", &_11, 94, &_10$$4, &v, &u, &w); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "atau", &_11, 86, &_10$$4, &v, &u, &w); zephir_check_call_status(); } } @@ -344,19 +344,19 @@ PHP_METHOD(Test_SpectralNorm, process) { } i = _13; ZVAL_LONG(&_16$$5, i); - ZEPHIR_CALL_METHOD(&_15$$5, &u, "offsetget", &_17, 95, &_16$$5); + ZEPHIR_CALL_METHOD(&_15$$5, &u, "offsetget", &_17, 87, &_16$$5); zephir_check_call_status(); ZVAL_LONG(&_16$$5, i); - ZEPHIR_CALL_METHOD(&_18$$5, &v, "offsetget", &_17, 95, &_16$$5); + ZEPHIR_CALL_METHOD(&_18$$5, &v, "offsetget", &_17, 87, &_16$$5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_19$$5); mul_function(&_19$$5, &_15$$5, &_18$$5); vBv += zephir_get_numberval(&_19$$5); ZVAL_LONG(&_16$$5, i); - ZEPHIR_CALL_METHOD(&_15$$5, &v, "offsetget", &_17, 95, &_16$$5); + ZEPHIR_CALL_METHOD(&_15$$5, &v, "offsetget", &_17, 87, &_16$$5); zephir_check_call_status(); ZVAL_LONG(&_16$$5, i); - ZEPHIR_CALL_METHOD(&_18$$5, &v, "offsetget", &_17, 95, &_16$$5); + ZEPHIR_CALL_METHOD(&_18$$5, &v, "offsetget", &_17, 87, &_16$$5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_20$$5); mul_function(&_20$$5, &_15$$5, &_18$$5); diff --git a/ext/test/strings.zep.c b/ext/test/strings.zep.c index 44b7182e9d..55665f744e 100644 --- a/ext/test/strings.zep.c +++ b/ext/test/strings.zep.c @@ -545,7 +545,7 @@ PHP_METHOD(Test_Strings, strToHex) { _1$$3 = ZEPHIR_STRING_OFFSET(&value, i); ZEPHIR_INIT_NVAR(&_2$$3); ZVAL_STRINGL(&_2$$3, &_1$$3, 1); - ZEPHIR_CALL_FUNCTION(&_3$$3, "ord", &_4, 96, &_2$$3); + ZEPHIR_CALL_FUNCTION(&_3$$3, "ord", &_4, 88, &_2$$3); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_5$$3, "dechex", &_6, 10, &_3$$3); zephir_check_call_status(); @@ -598,17 +598,17 @@ PHP_METHOD(Test_Strings, issue1267) { zephir_fast_str_replace(&_0, &_1, &_2, value); ZEPHIR_CPY_WRT(value, &_0); ZVAL_LONG(&_3, 513); - ZEPHIR_CALL_FUNCTION(&_4, "filter_var", NULL, 97, value, &_3); + ZEPHIR_CALL_FUNCTION(&_4, "filter_var", NULL, 89, value, &_3); zephir_check_call_status(); ZEPHIR_CPY_WRT(value, &_4); ZEPHIR_INIT_NVAR(&_0); - ZEPHIR_CALL_FUNCTION(&_4, "strip_tags", &_5, 98, value); + ZEPHIR_CALL_FUNCTION(&_4, "strip_tags", &_5, 90, value); zephir_check_call_status(); zephir_stripslashes(&_0, &_4); ZEPHIR_INIT_VAR(&x); zephir_fast_trim(&x, &_0, NULL , ZEPHIR_TRIM_BOTH); ZEPHIR_INIT_VAR(&_6); - ZEPHIR_CALL_FUNCTION(&_7, "strip_tags", &_5, 98, value); + ZEPHIR_CALL_FUNCTION(&_7, "strip_tags", &_5, 90, value); zephir_check_call_status(); zephir_stripcslashes(&_6, &_7); zephir_fast_trim(return_value, &_6, NULL , ZEPHIR_TRIM_BOTH); diff --git a/ext/test/trytest.zep.c b/ext/test/trytest.zep.c index 10f9f94321..240be68adc 100644 --- a/ext/test/trytest.zep.c +++ b/ext/test/trytest.zep.c @@ -192,7 +192,7 @@ PHP_METHOD(Test_TryTest, testTry4) { object_init_ex(&_2$$5, spl_ce_RuntimeException); ZEPHIR_INIT_VAR(&_3$$5); ZVAL_STRING(&_3$$5, "error!"); - ZEPHIR_CALL_METHOD(NULL, &_2$$5, "__construct", NULL, 99, &_3$$5); + ZEPHIR_CALL_METHOD(NULL, &_2$$5, "__construct", NULL, 91, &_3$$5); zephir_check_call_status_or_jump(try_end_1); zephir_throw_exception_debug(&_2$$5, "test/trytest.zep", 48); goto try_end_1; @@ -262,7 +262,7 @@ PHP_METHOD(Test_TryTest, testTry5) { object_init_ex(&_2$$5, spl_ce_RuntimeException); ZEPHIR_INIT_VAR(&_3$$5); ZVAL_STRING(&_3$$5, "error!"); - ZEPHIR_CALL_METHOD(NULL, &_2$$5, "__construct", NULL, 99, &_3$$5); + ZEPHIR_CALL_METHOD(NULL, &_2$$5, "__construct", NULL, 91, &_3$$5); zephir_check_call_status_or_jump(try_end_1); zephir_throw_exception_debug(&_2$$5, "test/trytest.zep", 65); goto try_end_1; @@ -331,7 +331,7 @@ PHP_METHOD(Test_TryTest, testTry6) { object_init_ex(&_2$$5, spl_ce_RuntimeException); ZEPHIR_INIT_VAR(&_3$$5); ZVAL_STRING(&_3$$5, "error!"); - ZEPHIR_CALL_METHOD(NULL, &_2$$5, "__construct", NULL, 99, &_3$$5); + ZEPHIR_CALL_METHOD(NULL, &_2$$5, "__construct", NULL, 91, &_3$$5); zephir_check_call_status_or_jump(try_end_1); zephir_throw_exception_debug(&_2$$5, "test/trytest.zep", 82); goto try_end_1; @@ -399,7 +399,7 @@ PHP_METHOD(Test_TryTest, testTry7) { object_init_ex(&_2$$5, spl_ce_RuntimeException); ZEPHIR_INIT_VAR(&_3$$5); ZVAL_STRING(&_3$$5, "error!"); - ZEPHIR_CALL_METHOD(NULL, &_2$$5, "__construct", NULL, 99, &_3$$5); + ZEPHIR_CALL_METHOD(NULL, &_2$$5, "__construct", NULL, 91, &_3$$5); zephir_check_call_status_or_jump(try_end_1); zephir_throw_exception_debug(&_2$$5, "test/trytest.zep", 101); goto try_end_1; @@ -495,7 +495,7 @@ PHP_METHOD(Test_TryTest, testTry9) { /* try_start_1: */ - ZEPHIR_CALL_METHOD(NULL, this_ptr, "somemethod1", NULL, 100); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "somemethod1", NULL, 92); zephir_check_call_status_or_jump(try_end_1); RETURN_MM_STRING("not catched"); @@ -530,7 +530,7 @@ PHP_METHOD(Test_TryTest, testTry10) { /* try_start_1: */ - ZEPHIR_CALL_METHOD(NULL, this_ptr, "somemethod2", NULL, 101); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "somemethod2", NULL, 93); zephir_check_call_status_or_jump(try_end_1); RETURN_MM_STRING("not catched"); diff --git a/kernels/ZendEngine3/main.c b/kernels/ZendEngine3/main.c index 8c27575fa2..c689b71aa1 100644 --- a/kernels/ZendEngine3/main.c +++ b/kernels/ZendEngine3/main.c @@ -100,8 +100,12 @@ int zephir_get_global(zval *arr, const char *global, unsigned int global_length) if ((gv = zend_hash_find_ind(&EG(symbol_table), str)) != NULL) { ZVAL_DEREF(gv); if (Z_TYPE_P(gv) == IS_ARRAY) { - ZVAL_DUP(arr, gv); - zend_hash_update(&EG(symbol_table), str, arr); + if (Z_REFCOUNTED_P(gv)) { + ZVAL_COPY_VALUE(arr, gv); + } else { + ZVAL_DUP(arr, gv); + zend_hash_update(&EG(symbol_table), str, arr); + } // See: https://github.com/phalcon/zephir/pull/1965#issuecomment-541299003 // ZVAL_COPY_VALUE(arr, gv); diff --git a/test/globals/server.zep b/test/globals/server.zep new file mode 100644 index 0000000000..b08be2cd31 --- /dev/null +++ b/test/globals/server.zep @@ -0,0 +1,21 @@ + +namespace Test\Globals; + +class Server +{ + public function f1() -> void + { + echo _SERVER["PHP_SELF"]; + this->f2(); + echo _SERVER["PHP_SELF"]; + } + + public function f2() -> void + { + echo _SERVER["SCRIPT_NAME"]; + } + + public function check() { + return _SERVER["HTTP_USER_AGENT"]; + } +} From eac2383d4ff669203f3ca93b26d8ccd184328e07 Mon Sep 17 00:00:00 2001 From: Dreamszhu Date: Sat, 19 Oct 2019 19:19:47 +0800 Subject: [PATCH 2/2] Updated --- ext/kernel/main.c | 2 +- kernels/ZendEngine3/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/kernel/main.c b/ext/kernel/main.c index c689b71aa1..4ed30d4bbe 100644 --- a/ext/kernel/main.c +++ b/ext/kernel/main.c @@ -100,7 +100,7 @@ int zephir_get_global(zval *arr, const char *global, unsigned int global_length) if ((gv = zend_hash_find_ind(&EG(symbol_table), str)) != NULL) { ZVAL_DEREF(gv); if (Z_TYPE_P(gv) == IS_ARRAY) { - if (Z_REFCOUNTED_P(gv)) { + if (Z_REFCOUNTED_P(gv) && Z_REFCOUNT_P(gv) <= 1) { ZVAL_COPY_VALUE(arr, gv); } else { ZVAL_DUP(arr, gv); diff --git a/kernels/ZendEngine3/main.c b/kernels/ZendEngine3/main.c index c689b71aa1..4ed30d4bbe 100644 --- a/kernels/ZendEngine3/main.c +++ b/kernels/ZendEngine3/main.c @@ -100,7 +100,7 @@ int zephir_get_global(zval *arr, const char *global, unsigned int global_length) if ((gv = zend_hash_find_ind(&EG(symbol_table), str)) != NULL) { ZVAL_DEREF(gv); if (Z_TYPE_P(gv) == IS_ARRAY) { - if (Z_REFCOUNTED_P(gv)) { + if (Z_REFCOUNTED_P(gv) && Z_REFCOUNT_P(gv) <= 1) { ZVAL_COPY_VALUE(arr, gv); } else { ZVAL_DUP(arr, gv);