Skip to content

Commit

Permalink
the issue with inheritance of methods, which have been created by the…
Browse files Browse the repository at this point in the history
… runkit_method_rename, was fixed
  • Loading branch information
zenovich committed Jan 6, 2011
1 parent a476e31 commit f8daf39
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
9 changes: 6 additions & 3 deletions runkit_methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,6 @@ int php_runkit_update_children_methods(RUNKIT_53_TSRMLS_ARG(zend_class_entry *ce
}
}

/* Process children of this child */
zend_hash_apply_with_arguments(RUNKIT_53_TSRMLS_PARAM(EG(class_table)), (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, fe, fname, fname_len);

PHP_RUNKIT_FUNCTION_ADD_REF(fe);
if (zend_hash_add_or_update(&ce->function_table, fname_lower, fname_len + 1, fe, sizeof(zend_function), NULL, cfe ? HASH_UPDATE : HASH_ADD) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error updating child class");
Expand All @@ -280,6 +277,9 @@ int php_runkit_update_children_methods(RUNKIT_53_TSRMLS_ARG(zend_class_entry *ce

PHP_RUNKIT_ADD_MAGIC_METHOD(ce, fname, fe);

/* Process children of this child */
zend_hash_apply_with_arguments(RUNKIT_53_TSRMLS_PARAM(EG(class_table)), (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, fe, fname, fname_len);

efree(fname_lower);
return ZEND_HASH_APPLY_KEEP;
}
Expand Down Expand Up @@ -655,6 +655,9 @@ methodname_len);

efree(newname_lower);
PHP_RUNKIT_ADD_MAGIC_METHOD(ce, newname, fe);

zend_hash_apply_with_arguments(RUNKIT_53_TSRMLS_PARAM(EG(class_table)), (apply_func_args_t)php_runkit_update_children_methods, 5, ce, ce, fe, newname, newname_len);

RETURN_TRUE;
}
/* }}} */
Expand Down
40 changes: 40 additions & 0 deletions tests/runkit_method_rename_inheritance.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--TEST--
runkit_method_rename() function and inheritance
--SKIPIF--
<?php if(!extension_loaded("runkit") || !RUNKIT_FEATURE_MANIPULATION) print "skip"; ?>
--INI--
error_reporting=E_ALL
display_errors=on
--FILE--
<?php
class runkit_class {
function runkit_original($a) {
echo "Runkit Original: a is $a\n";
}
}

class runkit_subclass extends runkit_class {
}

runkit_subclass::runkit_original(1);
runkit_method_rename('runkit_class','runkit_original','runkit_duplicate');
if (method_exists('runkit_subclass','runkit_original')) {
echo "Runkit Original still exists!\n";
}
runkit_subclass::runkit_duplicate(2);
runkit_method_rename('runkit_class','runkit_duplicate', 'runkitDuplicate');
if (method_exists('runkit_subclass','runkit_duplicate')) {
echo "Runkit Duplicate still exists!\n";
}
runkit_subclass::runkitDuplicate(3);
runkit_method_rename('runkit_class','runkitDuplicate', 'runkit_original');
if (method_exists('runkit_subclass','runkitDuplicate')) {
echo "RunkitDuplicate still exists!\n";
}
runkit_subclass::runkit_original(4);
?>
--EXPECT--
Runkit Original: a is 1
Runkit Original: a is 2
Runkit Original: a is 3
Runkit Original: a is 4

0 comments on commit f8daf39

Please sign in to comment.