summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/opcache/ZendAccelerator.c66
-rw-r--r--ext/spl/php_spl.c11
2 files changed, 39 insertions, 38 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 426156fa5b..112d1576c6 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -733,7 +733,7 @@ static accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle
#endif
if (sapi_module.get_stat &&
- !EG(opline_ptr) &&
+ !EG(current_execute_data) &&
file_handle->filename == SG(request_info).path_translated) {
struct stat *tmpbuf = sapi_module.get_stat(TSRMLS_C);
@@ -1518,16 +1518,16 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T
/* In case this callback is called from include_once, require_once or it's
* a main FastCGI request, the key must be already calculated, and cached
* persistent script already found */
- if ((EG(opline_ptr) == NULL &&
+ if ((EG(current_execute_data) == NULL &&
ZCG(cache_opline) == NULL &&
file_handle->filename == SG(request_info).path_translated &&
ZCG(cache_persistent_script)) ||
- (EG(opline_ptr) && *EG(opline_ptr) &&
- *EG(opline_ptr) == ZCG(cache_opline) &&
- (*EG(opline_ptr))->opcode == ZEND_INCLUDE_OR_EVAL &&
+ (EG(current_execute_data) && EG(current_execute_data)->opline &&
+ EG(current_execute_data)->opline == ZCG(cache_opline) &&
+ EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL &&
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
- ((*EG(opline_ptr))->extended_value == ZEND_INCLUDE_ONCE ||
- (*EG(opline_ptr))->extended_value == ZEND_REQUIRE_ONCE))) {
+ (EG(current_execute_data)->opline->extended_value == ZEND_INCLUDE_ONCE ||
+ EG(current_execute_data)->opline->extended_value == ZEND_REQUIRE_ONCE))) {
#else
((*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE ||
(*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_REQUIRE_ONCE))) {
@@ -1682,11 +1682,11 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T
/* see bug #15471 (old BTS) */
if (persistent_script->full_path) {
- if (!EG(opline_ptr) || !*EG(opline_ptr) ||
- (*EG(opline_ptr))->opcode != ZEND_INCLUDE_OR_EVAL ||
+ if (!EG(current_execute_data) || !EG(current_execute_data)->opline ||
+ EG(current_execute_data)->opline->opcode != ZEND_INCLUDE_OR_EVAL ||
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
- ((*EG(opline_ptr))->extended_value != ZEND_INCLUDE_ONCE &&
- (*EG(opline_ptr))->extended_value != ZEND_REQUIRE_ONCE)) {
+ (EG(current_execute_data)->opline->extended_value != ZEND_INCLUDE_ONCE &&
+ EG(current_execute_data)->opline->extended_value != ZEND_REQUIRE_ONCE)) {
#else
((*EG(opline_ptr))->op2.u.constant.value.lval != ZEND_INCLUDE_ONCE &&
(*EG(opline_ptr))->op2.u.constant.value.lval != ZEND_REQUIRE_ONCE)) {
@@ -1843,8 +1843,8 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl
!CG(interactive) &&
!ZCSG(restart_in_progress)) {
- if (EG(opline_ptr) && *EG(opline_ptr)) {
- zend_op *opline = *EG(opline_ptr);
+ if (EG(current_execute_data) && EG(current_execute_data)->opline) {
+ zend_op *opline = EG(current_execute_data)->opline;
if (opline->opcode == ZEND_INCLUDE_OR_EVAL &&
(opline->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE ||
@@ -1940,14 +1940,14 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl
!ZCSG(restart_in_progress)) {
/* check if callback is called from include_once or it's a main request */
- if ((!EG(opline_ptr) &&
+ if ((!EG(current_execute_data) &&
filename == SG(request_info).path_translated) ||
- (EG(opline_ptr) &&
- *EG(opline_ptr) &&
- (*EG(opline_ptr))->opcode == ZEND_INCLUDE_OR_EVAL &&
+ (EG(current_execute_data) &&
+ EG(current_execute_data)->opline &&
+ EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL &&
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
- ((*EG(opline_ptr))->extended_value == ZEND_INCLUDE_ONCE ||
- (*EG(opline_ptr))->extended_value == ZEND_REQUIRE_ONCE))) {
+ (EG(current_execute_data)->opline->extended_value == ZEND_INCLUDE_ONCE ||
+ EG(current_execute_data)->opline->extended_value == ZEND_REQUIRE_ONCE))) {
#else
((*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE ||
(*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_REQUIRE_ONCE))) {
@@ -1960,11 +1960,11 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl
handle->free_filename = 0;
/* check if cached script was already found by resolve_path() */
- if ((EG(opline_ptr) == NULL &&
+ if ((EG(current_execute_data) == NULL &&
ZCG(cache_opline) == NULL &&
ZCG(cache_persistent_script) != NULL) ||
- (EG(opline_ptr) &&
- (ZCG(cache_opline) == *EG(opline_ptr)))) {
+ (EG(current_execute_data) &&
+ (ZCG(cache_opline) == EG(current_execute_data)->opline))) {
persistent_script = ZCG(cache_persistent_script);
handle->opened_path = estrndup(persistent_script->full_path->val, persistent_script->full_path->len);
handle->type = ZEND_HANDLE_FILENAME;
@@ -1983,8 +1983,8 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl
handle->type = ZEND_HANDLE_FILENAME;
memcpy(ZCG(key), persistent_script->full_path, persistent_script->full_path_len + 1);
ZCG(key_len) = persistent_script->full_path_len;
- ZCG(cache_opline) = EG(opline_ptr) ? *EG(opline_ptr) : NULL;
- ZCG(cache_persistent_script) = EG(opline_ptr) ? persistent_script : NULL;
+ ZCG(cache_opline) = EG(current_execute_data) ? EG(current_execute_data)->opline : NULL;
+ ZCG(cache_persistent_script) = EG(current_execute_data) ? persistent_script : NULL;
return SUCCESS;
}
#endif
@@ -2005,14 +2005,14 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len
!ZCSG(restart_in_progress)) {
/* check if callback is called from include_once or it's a main request */
- if ((!EG(opline_ptr) &&
+ if ((!EG(current_execute_data) &&
filename == SG(request_info).path_translated) ||
- (EG(opline_ptr) &&
- *EG(opline_ptr) &&
- (*EG(opline_ptr))->opcode == ZEND_INCLUDE_OR_EVAL &&
+ (EG(current_execute_data) &&
+ EG(current_execute_data)->opline &&
+ EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL &&
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
- ((*EG(opline_ptr))->extended_value == ZEND_INCLUDE_ONCE ||
- (*EG(opline_ptr))->extended_value == ZEND_REQUIRE_ONCE))) {
+ (EG(current_execute_data)->opline->extended_value == ZEND_INCLUDE_ONCE ||
+ EG(current_execute_data)->opline->extended_value == ZEND_REQUIRE_ONCE))) {
#else
((*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE ||
(*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_REQUIRE_ONCE))) {
@@ -2034,7 +2034,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len
if (persistent_script && !persistent_script->corrupted) {
memcpy(ZCG(key), persistent_script->full_path->val, persistent_script->full_path->len + 1);
ZCG(key_len) = persistent_script->full_path->len;
- ZCG(cache_opline) = EG(opline_ptr) ? *EG(opline_ptr) : NULL;
+ ZCG(cache_opline) = EG(current_execute_data) ? EG(current_execute_data)->opline : NULL;
ZCG(cache_persistent_script) = persistent_script;
return estrndup(persistent_script->full_path->val, persistent_script->full_path->len);
}
@@ -2051,7 +2051,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len
!persistent_script->corrupted) {
/* we have persistent script */
- ZCG(cache_opline) = EG(opline_ptr) ? *EG(opline_ptr) : NULL;
+ ZCG(cache_opline) = EG(current_execute_data) ? EG(current_execute_data)->opline : NULL;
ZCG(cache_persistent_script) = persistent_script;
return estrndup(persistent_script->full_path->val, persistent_script->full_path->len);
}
@@ -2073,7 +2073,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len
zend_shared_alloc_unlock(TSRMLS_C);
SHM_PROTECT();
}
- ZCG(cache_opline) = (EG(opline_ptr) && key) ? *EG(opline_ptr): NULL;
+ ZCG(cache_opline) = (EG(current_execute_data) && key) ? EG(current_execute_data)->opline : NULL;
ZCG(cache_persistent_script) = key ? persistent_script : NULL;
return resolved_path;
}
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index 2daeff6603..8bab4ae3cf 100644
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -318,7 +318,6 @@ PHP_FUNCTION(spl_autoload)
int found = 0, pos_len, pos1_len;
char *pos, *pos1;
zend_string *class_name, *lc_name, *file_exts = SPL_G(autoload_extensions);
- zend_op **original_opline_ptr = EG(opline_ptr);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|S", &class_name, &file_exts) == FAILURE) {
RETURN_FALSE;
@@ -335,7 +334,6 @@ PHP_FUNCTION(spl_autoload)
lc_name = STR_ALLOC(class_name->len, 0);
zend_str_tolower_copy(lc_name->val, class_name->val, class_name->len);
while (pos && *pos && !EG(exception)) {
- EG(opline_ptr) = original_opline_ptr;
pos1 = strchr(pos, ',');
if (pos1) {
pos1_len = pos1 - pos;
@@ -351,14 +349,17 @@ PHP_FUNCTION(spl_autoload)
}
STR_FREE(lc_name);
- EG(opline_ptr) = original_opline_ptr;
-
if (!found && !SPL_G(autoload_running)) {
/* For internal errors, we generate E_ERROR, for direct calls an exception is thrown.
* The "scope" is determined by an opcode, if it is ZEND_FETCH_CLASS we know function was called indirectly by
* the Zend engine.
*/
- if (active_opline->opcode != ZEND_FETCH_CLASS) {
+ zend_execute_data *ex = EG(current_execute_data);
+
+ while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
+ ex = ex->prev_execute_data;
+ }
+ if (ex && ex->opline && ex->opline->opcode != ZEND_FETCH_CLASS) {
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Class %s could not be loaded", class_name->val);
} else {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s could not be loaded", class_name->val);