Created
November 12, 2021 03:20
-
-
Save camporter/0fe6df7909c2473323f6892ced78fb62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c | |
index a064927f93..0d69bfbaca 100644 | |
--- a/Zend/zend_ast.c | |
+++ b/Zend/zend_ast.c | |
@@ -482,7 +482,7 @@ static zend_result zend_ast_add_unpacked_element(zval *result, zval *expr) { | |
zend_class_entry *zend_ast_fetch_class(zend_ast *ast, zend_class_entry *scope) | |
{ | |
- return zend_fetch_class(zend_ast_get_str(ast), ast->attr | ZEND_FETCH_CLASS_EXCEPTION); | |
+ return zend_fetch_class_with_scope(zend_ast_get_str(ast), ast->attr | ZEND_FETCH_CLASS_EXCEPTION, scope); | |
} | |
ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope) | |
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h | |
index 278afc9c10..d13087a5b0 100644 | |
--- a/Zend/zend_execute.h | |
+++ b/Zend/zend_execute.h | |
@@ -349,6 +349,7 @@ ZEND_API void zend_set_timeout(zend_long seconds, bool reset_signals); | |
ZEND_API void zend_unset_timeout(void); | |
ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void); | |
ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type); | |
+ZEND_API zend_class_entry *zend_fetch_class_with_scope(zend_string *class_name, int fetch_type, zend_class_entry *scope); | |
ZEND_API zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string *lcname, int fetch_type); | |
ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function(zend_string *name); | |
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c | |
index 7d870530b1..9295afa5e2 100644 | |
--- a/Zend/zend_execute_API.c | |
+++ b/Zend/zend_execute_API.c | |
@@ -1479,21 +1482,26 @@ void zend_unset_timeout(void) /* {{{ */ | |
} | |
/* }}} */ | |
-zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type) /* {{{ */ | |
+zend_class_entry *zend_fetch_class_with_scope(zend_string *class_name, int fetch_type, zend_class_entry *scope) | |
+/* {{{ */ | |
{ | |
- zend_class_entry *ce, *scope; | |
+ zend_class_entry *ce; | |
int fetch_sub_type = fetch_type & ZEND_FETCH_CLASS_MASK; | |
check_fetch_type: | |
switch (fetch_sub_type) { | |
case ZEND_FETCH_CLASS_SELF: | |
- scope = zend_get_executed_scope(); | |
+ if (scope == NULL) { | |
+ scope = zend_get_executed_scope(); | |
+ } | |
if (UNEXPECTED(!scope)) { | |
zend_throw_or_error(fetch_type, NULL, "Cannot access \"self\" when no class scope is active"); | |
} | |
return scope; | |
case ZEND_FETCH_CLASS_PARENT: | |
- scope = zend_get_executed_scope(); | |
+ if (scope == NULL) { | |
+ scope = zend_get_executed_scope(); | |
+ } | |
if (UNEXPECTED(!scope)) { | |
zend_throw_or_error(fetch_type, NULL, "Cannot access \"parent\" when no class scope is active"); | |
return NULL; | |
@@ -1535,6 +1543,12 @@ check_fetch_type: | |
} | |
/* }}} */ | |
+zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type) /* {{{ */ | |
+{ | |
+ return zend_fetch_class_with_scope(class_name, fetch_type, NULL); | |
+} | |
+/* }}} */ | |
+ | |
zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string *key, int fetch_type) /* {{{ */ | |
{ | |
zend_class_entry *ce = zend_lookup_class_ex(class_name, key, fetch_type); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment