php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57749 Fatal error "Cannot redeclare" when using runkit_function_redefine
Submitted: 2007-07-18 05:15 UTC Modified: 2013-02-23 18:56 UTC
From: bogdan at acunetix dot com Assigned: pollita (profile)
Status: Closed Package: runkit (PECL)
PHP Version: 5.2.1 OS: Ubuntu
Private report: No CVE-ID: None
 [2007-07-18 05:15 UTC] bogdan at acunetix dot com
Description:
------------
affects runkit 0.9:

I'm using runkit_function_redefine to redefine a system function (passthru). I would like to be able to intercept the parameters passed to this function in old_passthru.
For some files, the code bellow is working great. 

However, if you have an PHP file with any function defined, runkit returns an Fatal error: Cannot redeclare my_function().
If the function is commented out, it's working fine.


Reproduce code:
---------------
File /var/www/tr/index.php
---------------
<?php

function my_function() {
}	
	
// redefine passthru
runkit_function_copy('passthru','old_passthru');
runkit_function_redefine(
'passthru',    // function to redefine
'',			   // number of parameters		
			   // code	
'
$args = func_get_args();
echo "<b>passthru</b> params = [<b>" .  func_get_arg (0) . "</b>]<br>";
return call_user_func_array("old_passthru", $args);
'
);

// call passthru
passthru("ls");

?>

<i><br>
this is html already
</i>	


Expected result:
----------------
passthru params = [ls]
index.php phpinfo.php runkit.php
this is html already

Actual result:
--------------
Fatal error: Cannot redeclare my_function() (previously declared in /var/www/tr/index.php:4) in /var/www/tr/index.php on line 4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-05 16:02 UTC] dzenovich at gmail dot com
The solution of this issue can be found here:

http://github.com/zenovich/runkit/commit/ffa9a187c6ac2d14244b766fd58581cff1d0a975
 [2009-11-06 04:51 UTC] dzenovich at gmail dot com
Here is a fix for zts
http://github.com/zenovich/runkit/commit/f60ed0caef37b1d9299ab8727d552f8dcc9af14c
 [2013-02-23 18:56 UTC] pollita@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: pollita
 [2013-02-23 18:56 UTC] pollita@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

This should be fixed by: https://github.com/php/pecl-php-
runkit/commit/ad37fa3b5810a3a679bae4c375c8c86be7cce78c
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 14 18:01:28 2024 UTC