diff options
Diffstat (limited to 'ext/pdo')
-rw-r--r-- | ext/pdo/pdo.c | 27 | ||||
-rw-r--r-- | ext/pdo/pdo_dbh.c | 12 | ||||
-rw-r--r-- | ext/pdo/pdo_sql_parser.c | 2 | ||||
-rw-r--r-- | ext/pdo/pdo_sql_parser.re | 2 | ||||
-rw-r--r-- | ext/pdo/pdo_sqlstate.c | 2 | ||||
-rw-r--r-- | ext/pdo/pdo_stmt.c | 41 | ||||
-rw-r--r-- | ext/pdo/tests/pdo_036.phpt | 5 | ||||
-rw-r--r-- | ext/pdo/tests/pdorow.phpt | 3 |
8 files changed, 32 insertions, 62 deletions
diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c index 77366f817d..20f71491be 100644 --- a/ext/pdo/pdo.c +++ b/ext/pdo/pdo.c @@ -32,8 +32,7 @@ #include "php_pdo_driver.h" #include "php_pdo_int.h" #include "zend_exceptions.h" - -static zend_class_entry *spl_ce_RuntimeException; +#include "ext/spl/spl_exceptions.h" zend_class_entry *pdo_dbh_ce, *pdo_dbstmt_ce, *pdo_row_ce; @@ -79,20 +78,9 @@ PDO_API char *php_pdo_str_tolower_dup(const char *src, int len) /* {{{ */ PDO_API zend_class_entry *php_pdo_get_exception_base(int root) /* {{{ */ { -#if defined(HAVE_SPL) if (!root) { - if (!spl_ce_RuntimeException) { - zend_class_entry *pce; - - if ((pce = zend_hash_str_find_ptr(CG(class_table), "runtimeexception", sizeof("RuntimeException") - 1))) { - spl_ce_RuntimeException = pce; - return pce; - } - } else { - return spl_ce_RuntimeException; - } + return spl_ce_RuntimeException; } -#endif return zend_ce_exception; } /* }}} */ @@ -128,14 +116,10 @@ const zend_function_entry pdo_functions[] = { /* }}} */ /* {{{ pdo_functions[] */ -#if ZEND_MODULE_API_NO >= 20050922 static const zend_module_dep pdo_deps[] = { -#ifdef HAVE_SPL ZEND_MOD_REQUIRED("spl") -#endif ZEND_MOD_END }; -#endif /* }}} */ /* {{{ pdo_module_entry */ @@ -175,7 +159,7 @@ static PHP_GINIT_FUNCTION(pdo) PDO_API int php_pdo_register_driver(pdo_driver_t *driver) /* {{{ */ { if (driver->api_version != PDO_DRIVER_API) { - zend_error(E_ERROR, "PDO: driver %s requires PDO API version %pd; this is PDO version %d", + zend_error(E_ERROR, "PDO: driver %s requires PDO API version " ZEND_ULONG_FMT "; this is PDO version %d", driver->driver_name, driver->api_version, PDO_DRIVER_API); return FAILURE; } @@ -206,7 +190,8 @@ pdo_driver_t *pdo_find_driver(const char *name, int namelen) /* {{{ */ PDO_API int php_pdo_parse_data_source(const char *data_source, zend_ulong data_source_len, struct pdo_data_src_parser *parsed, int nparams) /* {{{ */ { - int i, j; + zend_ulong i; + int j; int valstart = -1; int semi = -1; int optstart = 0; @@ -351,8 +336,6 @@ PHP_MINIT_FUNCTION(pdo) { zend_class_entry ce; - spl_ce_RuntimeException = NULL; - if (FAILURE == pdo_sqlstate_init_error_table()) { return FAILURE; } diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 0f2a2ba788..4411c681bd 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -141,7 +141,7 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt) /* {{{ */ } if (supp) { - message = strpprintf(0, "SQLSTATE[%s]: %s: %ld %s", *pdo_err, msg, native_code, supp); + message = strpprintf(0, "SQLSTATE[%s]: %s: " ZEND_LONG_FMT " %s", *pdo_err, msg, native_code, supp); } else { message = strpprintf(0, "SQLSTATE[%s]: %s", *pdo_err, msg); } @@ -438,10 +438,8 @@ static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt zval retval; fci.size = sizeof(zend_fcall_info); - fci.function_table = &dbstmt_ce->function_table; ZVAL_UNDEF(&fci.function_name); fci.object = Z_OBJ_P(object); - fci.symbol_table = NULL; fci.retval = &retval; fci.param_count = 0; fci.params = NULL; @@ -451,7 +449,7 @@ static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt fcc.initialized = 1; fcc.function_handler = dbstmt_ce->constructor; - fcc.calling_scope = EG(scope); + fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = Z_OBJCE_P(object); fcc.object = Z_OBJ_P(object); @@ -1250,7 +1248,7 @@ const zend_function_entry pdo_dbh_functions[] = /* {{{ */ { PHP_ME(PDO, __wakeup, arginfo_pdo__void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) PHP_ME(PDO, __sleep, arginfo_pdo__void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) PHP_ME(PDO, getAvailableDrivers, arginfo_pdo__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - {NULL, NULL, NULL} + PHP_FE_END }; /* }}} */ @@ -1313,7 +1311,7 @@ int pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind) func.arg_info = (zend_internal_arg_info*)funcs->arg_info + 1; func.num_args = funcs->num_args; - if (info->required_num_args == -1) { + if (info->required_num_args == (uint32_t)-1) { func.required_num_args = funcs->num_args; } else { func.required_num_args = info->required_num_args; @@ -1434,9 +1432,7 @@ void pdo_dbh_init(void) REGISTER_PDO_CLASS_CONST_LONG("FETCH_KEY_PAIR", (zend_long)PDO_FETCH_KEY_PAIR); REGISTER_PDO_CLASS_CONST_LONG("FETCH_CLASSTYPE", (zend_long)PDO_FETCH_CLASSTYPE); -#if PHP_VERSION_ID >= 50100 REGISTER_PDO_CLASS_CONST_LONG("FETCH_SERIALIZE",(zend_long)PDO_FETCH_SERIALIZE); -#endif REGISTER_PDO_CLASS_CONST_LONG("FETCH_PROPS_LATE", (zend_long)PDO_FETCH_PROPS_LATE); REGISTER_PDO_CLASS_CONST_LONG("FETCH_NAMED", (zend_long)PDO_FETCH_NAMED); diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c index 0095c3d8dc..573d5865a0 100644 --- a/ext/pdo/pdo_sql_parser.c +++ b/ext/pdo/pdo_sql_parser.c @@ -400,7 +400,7 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len Scanner s; char *ptr, *newbuffer; int t; - int bindno = 0; + uint32_t bindno = 0; int ret = 0; size_t newbuffer_len; HashTable *params; diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index 3279b47056..20b9976850 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -86,7 +86,7 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len Scanner s; char *ptr, *newbuffer; int t; - int bindno = 0; + uint32_t bindno = 0; int ret = 0; size_t newbuffer_len; HashTable *params; diff --git a/ext/pdo/pdo_sqlstate.c b/ext/pdo/pdo_sqlstate.c index 24ed49b414..c40f8c1835 100644 --- a/ext/pdo/pdo_sqlstate.c +++ b/ext/pdo/pdo_sqlstate.c @@ -311,7 +311,7 @@ void pdo_sqlstate_fini_error_table(void) int pdo_sqlstate_init_error_table(void) { - int i; + size_t i; const struct pdo_sqlstate_info *info; zend_hash_init(&err_hash, sizeof(err_initializer)/sizeof(err_initializer[0]), NULL, NULL, 1); diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 0ff8a04000..7aaf76453b 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -113,12 +113,6 @@ ZEND_END_ARG_INFO() RETURN_FALSE; \ } \ -static PHP_FUNCTION(dbrow_constructor) /* {{{ */ -{ - zend_throw_exception_ex(php_pdo_get_exception(), 0, "You may not create a PDORow manually"); -} -/* }}} */ - static inline int rewrite_name_to_position(pdo_stmt_t *stmt, struct pdo_bound_param_data *param) /* {{{ */ { if (stmt->bound_param_map) { @@ -551,7 +545,7 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ col = &stmt->columns[colno]; type = PDO_PARAM_TYPE(col->param_type); - new_type = type_override ? PDO_PARAM_TYPE(*type_override) : type; + new_type = type_override ? (int)PDO_PARAM_TYPE(*type_override) : type; value = NULL; value_len = 0; @@ -740,9 +734,7 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt) /* {{{ */ } if (ce->constructor) { - fci->function_table = &ce->function_table; ZVAL_UNDEF(&fci->function_name); - fci->symbol_table = NULL; fci->retval = &stmt->fetch.cls.retval; fci->param_count = 0; fci->params = NULL; @@ -752,7 +744,7 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt) /* {{{ */ fcc->initialized = 1; fcc->function_handler = ce->constructor; - fcc->calling_scope = EG(scope); + fcc->calling_scope = zend_get_executed_scope(); fcc->called_scope = ce; return 1; } else if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args)) { @@ -1539,10 +1531,11 @@ static PHP_METHOD(PDOStatement, fetchAll) static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int is_param) /* {{{ */ { - struct pdo_bound_param_data param = {{{0}}}; + struct pdo_bound_param_data param; zend_long param_type = PDO_PARAM_STR; zval *parameter, *driver_params = NULL; + memset(¶m, 0, sizeof(param)); param.paramno = -1; if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), @@ -1582,11 +1575,12 @@ static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, bind an input parameter to the value of a PHP variable. $paramno is the 1-based position of the placeholder in the SQL statement (but can be the parameter name for drivers that support named placeholders). It should be called prior to execute(). */ static PHP_METHOD(PDOStatement, bindValue) { - struct pdo_bound_param_data param = {{{0}}}; + struct pdo_bound_param_data param; zend_long param_type = PDO_PARAM_STR; zval *parameter; PHP_STMT_GET_OBJ; + memset(¶m, 0, sizeof(param)); param.paramno = -1; if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), @@ -2125,7 +2119,7 @@ static PHP_METHOD(PDOStatement, debugDumpParams) php_stream_printf(out, "Key: Name: [%zd] %.*s\n", ZSTR_LEN(key), (int) ZSTR_LEN(key), ZSTR_VAL(key)); } else { - php_stream_printf(out, "Key: Position #%pd:\n", num); + php_stream_printf(out, "Key: Position #" ZEND_ULONG_FMT ":\n", num); } php_stream_printf(out, "paramno=%pd\nname=[%zd] \"%.*s\"\nis_param=%d\nparam_type=%d\n", @@ -2179,7 +2173,7 @@ const zend_function_entry pdo_dbstmt_functions[] = { PHP_ME(PDOStatement, debugDumpParams, arginfo_pdostatement__void, ZEND_ACC_PUBLIC) PHP_ME(PDOStatement, __wakeup, arginfo_pdostatement__void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) PHP_ME(PDOStatement, __sleep, arginfo_pdostatement__void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) - {NULL, NULL, NULL} + PHP_FE_END }; /* {{{ overloaded handlers for PDOStatement class */ @@ -2451,6 +2445,7 @@ static zend_object_iterator_funcs pdo_stmt_iter_funcs = { pdo_stmt_iter_get_data, pdo_stmt_iter_get_key, pdo_stmt_iter_move_forwards, + NULL, NULL }; @@ -2483,7 +2478,7 @@ zend_object_iterator *pdo_stmt_iter_get(zend_class_entry *ce, zval *object, int /* {{{ overloaded handlers for PDORow class (used by PDO_FETCH_LAZY) */ const zend_function_entry pdo_row_functions[] = { - {NULL, NULL, NULL} + PHP_FE_END }; static zval *row_prop_read(zval *object, zval *member, int type, void **cache_slot, zval *rv) @@ -2645,15 +2640,8 @@ static int row_call_method(zend_string *method, zend_object *object, INTERNAL_FU static union _zend_function *row_get_ctor(zend_object *object) { - static zend_internal_function ctor = {0}; - - ctor.type = ZEND_INTERNAL_FUNCTION; - ctor.function_name = zend_string_init("__construct", sizeof("__construct") - 1, 0); - ctor.scope = pdo_row_ce; - ctor.handler = ZEND_FN(dbrow_constructor); - ctor.fn_flags = ZEND_ACC_PUBLIC; - - return (union _zend_function*)&ctor; + zend_throw_exception_ex(php_pdo_get_exception(), 0, "You may not create a PDORow manually"); + return NULL; } static zend_string *row_get_classname(const zend_object *object) @@ -2689,6 +2677,11 @@ zend_object_handlers pdo_row_object_handlers = { row_get_classname, row_compare, NULL, /* cast */ + NULL, + NULL, + NULL, + NULL, + NULL, NULL }; diff --git a/ext/pdo/tests/pdo_036.phpt b/ext/pdo/tests/pdo_036.phpt index 61f0e49a1c..1bf369b33b 100644 --- a/ext/pdo/tests/pdo_036.phpt +++ b/ext/pdo/tests/pdo_036.phpt @@ -22,7 +22,6 @@ object(PDOStatement)#%d (1) { Fatal error: Uncaught PDOException: You may not create a PDORow manually in %spdo_036.php:8 Stack trace: -#0 [internal function]: PDORow->__construct() -#1 %spdo_036.php(8): ReflectionClass->newInstance() -#2 {main} +#0 %spdo_036.php(8): ReflectionClass->newInstance() +#1 {main} thrown in %spdo_036.php on line 8 diff --git a/ext/pdo/tests/pdorow.phpt b/ext/pdo/tests/pdorow.phpt index 7cd1198838..54850d3860 100644 --- a/ext/pdo/tests/pdorow.phpt +++ b/ext/pdo/tests/pdorow.phpt @@ -11,6 +11,5 @@ new PDORow; --EXPECTF-- Fatal error: Uncaught PDOException: You may not create a PDORow manually in %spdorow.php:3 Stack trace: -#0 %spdorow.php(3): PDORow->__construct() -#1 {main} +#0 {main} thrown in %spdorow.php on line 3 |