cvs: pecl /classkit classkit.c
| From: | Sara Golemon | Date: | Sat, 21 Aug 2004 17:19:24 +0000 |
| Subject: | cvs: pecl /classkit classkit.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-1698@lists.php.net to get a copy of this message | ||
pollita Sat Aug 21 13:19:24 2004 EDT
Modified files:
/pecl/classkit classkit.c
Log:
Checking the active function isn't enough.
We need to traverse the entire execution stack
otherwise we might kill a method that we'll return to later.
http://cvs.php.net/diff.php/pecl/classkit/classkit.c?r1=1.2&r2=1.3&ty=u
Index: pecl/classkit/classkit.c
diff -u pecl/classkit/classkit.c:1.2 pecl/classkit/classkit.c:1.3
--- pecl/classkit/classkit.c:1.2 Sat Aug 21 07:47:14 2004
+++ pecl/classkit/classkit.c Sat Aug 21 13:19:24 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: classkit.c,v 1.2 2004/08/21 11:47:14 pollita Exp $ */
+/* $Id: classkit.c,v 1.3 2004/08/21 17:19:24 pollita Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -75,6 +75,25 @@
}
/* }}} */
+/* {{{ php_classkit_check_call_stack
+ */
+static int php_classkit_check_call_stack(zend_op_array *op_array TSRMLS_DC)
+{
+ zend_execute_data *ptr;
+
+ ptr = EG(current_execute_data);
+
+ while (ptr) {
+ if (ptr->op_array == op_array) {
+ return FAILURE;
+ }
+ ptr = ptr->prev_execute_data;
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
/* {{{ php_classkit_fetch_class
*/
static int php_classkit_fetch_class(char *classname, int classname_len, zend_class_entry **pce
TSRMLS_DC)
@@ -211,8 +230,8 @@
if (php_classkit_fetch_class_method(classname, classname_len, methodname, methodname_len,
&ce, &fe TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
}
- if (&fe->op_array == EG(active_op_array)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot redefine a method from inside
itself!");
+ if (php_classkit_check_call_stack(&fe->op_array TSRMLS_CC) == FAILURE) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot redefine a method while that method is
active.");
RETURN_FALSE;
}
} else {
@@ -329,8 +348,8 @@
RETURN_FALSE;
}
- if (&fe->op_array == EG(active_op_array)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot remove a method while inside it!");
+ if (php_classkit_check_call_stack(&fe->op_array TSRMLS_CC) == FAILURE) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot remove a method while it is
active");
RETURN_FALSE;
}
@@ -376,8 +395,8 @@
RETURN_FALSE;
}
- if (&fe->op_array == EG(active_op_array)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot rename a method while inside it!");
+ if (php_classkit_check_call_stack(&fe->op_array TSRMLS_CC) == FAILURE) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot rename a method while it is
active");
RETURN_FALSE;
}