cvs: ZendEngine2 / zend_object_handlers.c /tests bug44141.phpt
[email protected] ("Dmitry Stogov")
| Newsgroups | php.zend-engine.cvs |
|---|---|
| Message-ID | <cvsdmitry1203602155@cvsserver> |
dmitry Thu Feb 21 13:55:55 2008 UTC
Modified files:
/ZendEngine2 zend_object_handlers.c
/ZendEngine2/tests bug44141.phpt
Log:
Fixed bug #44141 (private parent constructor callable through static function)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.c?r1=1.195&r2=1.196&diff_format=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.195 ZendEngine2/zend_object_handlers.c:1.196
--- ZendEngine2/zend_object_handlers.c:1.195 Mon Dec 31 07:12:07 2007
+++ ZendEngine2/zend_object_handlers.c Thu Feb 21 13:55:55 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_object_handlers.c,v 1.195 2007/12/31 07:12:07 sebastian Exp $ */
+/* $Id: zend_object_handlers.c,v 1.196 2008/02/21 13:55:55 dmitry Exp $ */
#include "zend.h"
#include "zend_globals.h"
@@ -1052,7 +1052,7 @@
} else if (constructor->op_array.fn_flags & ZEND_ACC_PRIVATE) {
/* Ensure that if we're calling a private function, we're allowed to do so.
*/
- if (Z_OBJ_HANDLER_P(object, get_class_entry)(object TSRMLS_CC) != EG(scope)) {
+ if (constructor->common.scope != EG(scope)) {
if (EG(scope)) {
zend_error(E_ERROR, "Call to private %v::%v() from context '%v'", constructor->common.scope->name, constructor->common.function_name, EG(scope)->name);
} else {
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug44141.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug44141.phpt
diff -u /dev/null ZendEngine2/tests/bug44141.phpt:1.2
--- /dev/null Thu Feb 21 13:55:55 2008
+++ ZendEngine2/tests/bug44141.phpt Thu Feb 21 13:55:55 2008
@@ -0,0 +1,25 @@
+--TEST--
+Bug #44141 (private parent constructor callable through static function)
+--FILE--
+<?php
+class X
+{
+ public $x;
+ private function __construct($x)
+ {
+ $this->x = $x;
+ }
+}
+
+class Y extends X
+{
+ static public function cheat($x)
+ {
+ return new Y($x);
+ }
+}
+
+$y = Y::cheat(5);
+echo $y->x, PHP_EOL;
+--EXPECTF--
+Fatal error: Call to private X::__construct() from context 'Y' in %sbug44141.php on line 15