@@ -472,7 +472,7 @@ static inline void zai_hook_resolved_install_shared_hook(zai_hook_t *hook, zend_
472
472
static inline void zai_hook_resolved_install_abstract_recursive (zai_hook_t * hook , zend_ulong index , zend_class_entry * scope ) {
473
473
// find implementers by searching through all inheritors, recursively, stopping upon finding a non-abstract implementation
474
474
zai_hook_inheritor_list * inheritors ;
475
- zend_ulong ce_addr = ((zend_ulong )scope ) << 3 ;
475
+ zend_ulong ce_addr = ((zend_ulong )scope ) >> 3 ;
476
476
if ((inheritors = zend_hash_index_find_ptr (& zai_hook_tls -> inheritors , ce_addr ))) {
477
477
for (size_t i = inheritors -> size ; i -- ;) {
478
478
zend_class_entry * inheritor = inheritors -> inheritor [i ];
@@ -490,7 +490,7 @@ static inline void zai_hook_resolved_install_abstract_recursive(zai_hook_t *hook
490
490
static inline void zai_hook_resolved_install_inherited_internal_function_recursive (zai_hook_t * hook , zend_ulong index , zend_class_entry * scope , zif_handler handler ) {
491
491
// find implementers by searching through all inheritors, recursively, stopping upon finding an explicit override
492
492
zai_hook_inheritor_list * inheritors ;
493
- zend_ulong ce_addr = ((zend_ulong )scope ) << 3 ;
493
+ zend_ulong ce_addr = ((zend_ulong )scope ) >> 3 ;
494
494
if ((inheritors = zend_hash_index_find_ptr (& zai_hook_tls -> inheritors , ce_addr ))) {
495
495
for (size_t i = inheritors -> size ; i -- ;) {
496
496
zend_class_entry * inheritor = inheritors -> inheritor [i ];
@@ -554,7 +554,7 @@ static zend_long zai_hook_request_install(zai_hook_t *hook) {
554
554
static inline void zai_hook_register_inheritor (zend_class_entry * child , zend_class_entry * parent , bool persistent ) {
555
555
const size_t min_size = 7 ;
556
556
557
- zend_ulong addr = ((zend_ulong )parent ) << 3 ;
557
+ zend_ulong addr = ((zend_ulong )parent ) >> 3 ;
558
558
zai_hook_inheritor_list * inheritors ;
559
559
zval * inheritors_zv ;
560
560
HashTable * ht = persistent ? & zai_hook_static_inheritors : & zai_hook_tls -> inheritors ;
@@ -842,7 +842,7 @@ static inline void zai_hook_remove_shared_hook(zend_function *func, zend_ulong h
842
842
static void zai_hook_remove_abstract_recursive (zai_hooks_entry * base_hooks , zend_class_entry * scope , zend_string * function_name , zend_ulong hook_id ) {
843
843
// find implementers by searching through all inheritors, recursively, stopping upon finding a non-abstract implementation
844
844
zai_hook_inheritor_list * inheritors ;
845
- zend_ulong ce_addr = ((zend_ulong )scope ) << 3 ;
845
+ zend_ulong ce_addr = ((zend_ulong )scope ) >> 3 ;
846
846
if ((inheritors = zend_hash_index_find_ptr (& zai_hook_tls -> inheritors , ce_addr ))) {
847
847
for (size_t i = inheritors -> size ; i -- ;) {
848
848
zend_class_entry * inheritor = inheritors -> inheritor [i ];
@@ -860,7 +860,7 @@ static void zai_hook_remove_abstract_recursive(zai_hooks_entry *base_hooks, zend
860
860
static void zai_hook_remove_internal_inherited_recursive (zend_class_entry * scope , zend_string * function_name , zend_ulong hook_id , zif_handler handler ) {
861
861
// find implementers by searching through all inheritors, recursively, stopping upon finding an explicit override
862
862
zai_hook_inheritor_list * inheritors ;
863
- zend_ulong ce_addr = ((zend_ulong )scope ) << 3 ;
863
+ zend_ulong ce_addr = ((zend_ulong )scope ) >> 3 ;
864
864
if ((inheritors = zend_hash_index_find_ptr (& zai_hook_tls -> inheritors , ce_addr ))) {
865
865
for (size_t i = inheritors -> size ; i -- ;) {
866
866
zend_class_entry * inheritor = inheritors -> inheritor [i ];
@@ -1276,12 +1276,12 @@ void zai_hook_exclude_class_resolved(zai_install_address function_address, zend_
1276
1276
if (!hooks ) {
1277
1277
return ;
1278
1278
}
1279
- zai_hook_add_exclusion (hooks , index , lc_classname );
1280
1279
1281
1280
zend_class_entry * ce = NULL ;
1282
1281
zend_string * function_name = hooks -> resolved -> common .function_name ;
1283
1282
zend_function * resolved = zai_hook_lookup_function (zai_str_from_zstr (lc_classname ), zai_str_from_zstr (function_name ), & ce );
1284
1283
if (!ce || !resolved ) {
1284
+ zai_hook_add_exclusion (hooks , index , lc_classname );
1285
1285
return ;
1286
1286
}
1287
1287
zai_hooks_entry * excluded_hooks = zend_hash_index_find_ptr (& zai_hook_resolved , zai_hook_install_address (resolved ));
@@ -1294,6 +1294,16 @@ void zai_hook_exclude_class_resolved(zai_install_address function_address, zend_
1294
1294
return ;
1295
1295
}
1296
1296
1297
+ zend_hash_index_del (& excluded_hooks -> hooks , (zend_ulong ) index );
1298
+ if (zend_hash_num_elements (& excluded_hooks -> hooks ) == 0 ) {
1299
+ #if PHP_VERSION_ID >= 80200
1300
+ if (excluded_hooks -> internal_duplicate_count == 0 )
1301
+ #endif
1302
+ {
1303
+ zai_hook_entries_remove_resolved ((zend_ulong ) function_address );
1304
+ }
1305
+ }
1306
+
1297
1307
zai_hook_remove_abstract_recursive (hooks , ce , function_name , (zend_ulong ) index );
1298
1308
}
1299
1309
0 commit comments