Skip to content

Commit

Permalink
Can use runkit_method_* on internal classes
Browse files Browse the repository at this point in the history
  • Loading branch information
baptistepillot committed Feb 1, 2014
1 parent 82f3fe0 commit 409e270
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions runkit_methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,14 @@ int php_runkit_fetch_class(const char *classname, int classname_len, zend_class_
return FAILURE;
}

if (ce->type != ZEND_USER_CLASS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "class %s is not a user-defined class", classname);
return FAILURE;
}
/*
* It works when commented, but you must undo everything you do on internal classes before the end of the
* PHP script, otherwise your php process will crash next scripts execution !
*/
// if (ce->type != ZEND_USER_CLASS) {
// php_error_docref(NULL TSRMLS_CC, E_WARNING, "class %s is not a user-defined class", classname);
// return FAILURE;
// }

#ifdef ZEND_ENGINE_2
if (ce->ce_flags & ZEND_ACC_INTERFACE) {
Expand Down Expand Up @@ -201,10 +205,14 @@ TSRMLS_DC)
return FAILURE;
}

if (ce->type != ZEND_USER_CLASS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "class %s is not a user-defined class", classname);
return FAILURE;
}
/*
* It works when commented, but you must undo everything you do on internal classes before the end of the
* PHP script, otherwise your php process will crash next scripts execution !
*/
// if (ce->type != ZEND_USER_CLASS) {
// php_error_docref(NULL TSRMLS_CC, E_WARNING, "class %s is not a user-defined class", classname);
// return FAILURE;
// }

if (pce) {
*pce = ce;
Expand All @@ -225,11 +233,15 @@ TSRMLS_DC)
return FAILURE;
}

if (fe->type != ZEND_USER_FUNCTION) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::%s() is not a user function", classname, fname);
efree(fname_lower);
return FAILURE;
}
/*
* It works when commented, but you must undo everything you do on internal classes before the end of the
* PHP script, otherwise your php process will crash next scripts execution !
*/
// if (fe->type != ZEND_USER_FUNCTION) {
// php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::%s() is not a user function", classname, fname);
// efree(fname_lower);
// return FAILURE;
// }

if (pfe) {
*pfe = fe;
Expand Down

1 comment on commit 409e270

@baptistepillot
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch enable you to change is dangerous : everything you change into internal methods must be undone before your php scripts ends, or you will have to restart apache to reload all running mod-php processes !
More info here (what issue does this patch "solve") : zenovich#60 (comment)

Please sign in to comment.