@@ -123,49 +123,25 @@ ZEND_API void zend_objects_destroy_object(zend_object *object)
123123 zend_object * old_exception ;
124124 const zend_op * old_opline_before_exception ;
125125
126- if (destructor -> op_array .fn_flags & (ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED )) {
127- if (destructor -> op_array .fn_flags & ZEND_ACC_PRIVATE ) {
128- /* Ensure that if we're calling a private function, we're allowed to do so.
129- */
130- if (EG (current_execute_data )) {
131- zend_class_entry * scope = zend_get_executed_scope ();
132-
133- if (object -> ce != scope ) {
134- zend_throw_error (NULL ,
135- "Call to private %s::__destruct() from %s%s" ,
136- ZSTR_VAL (object -> ce -> name ),
137- scope ? "scope " : "global scope" ,
138- scope ? ZSTR_VAL (scope -> name ) : ""
139- );
140- return ;
141- }
142- } else {
143- zend_error (E_WARNING ,
144- "Call to private %s::__destruct() from global scope during shutdown ignored" ,
145- ZSTR_VAL (object -> ce -> name ));
126+ if (destructor -> common .fn_flags & (ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED )) {
127+ if (EG (current_execute_data )) {
128+ zend_class_entry * scope = zend_get_executed_scope ();
129+ /* Ensure that if we're calling a protected or private function, we're allowed to do so. */
130+ ZEND_ASSERT (!(destructor -> common .fn_flags & ZEND_ACC_PUBLIC ));
131+ if (!zend_check_method_accessible (destructor , scope )) {
132+ zend_throw_error (NULL ,
133+ "Call to %s %s::__destruct() from %s%s" ,
134+ zend_visibility_string (destructor -> common .fn_flags ), ZSTR_VAL (object -> ce -> name ),
135+ scope ? "scope " : "global scope" ,
136+ scope ? ZSTR_VAL (scope -> name ) : ""
137+ );
146138 return ;
147139 }
148140 } else {
149- /* Ensure that if we're calling a protected function, we're allowed to do so.
150- */
151- if (EG (current_execute_data )) {
152- zend_class_entry * scope = zend_get_executed_scope ();
153-
154- if (!zend_check_protected (zend_get_function_root_class (destructor ), scope )) {
155- zend_throw_error (NULL ,
156- "Call to protected %s::__destruct() from %s%s" ,
157- ZSTR_VAL (object -> ce -> name ),
158- scope ? "scope " : "global scope" ,
159- scope ? ZSTR_VAL (scope -> name ) : ""
160- );
161- return ;
162- }
163- } else {
164- zend_error (E_WARNING ,
165- "Call to protected %s::__destruct() from global scope during shutdown ignored" ,
166- ZSTR_VAL (object -> ce -> name ));
167- return ;
168- }
141+ zend_error (E_WARNING ,
142+ "Call to %s %s::__destruct() from global scope during shutdown ignored" ,
143+ zend_visibility_string (destructor -> common .fn_flags ), ZSTR_VAL (object -> ce -> name ));
144+ return ;
169145 }
170146 }
171147
0 commit comments