1 --- php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c 2009/12/11 22:30:46 292003
2 +++ php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c 2009/12/14 03:44:33 292107
5 static int make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info * fci, zend_fcall_info_cache * fcc, int num_args TSRMLS_DC) /* {{{ */
7 - zval *object = NULL, **method = NULL;
8 - char *fname = NULL, *cname;
9 - zend_class_entry * ce = NULL, **pce;
10 - zend_function *function_handler;
12 - if (Z_TYPE_P(callable) == IS_ARRAY) {
13 - if (Z_ARRVAL_P(callable)->nNumOfElements < 2) {
14 - pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback" TSRMLS_CC);
17 - object = *(zval**)Z_ARRVAL_P(callable)->pListHead->pData;
18 - method = (zval**)Z_ARRVAL_P(callable)->pListHead->pListNext->pData;
19 + char *is_callable_error = NULL;
21 - if (Z_TYPE_P(object) == IS_STRING) { /* static call */
22 - if (zend_lookup_class(Z_STRVAL_P(object), Z_STRLEN_P(object), &pce TSRMLS_CC) == FAILURE) {
23 - pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied class does not exist" TSRMLS_CC);
29 - } else if (Z_TYPE_P(object) == IS_OBJECT) { /* object call */
30 - ce = Z_OBJCE_P(object);
31 + if (zend_fcall_info_init(callable, 0, fci, fcc, NULL, &is_callable_error TSRMLS_CC) == FAILURE) {
32 + if (is_callable_error) {
33 + pdo_raise_impl_error(stmt->dbh, stmt, "HY000", is_callable_error TSRMLS_CC);
34 + efree(is_callable_error);
36 - pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback; bogus object/class name" TSRMLS_CC);
40 - if (Z_TYPE_PP(method) != IS_STRING) {
41 - pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback; bogus method name" TSRMLS_CC);
44 - } else if (Z_TYPE_P(callable) == IS_STRING) {
48 - if (!method || !zend_is_callable(callable, 0, &fname TSRMLS_CC)) {
49 - pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback" TSRMLS_CC);
52 + pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function must be a valid callback" TSRMLS_CC);
57 - /* ATM we do not support array($obj, "CLASS::FUNC") or "CLASS_FUNC" */
59 - if ((fname = strstr(fname, "::")) == NULL) {
67 - if (zend_lookup_class(cname, strlen(cname), &pce TSRMLS_CC) == FAILURE) {
68 - pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied class does not exist" TSRMLS_CC);
72 - /* pce must be base of ce or ce itself */
73 - if (ce != *pce && !instanceof_function(ce, *pce TSRMLS_CC)) {
74 - pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied class has bogus lineage" TSRMLS_CC);
82 - zend_str_tolower_copy(fname, fname, strlen(fname));
83 - fci->function_table = ce ? &ce->function_table : EG(function_table);
84 - if (zend_hash_find(fci->function_table, fname, strlen(fname)+1, (void **)&function_handler) == FAILURE) {
85 - pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function does not exist" TSRMLS_CC);
88 - efree(cname ? cname : fname);
90 - fci->size = sizeof(zend_fcall_info);
91 - fci->function_name = NULL;
92 - fci->symbol_table = NULL;
93 fci->param_count = num_args; /* probably less */
94 fci->params = safe_emalloc(sizeof(zval**), num_args, 0);
95 - fci->object_ptr = object;
97 - fcc->initialized = 1;
98 - fcc->function_handler = function_handler;
99 - fcc->calling_scope = EG(scope);
100 - fcc->called_scope = object ? Z_OBJCE_P(object) : NULL;
101 - fcc->object_ptr = object;
105 @@ -1568,7 +1493,9 @@
108 stmt->fetch.func.function = arg2;
109 - do_fetch_func_prepare(stmt TSRMLS_CC);
110 + if (do_fetch_func_prepare(stmt TSRMLS_CC) == 0) {