cvs: ZendEngine2(PHP_5_2) / zend_compile.c zend_object_handlers.c /tests bug38772.phpt php-src NEWS

From: Date: Tue, 12 Sep 2006 11:01:16 +0000
Subject: cvs: ZendEngine2(PHP_5_2) / zend_compile.c zend_object_handlers.c /tests bug38772.phpt php-src NEWS
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-5247@lists.php.net to get a copy of this message
dmitry Tue Sep 12 11:01:16 2006 UTC Added files: (Branch: PHP_5_2) /ZendEngine2/tests bug38772.phpt Modified files: /php-src NEWS /ZendEngine2 zend_compile.c zend_object_handlers.c Log: Fixed bug #38772 (inconsistent overriding of methods in different visibility contexts) http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.246&r2=1.2027.2.547.2.247&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.246 php-src/NEWS:1.2027.2.547.2.247 --- php-src/NEWS:1.2027.2.547.2.246 Mon Sep 11 19:57:45 2006 +++ php-src/NEWS Tue Sep 12 11:01:15 2006 @@ -7,6 +7,8 @@ readded it for other SAPIs (restore to pre 5.1.x behavior). (Edin) - Fixed bug #38779 (engine crashes when require()'ing file with syntax error through userspace stream wrapper). (Tony, Dmitry) +- Fixed bug #38772 (inconsistent overriding of methods in different visibility + contexts). (Dmitry) - Fixed bug #38759 (PDO sqlite2 empty query causes segfault). (Tony) - Fixed bug #38721 (Invalid memory read in date_parse()). (Tony, Derick) - Fixed bug #38700 (SoapClient::__getTypes never returns). (Dmitry) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.16&r2=1.647.2.27.2.17&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.16 ZendEngine2/zend_compile.c:1.647.2.27.2.17 --- ZendEngine2/zend_compile.c:1.647.2.27.2.16 Mon Jul 24 22:36:21 2006 +++ ZendEngine2/zend_compile.c Tue Sep 12 11:01:16 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.647.2.27.2.16 2006/07/24 22:36:21 helly Exp $ */ +/* $Id: zend_compile.c,v 1.647.2.27.2.17 2006/09/12 11:01:16 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -2025,7 +2025,9 @@ } } - if (parent_flags & ZEND_ACC_ABSTRACT) { + if (parent_flags & ZEND_ACC_PRIVATE) { + child->common.prototype = NULL; + } else if (parent_flags & ZEND_ACC_ABSTRACT) { child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT; child->common.prototype = parent; } else if (!(parent->common.fn_flags & ZEND_ACC_CTOR) || (parent->common.prototype && (parent->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE))) { http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.c?r1=1.135.2.6.2.14&r2=1.135.2.6.2.15&diff_format=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.135.2.6.2.14 ZendEngine2/zend_object_handlers.c:1.135.2.6.2.15 --- ZendEngine2/zend_object_handlers.c:1.135.2.6.2.14 Mon Aug 28 10:59:18 2006 +++ ZendEngine2/zend_object_handlers.c Tue Sep 12 11:01:16 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.135.2.6.2.14 2006/08/28 10:59:18 tony2001 Exp $ */ +/* $Id: zend_object_handlers.c,v 1.135.2.6.2.15 2006/09/12 11:01:16 dmitry Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -783,7 +783,17 @@ } /* Check access level */ - if (fbc->op_array.fn_flags & ZEND_ACC_PUBLIC) { + if (fbc->op_array.fn_flags & ZEND_ACC_PRIVATE) { + zend_function *updated_fbc; + + /* Ensure that if we're calling a private function, we're allowed to do so. + */ + updated_fbc = zend_check_private_int(fbc, Z_OBJ_HANDLER_P(object, get_class_entry)(object TSRMLS_CC), lc_method_name, method_len TSRMLS_CC); + if (!updated_fbc) { + zend_error(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : ""); + } + fbc = updated_fbc; + } else { /* Ensure that we haven't overridden a private function and end up calling * the overriding public function... */ @@ -796,21 +806,12 @@ fbc = priv_fbc; } } - } else if (fbc->op_array.fn_flags & ZEND_ACC_PRIVATE) { - zend_function *updated_fbc; - - /* Ensure that if we're calling a private function, we're allowed to do so. - */ - updated_fbc = zend_check_private_int(fbc, Z_OBJ_HANDLER_P(object, get_class_entry)(object TSRMLS_CC), lc_method_name, method_len TSRMLS_CC); - if (!updated_fbc) { - zend_error(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : ""); - } - fbc = updated_fbc; - } else if ((fbc->common.fn_flags & ZEND_ACC_PROTECTED)) { - /* Ensure that if we're calling a protected function, we're allowed to do so. - */ - if (!zend_check_protected(zend_get_function_root_class(fbc), EG(scope))) { - zend_error(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : ""); + if ((fbc->common.fn_flags & ZEND_ACC_PROTECTED)) { + /* Ensure that if we're calling a protected function, we're allowed to do so. + */ + if (!zend_check_protected(zend_get_function_root_class(fbc), EG(scope))) { + zend_error(E_ERROR, "Call to %s method %s::%s() from context '%s'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : ""); + } } } http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug38772.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/bug38772.phpt +++ ZendEngine2/tests/bug38772.phpt

« previous php.zend-engine.cvs (#5247) next »