For Programmers: Free Programming Magazines  


Home > Archive > PHP Zend Engine > August 2006 > cvs: ZendEngine2(PHP_5_2) / zend_vm_def.h zend_vm_execute.h php-src NEWS php-src/te









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cvs: ZendEngine2(PHP_5_2) / zend_vm_def.h zend_vm_execute.h php-src NEWS php-src/te
Marcus Boerger

2006-08-07, 6:56 pm

helly Mon Aug 7 23:24:35 2006 UTC

Added files: (Branch: PHP_5_2)
/php-src/tests/classes ctor_visibility.phpt

Modified files:
/php-src NEWS
/ZendEngine2 zend_vm_def.h zend_vm_execute.h
Log:
- MFH Fixed Bug #38064 ignored constructor visibility


http://cvs.php.net/viewvc.cgi/php-s...8&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.187 php-src/NEWS:1.2027.2.547.2.188
--- php-src/NEWS:1.2027.2.547.2.187 Mon Aug 7 15:15:20 2006
+++ php-src/NEWS Mon Aug 7 23:24:33 2006
@@ -73,6 +73,7 @@
- Fixed bug #38168 (Crash in pdo_pgsql on missing bound parameters). (Ilia)
- Fixed bug #38132 (ReflectionClass::getStaticProperties() retains \0 in key
names). (Ilia)
+- Fixed bug #38064 (ignored constructor visibility). (Marcus)
- Fixed bug #38047 ("file" and "line" sometimes not set in backtrace from
inside error handler). (Dmitry)
- Fixed bug #37846 (wordwrap() wraps incorrectly). (ddk at krasn dot ru, Tony)
http://cvs.php.net/viewvc.cgi/ZendE...2&diff_format=u
Index: ZendEngine2/zend_vm_def.h
diff -u ZendEngine2/zend_vm_def.h:1.59.2.29.2.21 ZendEngine2/zend_vm_def.h:1.59.2.29.2.22
--- ZendEngine2/zend_vm_def.h:1.59.2.29.2.21 Mon Aug 7 15:15:20 2006
+++ ZendEngine2/zend_vm_def.h Mon Aug 7 23:24:33 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: zend_vm_def.h,v 1.59.2.29.2.21 2006/08/07 15:15:20 dmitry Exp $ */
+/* $Id: zend_vm_def.h,v 1.59.2.29.2.22 2006/08/07 23:24:33 helly Exp $ */

/* If you change this file, please regenerate the zend_vm_execute.h and
* zend_vm_opcodes.h files by running:
@@ -1763,6 +1763,9 @@
if(!ce->constructor) {
zend_error_noreturn(E_ERROR, "Can not call constructor");
}
+ if (Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) {
+ zend_error(E_COMPILE_ERROR, "Cannot call private %s::__constrcut()", ce->name);
+ }
EX(fbc) = ce->constructor;
}

http://cvs.php.net/viewvc.cgi/ZendE...2&diff_format=u
Index: ZendEngine2/zend_vm_execute.h
diff -u ZendEngine2/zend_vm_execute.h:1.62.2.30.2.21 ZendEngine2/zend_vm_execute.h:1.62.2.30.2.22
--- ZendEngine2/zend_vm_execute.h:1.62.2.30.2.21 Mon Aug 7 15:15:21 2006
+++ ZendEngine2/zend_vm_execute.h Mon Aug 7 23:24:33 2006
@@ -670,6 +670,9 @@
if(!ce->constructor) {
zend_error_noreturn(E_ERROR, "Can not call constructor");
}
+ if (Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE) {
+ zend_error(E_COMPILE_ERROR, "Cannot call private %s::__constrcut()", ce->name);
+ }
EX(fbc) = ce->constructor;
}

@@ -871,6 +874,9 @@
if(!ce->constructor) {
zend_error_noreturn(E_ERROR, "Can not call constructor");
}
+ if (Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE) {
+ zend_error(E_COMPILE_ERROR, "Cannot call private %s::__constrcut()", ce->name);
+ }
EX(fbc) = ce->constructor;
}

@@ -1029,6 +1035,9 @@
if(!ce->constructor) {
zend_error_noreturn(E_ERROR, "Can not call constructor");
}
+ if (Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE) {
+ zend_error(E_COMPILE_ERROR, "Cannot call private %s::__constrcut()", ce->name);
+ }
EX(fbc) = ce->constructor;
}

@@ -1186,6 +1195,9 @@
if(!ce->constructor) {
zend_error_noreturn(E_ERROR, "Can not call constructor");
}
+ if (Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE) {
+ zend_error(E_COMPILE_ERROR, "Cannot call private %s::__constrcut()", ce->name);
+ }
EX(fbc) = ce->constructor;
}

@@ -1276,6 +1288,9 @@
if(!ce->constructor) {
zend_error_noreturn(E_ERROR, "Can not call constructor");
}
+ if (Z_OBJCE_P(EG(This)) != ce->constructor->common.scope && ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE) {
+ zend_error(E_COMPILE_ERROR, "Cannot call private %s::__constrcut()", ce->name);
+ }
EX(fbc) = ce->constructor;
}


http://cvs.php.net/viewvc.cgi/php-s...=markup&rev=1.1
Index: php-src/tests/classes/ctor_visibility.phpt
+++ php-src/tests/classes/ctor_visibility.phpt
--TEST--
ZE2 A private constructor cannot be called
--FILE--
<?php

class Test
{
function __construct()
{
echo __METHOD__ . "()\n";
}
}

class Derived extends Test
{
function __construct()
{
echo __METHOD__ . "()\n";
parent::__construct();
}

static function f()
{
new Derived;
}
}

Derived::f();

class TestPriv
{
private function __construct()
{
echo __METHOD__ . "()\n";
}

static function f()
{
new TestPriv;
}
}

TestPriv::f();

class DerivedPriv extends TestPriv
{
function __construct()
{
echo __METHOD__ . "()\n";
parent::__construct();
}

static function f()
{
new DerivedPriv;
}
}

DerivedPriv::f();

?>
===DONE===
--EXPECTF--
Derived::__construct()
Test::__construct()
TestPriv::__construct()
DerivedPriv::__construct()

Fatal error: Cannot call private TestPriv::__constrcut() in %sctor_visibility.php on line %d
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com