Skip to content

Commit 009cdf1

Browse files
Autoload with zvals
1 parent d38277b commit 009cdf1

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

Zend/zend_execute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ZEND_API extern void (*zend_execute_ex)(zend_execute_data *execute_data);
3535
ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value);
3636

3737
/* The lc_name may be stack allocated! */
38-
ZEND_API extern zend_class_entry *(*zend_autoload)(zend_string *name, zend_string *lc_name);
38+
ZEND_API extern zval *(*zend_autoload)(zend_string *name, zend_string *lc_name);
3939

4040
void init_executor(void);
4141
void shutdown_executor(void);

Zend/zend_execute_API.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data);
5454
ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value);
55-
ZEND_API zend_class_entry *(*zend_autoload)(zend_string *name, zend_string *lc_name);
55+
ZEND_API zval *(*zend_autoload)(zend_string *name, zend_string *lc_name);
5656

5757
#ifdef ZEND_WIN32
5858
ZEND_TLS HANDLE tq_timer = NULL;
@@ -1270,7 +1270,10 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
12701270
EG(filename_override) = NULL;
12711271
EG(lineno_override) = -1;
12721272
zend_exception_save();
1273-
ce = zend_autoload(autoload_name, lc_name);
1273+
zval *ce_zval = zend_autoload(autoload_name, lc_name);
1274+
if (ce_zval) {
1275+
ce = Z_PTR_P(ce_zval);
1276+
}
12741277
zend_exception_restore();
12751278
EG(filename_override) = previous_filename;
12761279
EG(lineno_override) = previous_lineno;

ext/spl/php_spl.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ static bool autoload_func_info_equals(
414414
&& alfi1->closure == alfi2->closure;
415415
}
416416

417-
static zend_class_entry *spl_perform_autoload(zend_string *class_name, zend_string *lc_name) {
417+
static zval *spl_perform_autoload(zend_string *class_name, zend_string *lc_name) {
418418
if (!spl_autoload_functions) {
419419
return NULL;
420420
}
@@ -444,13 +444,9 @@ static zend_class_entry *spl_perform_autoload(zend_string *class_name, zend_stri
444444
break;
445445
}
446446

447-
if (ZSTR_HAS_CE_CACHE(class_name) && ZSTR_GET_CE_CACHE(class_name)) {
448-
return (zend_class_entry*)ZSTR_GET_CE_CACHE(class_name);
449-
} else {
450-
zend_class_entry *ce = zend_hash_find_ptr(EG(class_table), lc_name);
451-
if (ce) {
452-
return ce;
453-
}
447+
zval *ce_ptr = zend_hash_find(EG(class_table), lc_name);
448+
if (ce_ptr) {
449+
return ce_ptr;
454450
}
455451

456452
zend_hash_move_forward_ex(spl_autoload_functions, &pos);

0 commit comments

Comments
 (0)