@@ -124,48 +124,28 @@ ZEND_API void zend_objects_destroy_object(zend_object *object)
124124 const zend_op * old_opline_before_exception ;
125125
126126 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 )) {
127+ if (EG (current_execute_data )) {
128+ zend_class_entry * scope = zend_get_executed_scope ();
129+ if (!zend_check_method_accessible (destructor , scope )) {
130+ /* Ensure that if we're calling a protected or private function, we're allowed to do so.
131+ */
131132 zend_class_entry * scope = zend_get_executed_scope ();
132133
133134 if (object -> ce != scope ) {
134135 zend_throw_error (NULL ,
135- "Call to private %s::__destruct() from %s%s" ,
136- ZSTR_VAL (object -> ce -> name ),
136+ "Call to %s %s::__destruct() from %s%s" ,
137+ zend_visibility_string ( destructor -> common . fn_flags ), ZSTR_VAL (object -> ce -> name ),
137138 scope ? "scope " : "global scope" ,
138139 scope ? ZSTR_VAL (scope -> name ) : ""
139140 );
140141 return ;
141142 }
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 ));
146- return ;
147143 }
148144 } 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- }
145+ zend_error (E_WARNING ,
146+ "Call to %s %s::__destruct() from global scope during shutdown ignored" ,
147+ zend_visibility_string (destructor -> common .fn_flags ), ZSTR_VAL (object -> ce -> name ));
148+ return ;
169149 }
170150 }
171151
0 commit comments