zenovich / runkit

Runkit (official PECL PHP Runkit extension)
http://pecl.php.net/runkit
Other
610 stars 136 forks source link

Crashes with runkit_function_rename() on internal functions on php-mod mode #63

Closed baptistepillot closed 9 years ago

baptistepillot commented 10 years ago
echo "function exists ? " . function_exists('_chop') . "<br>";
echo chop("[ A WORD ") . "]<br>";
if (function_exists('_chop')) echo _chop("[ ANOTHER WORD ") . "]<br>";
runkit_function_rename('chop', '_chop');

If I refresh the page executing this script quickly (less than 5 seconds, as apache can use the same process for the next script execution than the previous one) :

function exists ? 
[ A WORD]
function exists ? 1
[ A WORD]
[ ANOTHER WORD]

It looks like php kept in its memory the _chop function, that keep working well ! This is done with internal functions only. Php defined functions work well.

Tested and reproduced on several computers under xubuntu 13.10 using PHP 5.5.3, installed as an apache module (common use).

And you can make an runkit_method_delete('_chop') if you want : it will not be here for the current script, but will come back on the next execution using the same process !

I don't want to run php-cgi, sorry :)

baptistepillot commented 10 years ago

Wan't a "php patch" for this ? This code, begining all my scripts, removes automatically the renamed function but you will never have any error for already existing functions : they will be replaced !

if (function_exists('_runkit_function_rename')) {
    runkit_function_remove('_runkit_function_rename');
}
runkit_function_rename('runkit_function_rename', '_runkit_function_rename');
runkit_function_add(
    'runkit_function_rename', '$function_name, $new_name',
    '
        if (function_exists($new_name)) {
            runkit_function_remove($new_name);
        }
        return _runkit_function_rename($function_name, $new_name);
    '
);
zenovich commented 9 years ago

Fixed