Skip to content

Commit

Permalink
Fixed renaming of internal functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zenovich committed Oct 6, 2010
1 parent 0623a53 commit 8472200
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Execute code in restricted environment (sandboxing).
<file name="runkit_function_redefine.phpt" role="test" />
<file name="runkit_function_remove.phpt" role="test" />
<file name="runkit_function_rename.phpt" role="test" />
<file name="runkit_function_rename_redefine_add_remove.phpt" role="test" />
<file name="runkit_import_class.inc" role="test" />
<file name="runkit_import_class.phpt" role="test" />
<file name="runkit_import_class_property.inc" role="test" />
Expand Down
6 changes: 2 additions & 4 deletions runkit_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,8 @@ PHP_FUNCTION(runkit_function_rename)
RETURN_FALSE;
}

if (fe->type == ZEND_USER_FUNCTION) {
func = *fe;
PHP_RUNKIT_FUNCTION_ADD_REF(&func);
}
func = *fe;
PHP_RUNKIT_FUNCTION_ADD_REF(&func);

if (zend_hash_del(EG(function_table), sfunc, sfunc_len + 1) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error removing reference to old function name %s()", sfunc);
Expand Down
22 changes: 22 additions & 0 deletions tests/runkit_function_rename_redefine_add_remove.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
complex test for renaming, adding and removing with internal functions
--SKIPIF--
<?php if(!extension_loaded("runkit") || !RUNKIT_FEATURE_MANIPULATION) print "skip"; ?>
--INI--
error_reporting=E_ALL
display_errors=on
runkit.internal_override="1"
--FILE--
<?php
runkit_function_rename('rand', 'oldRand');
echo oldRand(), "\n";
runkit_function_add('rand', '', 'return "a" . oldRand();');
echo rand(), "\n";
runkit_function_remove('rand');
runkit_function_rename('oldRand', 'rand');
echo rand(), "\n";
?>
--EXPECTF--
%d
a%d
%d

0 comments on commit 8472200

Please sign in to comment.