php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56408 Unable to override class definitions of a derived class
Submitted: 2005-06-02 23:14 UTC Modified: 2009-03-24 02:21 UTC
From: msaladna at apisnetworks dot com Assigned: mlively (profile)
Status: Closed Package: runkit (PECL)
PHP Version: 5.0.3 OS: Redhat Linux 3ES
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: msaladna at apisnetworks dot com
New email:
PHP Version: OS:

 

 [2005-06-02 23:14 UTC] msaladna at apisnetworks dot com
Description:
------------
affects runkit 0.2:

The following code will fail when attempting to override the class via runkit_import(); however, if the class is derived from a base class via runkit_class_adopt such as runkit_class_adopt('Foo','Bar') for example, then the class can be overwritten without issue.


Here is the configuration line:

'./configure' '--host=i386-redhat-linux' '--build=i386-redhat-linux' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--enable-force-cgi-redirect' '--disable-debug' '--enable-pic' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-db4=/usr' '--with-curl' '--with-dom=/usr' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-ttf' '--with-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp' '--with-iconv' '--enable-pcntl' '--with-mysqli' '--with-jpeg-dir=/usr' '--with-openssl' '--enable-cli' '--with-png' '--with-pspell' '--with-regex=system' '--with-xml' '--with-expat-dir=/usr' '--with-pcre=/usr' '--with-zlib' '--with-layout=GNU' '--enable-bcmath' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sigchild' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--without-oci8' '--with-pear=/usr/share/pear' '--with-imap' '--with-imap-ssl' '--with-kerberos=/usr/kerberos' '--with-mysql=/usr' '--with-pgsql' '--with-unixODBC' '--enable-memory-limit' '--enable-bcmath' '--enable-shmop' '--disable-versioning' '--enable-calendar' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-regex=system' '--with-xml' '--enable-sysvmsg' '--enable-sysvshm' '--enable-sysvsem' '--enable-soap' '--with-libxml' '--with-expat-dir=/usr' '--with-pcre=/usr' '--with-zlib' '--with-layout=GNU' '--enable-bcmath' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--without-oci8' '--with-pear=/usr/share/pear' '--with-imap' '--with-imap-ssl' '--with-kerberos=/usr/kerberos' '--with-mysql=/usr' '--with-pgsql' '--with-unixODBC' '--enable-memory-limit' '--enable-bcmath' '--enable-shmop' '--enable-versioning' '--enable-calendar' '--enable-dbx' '--enable-dio' '--enable-mcal' '--with-apxs2=/usr/sbin/apxs' '--with-db4' '--enable-memory-limit' '--enable-maintainer-zts' '--program-suffix=5' '--with-config-file-path=/etc/php5' '--with-curl' '--with-mcrypt'

Reproduce code:
---------------
File testclass.php:
<?php
   class Foo extends Bar {
     public function a() { print "Hello World!\n"; }
   }
   
   class Bar {
     public function b() { print "Hello World from Bar!\n"; }
   }
?>

File test.php:

<?php
   include('testclass.php');
   $test = new Foo();
   print($test->b());
   runkit_import('testclass.php', RUNKIT_IMPORT_OVERRIDE);
   $test2 = new Foo();
   print($test2->b());
?>

Expected result:
----------------
Hello World from Bar!
Hello World from Bar!


Actual result:
--------------
Hello World from Bar!
Fatal error: Cannot redeclare class foo in testclass.php on line 4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-02 23:29 UTC] msaladna at apisnetworks dot com
I'm not sure what I was thinking with the configure line; here's the proper one:


'./configure' '--enable-runkit=classkit' '--enable-maintainer-zts'
 [2005-06-03 20:19 UTC] pollita@php.net
The fix may be a little slow coming, but I've got an idea in mind...
 [2007-09-26 04:06 UTC] srfed at gdfh dot hf
http://www.meta-fx.com
forex   ??ј?
 [2008-06-22 11:36 UTC] mlively@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 [2009-03-23 23:50 UTC] sam dot kuper at uclmail dot net
I just tried compiling runkit on Mac OS X 10.5. When I ran 
'make test', I got the following:

============================================================
=========
FAILED TEST SUMMARY
------------------------------------------------------------
---------
Bug #4519 Unable to override class definitions of a derived 
class [tests/bug4519.phpt]
============================================================
=========
 [2009-03-24 02:21 UTC] philip at roshambo dot org
This test has been fixed in CVS.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC