ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-Dev
php-Dev
[PHP-DEV] Re: Bug #12560 Updated: 'parent' incorrectly refers to $this in certain cases
by Nick Lindridge other posts by this author
Oct 22 2001 7:14PM messages near this date
[PHP-DEV] Bug #13791 Updated: just a test. ignore. | [PHP-DEV] CVS Account Request: jim
On Mon, Oct 22, 2001 at 12:03:59AM -0000, Bug Database wrote:
>  ID: 12560
>  Updated by: sniper
>  Reported By: nick@[...].uk
>  Old Status: Open
>  Status: Closed
>  Bug Type: Class/Object related
>  Operating System: Solaris 2.7
>  PHP Version: 4.0.6
>  New Comment:
>  
>  Works for me just fine with PHP 4.1.0RC1

Great, so you've fixed it then. Well done!

>  
>  
>  Previous Comments:
>  ------------------------------------------------------------------------
>  
>  [2001-08-03 13:51:21] nick@[...].uk
>  
>  This bug occurred with Solaris 2.7 and a regular build of php as a standalone app. I haven
't tested on Linux yet.
>  
>  If the base class of a few levels of inheritance is in an included or required file, then 
'parent' may be incorrectly setup. Calls via 'parent' will actually call $this, and then giv
e incorrect and most likely disastrous behaviour.
>  
>  The following example will quickly crash due to stack overflow from infinite recursion, wh
ereas inlining the base class 'X' rather than including it will work as expected.
>  
>  Incidentally, instantiating a B rather than a C will work correctly in both cases.
>  
>  File X.php:
>  
>  <?php
>  
>  class X
>  {
>        function X() { }
>  }
>  
>  ?>
>  
>  File crashme.php:
>  
>  <?php
>  
>  // Commenting out include and uncommenting class X
>  // below will work, whilst including X will crash
>  
>  include_once 'X.php';
>  
>  
>  /*
>  class X
>  {
>        function X() { }
>  }
>  */
>  
>  class A extends X
>  {
>        function A() { $this->X(); }
>  
>        function crash_me() { }
>  }
>  
>  class B extends A
>  {
>        function B() { $this->A(); }
>    
>        function crash_me() { parent::crash_me(); }
>  }
>  
>  class C extends B
>  {
>        function C() { $this->B(); }
>  }
>  
>  $r = new C();
>  $r->crash_me();
>  
>  ?>
>  
>  
>  
>  
>  ------------------------------------------------------------------------
>  
>  
>  
>  ATTENTION! Do NOT reply to this email!
>  To reply, use the web interface found at http://bugs.php.net/?id=12560&edit=2

-- 
PHP Development Mailing List <http://www.php.net/> 
To unsubscribe, e-mail: php-dev-unsubscribe@[...].net
For additional commands, e-mail: php-dev-help@[...].net
To contact the list administrators, e-mail: php-list-admin@lists.php.net

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved