@@ -582,6 +582,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
582
582
zend_op * * original_opline_ptr ;
583
583
zend_class_entry * current_scope ;
584
584
zend_class_entry * calling_scope = NULL ;
585
+ zend_class_entry * check_scope_or_static = NULL ;
585
586
zval * current_this ;
586
587
zend_execute_data execute_data ;
587
588
zval * method_name ;
@@ -719,21 +720,20 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
719
720
} else {
720
721
char * lcname = zend_str_tolower_dup (fname , clen );
721
722
/* caution: lcname is not '\0' terminated */
722
- if (clen == sizeof ("self" ) - 1 && memcmp (lcname , "self" , sizeof ("self" ) - 1 ) == 0 ) {
723
- ce_child = EG (active_op_array ) ? EG (active_op_array )-> scope : NULL ;
724
- } else if (clen == sizeof ("parent" ) - 1 && memcmp (lcname , "parent" , sizeof ("parent" ) - 1 ) == 0 && EG (active_op_array )-> scope ) {
725
- ce_child = EG (active_op_array ) && EG (active_op_array )-> scope ? EG (scope )-> parent : NULL ;
723
+ if (calling_scope ) {
724
+ if (clen == sizeof ("self" ) - 1 && memcmp (lcname , "self" , sizeof ("self" ) - 1 ) == 0 ) {
725
+ ce_child = EG (active_op_array ) ? EG (active_op_array )-> scope : NULL ;
726
+ } else if (clen == sizeof ("parent" ) - 1 && memcmp (lcname , "parent" , sizeof ("parent" ) - 1 ) == 0 && EG (active_op_array )-> scope ) {
727
+ ce_child = EG (active_op_array ) && EG (active_op_array )-> scope ? EG (scope )-> parent : NULL ;
728
+ }
726
729
}
727
730
efree (lcname );
728
731
}
729
732
if (!ce_child ) {
730
733
zend_error (E_ERROR , "Cannot call method %s() or method does not exist" , fname );
731
734
return FAILURE ;
732
735
}
733
- if (!instanceof_function (calling_scope , ce_child TSRMLS_CC )) {
734
- zend_error (E_ERROR , "Cannot call method %s() of class %s which is not a derived from %s" , fname , ce_child -> name , calling_scope -> name );
735
- return 0 ;
736
- }
736
+ check_scope_or_static = calling_scope ;
737
737
fci -> function_table = & ce_child -> function_table ;
738
738
calling_scope = ce_child ;
739
739
fname = fname + clen + 2 ;
@@ -760,6 +760,12 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
760
760
EX (function_state ).function =
761
761
zend_std_get_static_method (calling_scope , function_name_lc , fname_len TSRMLS_CC );
762
762
efree (function_name_lc );
763
+ if (check_scope_or_static && EX (function_state ).function
764
+ && !(EX (function_state ).function -> common .fn_flags & ZEND_ACC_STATIC )
765
+ && !instanceof_function (check_scope_or_static , calling_scope TSRMLS_CC )) {
766
+ zend_error (E_ERROR , "Cannot call method %s() of class %s which is not a derived from %s" , fname , calling_scope -> name , check_scope_or_static -> name );
767
+ return 0 ;
768
+ }
763
769
} else {
764
770
char * function_name_lc = zend_str_tolower_dup (fname , fname_len );
765
771
0 commit comments