summaryrefslogtreecommitdiff
path: root/ext/pdo
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo')
-rw-r--r--ext/pdo/Makefile.frag3
-rwxr-xr-xext/pdo/config.m42
-rwxr-xr-xext/pdo/config.w322
-rw-r--r--ext/pdo/pdo_dbh.c32
-rw-r--r--ext/pdo/pdo_stmt.c20
-rw-r--r--ext/pdo/php_pdo_error.h47
-rw-r--r--ext/pdo/php_pdo_int.h15
-rw-r--r--ext/pdo/tests/bug_39656.phpt2
8 files changed, 66 insertions, 57 deletions
diff --git a/ext/pdo/Makefile.frag b/ext/pdo/Makefile.frag
index 5ba5f80840..dc25c9f70b 100644
--- a/ext/pdo/Makefile.frag
+++ b/ext/pdo/Makefile.frag
@@ -2,7 +2,8 @@ phpincludedir=$(prefix)/include/php
PDO_HEADER_FILES= \
php_pdo.h \
- php_pdo_driver.h
+ php_pdo_driver.h \
+ php_pdo_error.h
$(srcdir)/pdo_sql_parser.c: $(srcdir)/pdo_sql_parser.re
diff --git a/ext/pdo/config.m4 b/ext/pdo/config.m4
index f8515ddb1d..786c70382a 100755
--- a/ext/pdo/config.m4
+++ b/ext/pdo/config.m4
@@ -60,7 +60,7 @@ for more detail on this issue.
ifdef([PHP_INSTALL_HEADERS],
[
dnl Sadly, this is a complete NOP for pecl extensions
- PHP_INSTALL_HEADERS(ext/pdo, [php_pdo.h php_pdo_driver.h])
+ PHP_INSTALL_HEADERS(ext/pdo, [php_pdo.h php_pdo_driver.h php_pdo_error.h])
])
dnl so we always include the known-good working hack.
diff --git a/ext/pdo/config.w32 b/ext/pdo/config.w32
index c85f2e55e4..b026590980 100755
--- a/ext/pdo/config.w32
+++ b/ext/pdo/config.w32
@@ -6,5 +6,5 @@ ARG_ENABLE("pdo", "Enable PHP Data Objects support", "no");
if (PHP_PDO != "no") {
EXTENSION('pdo', 'pdo.c pdo_dbh.c pdo_stmt.c pdo_sql_parser.c pdo_sqlstate.c', false /* force static, PHP_PDO_SHARED is broken yet somehow */);
ADD_EXTENSION_DEP('pdo', 'spl', true);
- PHP_INSTALL_HEADERS("ext/pdo", "php_pdo.h php_pdo_driver.h");
+ PHP_INSTALL_HEADERS("ext/pdo", "php_pdo.h php_pdo_driver.h php_pdo_error.h");
}
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index 3444dcdfe0..6857a9b5e6 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -101,7 +101,7 @@ void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate
}
/* }}} */
-void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
+PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
{
pdo_error_type *pdo_err = &dbh->error_code;
const char *msg = "<<Unknown>>";
@@ -468,23 +468,11 @@ static void pdo_stmt_construct(pdo_stmt_t *stmt, zval *object, zend_class_entry
fci.object_ptr = object;
fci.symbol_table = NULL;
fci.retval_ptr_ptr = &retval;
- if (ctor_args) {
- HashTable *ht = Z_ARRVAL_P(ctor_args);
- Bucket *p;
-
- fci.param_count = 0;
- fci.params = safe_emalloc(sizeof(zval*), ht->nNumOfElements, 0);
- p = ht->pListHead;
- while (p != NULL) {
- fci.params[fci.param_count++] = (zval**)p->pData;
- p = p->pListNext;
- }
- } else {
- fci.param_count = 0;
- fci.params = NULL;
- }
+ fci.params = NULL;
fci.no_separation = 1;
+ zend_fcall_info_args(&fci, ctor_args TSRMLS_CC);
+
fcc.initialized = 1;
fcc.function_handler = dbstmt_ce->constructor;
fcc.calling_scope = EG(scope);
@@ -506,7 +494,7 @@ static void pdo_stmt_construct(pdo_stmt_t *stmt, zval *object, zend_class_entry
}
/* }}} */
-/* {{{ proto object PDO::prepare(string statment [, array options])
+/* {{{ proto object PDO::prepare(string statement [, array options])
Prepares a statement for execution and returns a statement object */
static PHP_METHOD(PDO, prepare)
{
@@ -1328,16 +1316,12 @@ int pdo_hash_methods(pdo_dbh_t *dbh, int kind TSRMLS_DC)
} else {
ifunc->required_num_args = info->required_num_args;
}
- if (info->pass_rest_by_reference) {
- if (info->pass_rest_by_reference == ZEND_SEND_PREFER_REF) {
- ifunc->fn_flags |= ZEND_ACC_PASS_REST_PREFER_REF;
- } else {
- ifunc->fn_flags |= ZEND_ACC_PASS_REST_BY_REFERENCE;
- }
- }
if (info->return_reference) {
ifunc->fn_flags |= ZEND_ACC_RETURN_REFERENCE;
}
+ if (funcs->arg_info[funcs->num_args].is_variadic) {
+ ifunc->fn_flags |= ZEND_ACC_VARIADIC;
+ }
} else {
ifunc->arg_info = NULL;
ifunc->num_args = 0;
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index bee66538b1..5e2186a208 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -757,23 +757,11 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
fci->function_name = NULL;
fci->symbol_table = NULL;
fci->retval_ptr_ptr = &stmt->fetch.cls.retval_ptr;
- if (stmt->fetch.cls.ctor_args) {
- HashTable *ht = Z_ARRVAL_P(stmt->fetch.cls.ctor_args);
- Bucket *p;
-
- fci->param_count = 0;
- fci->params = safe_emalloc(sizeof(zval**), ht->nNumOfElements, 0);
- p = ht->pListHead;
- while (p != NULL) {
- fci->params[fci->param_count++] = (zval**)p->pData;
- p = p->pListNext;
- }
- } else {
- fci->param_count = 0;
- fci->params = NULL;
- }
+ fci->params = NULL;
fci->no_separation = 1;
+ zend_fcall_info_args(fci, stmt->fetch.cls.ctor_args TSRMLS_CC);
+
fcc->initialized = 1;
fcc->function_handler = ce->constructor;
fcc->calling_scope = EG(scope);
@@ -2052,7 +2040,7 @@ static PHP_METHOD(PDOStatement, setFetchMode)
/* }}} */
/* {{{ proto bool PDOStatement::nextRowset()
- Advances to the next rowset in a multi-rowset statement handle. Returns true if it succeded, false otherwise */
+ Advances to the next rowset in a multi-rowset statement handle. Returns true if it succeeded, false otherwise */
static int pdo_stmt_do_next_rowset(pdo_stmt_t *stmt TSRMLS_DC)
{
diff --git a/ext/pdo/php_pdo_error.h b/ext/pdo/php_pdo_error.h
new file mode 100644
index 0000000000..020e6c554b
--- /dev/null
+++ b/ext/pdo/php_pdo_error.h
@@ -0,0 +1,47 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2015 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Wez Furlong <wez@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef PHP_PDO_ERROR_H
+#define PHP_PDO_ERROR_H
+
+#include "php_pdo_driver.h"
+
+PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC);
+
+#define PDO_DBH_CLEAR_ERR() do { \
+ strlcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
+ if (dbh->query_stmt) { \
+ dbh->query_stmt = NULL; \
+ zend_objects_store_del_ref(&dbh->query_stmt_zval TSRMLS_CC); \
+ } \
+} while (0)
+#define PDO_STMT_CLEAR_ERR() strcpy(stmt->error_code, PDO_ERR_NONE)
+#define PDO_HANDLE_DBH_ERR() if (strcmp(dbh->error_code, PDO_ERR_NONE)) { pdo_handle_error(dbh, NULL TSRMLS_CC); }
+#define PDO_HANDLE_STMT_ERR() if (strcmp(stmt->error_code, PDO_ERR_NONE)) { pdo_handle_error(stmt->dbh, stmt TSRMLS_CC); }
+
+#endif /* PHP_PDO_ERROR_H */
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/pdo/php_pdo_int.h b/ext/pdo/php_pdo_int.h
index 216c5f48c0..54ea2d657f 100644
--- a/ext/pdo/php_pdo_int.h
+++ b/ext/pdo/php_pdo_int.h
@@ -23,6 +23,8 @@
/* Stuff private to the PDO extension and not for consumption by PDO drivers
* */
+#include "php_pdo_error.h"
+
extern HashTable pdo_driver_hash;
extern zend_class_entry *pdo_exception_ce;
PDO_API zend_class_entry *php_pdo_get_exception_base(int root TSRMLS_DC);
@@ -55,19 +57,6 @@ zend_object_iterator *php_pdo_dbstmt_iter_get(zend_class_entry *ce, zval *object
extern pdo_driver_t *pdo_find_driver(const char *name, int namelen);
-extern void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC);
-
-#define PDO_DBH_CLEAR_ERR() do { \
- strlcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
- if (dbh->query_stmt) { \
- dbh->query_stmt = NULL; \
- zend_objects_store_del_ref(&dbh->query_stmt_zval TSRMLS_CC); \
- } \
-} while (0)
-#define PDO_STMT_CLEAR_ERR() strcpy(stmt->error_code, PDO_ERR_NONE)
-#define PDO_HANDLE_DBH_ERR() if (strcmp(dbh->error_code, PDO_ERR_NONE)) { pdo_handle_error(dbh, NULL TSRMLS_CC); }
-#define PDO_HANDLE_STMT_ERR() if (strcmp(stmt->error_code, PDO_ERR_NONE)) { pdo_handle_error(stmt->dbh, stmt TSRMLS_CC); }
-
int pdo_sqlstate_init_error_table(void);
void pdo_sqlstate_fini_error_table(void);
const char *pdo_sqlstate_state_to_description(char *state);
diff --git a/ext/pdo/tests/bug_39656.phpt b/ext/pdo/tests/bug_39656.phpt
index 7d113ef4aa..9ee54916bb 100644
--- a/ext/pdo/tests/bug_39656.phpt
+++ b/ext/pdo/tests/bug_39656.phpt
@@ -1,5 +1,5 @@
--TEST--
-PDO Common: Bug #39656 (Crash when calling fetch() on a PDO statment object after closeCursor())
+PDO Common: Bug #39656 (Crash when calling fetch() on a PDO statement object after closeCursor())
--SKIPIF--
<?php
if (!extension_loaded('pdo')) die('skip');