diff --git a/NEWS b/NEWS index 5921ce8febea3..8a7647c98359c 100644 --- a/NEWS +++ b/NEWS @@ -48,6 +48,9 @@ PHP NEWS . Implement #81724 (openssl_cms_encrypt only allows specific ciphers). (Jakub Zelenka) +- PDO: + . Driver specific constants in the PDO class are now deprecated. (Arnaud) + - Phar: . Fixed memory leaks when verifying OpenSSL signature. (Girgias) diff --git a/UPGRADING b/UPGRADING index 9ffb1896917e7..29335130e1b6a 100644 --- a/UPGRADING +++ b/UPGRADING @@ -427,6 +427,51 @@ PHP 8.5 UPGRADE NOTES . The "uri:" DSN scheme has been deprecated due to security concerns with DSNs coming from remote URIs. RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_pdo_s_urischeme + . Driver specific constants in the PDO class have been deprecated. + List of affected constants and their replacement: + PDO::DBLIB_ATTR_CONNECTION_TIMEOUT => Pdo\Dblib::ATTR_CONNECTION_TIMEOUT + PDO::DBLIB_ATTR_QUERY_TIMEOUT => Pdo\Dblib::ATTR_QUERY_TIMEOUT + PDO::DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER => Pdo\Dblib::ATTR_STRINGIFY_UNIQUEIDENTIFIER + PDO::DBLIB_ATTR_VERSION => Pdo\Dblib::ATTR_VERSION + PDO::DBLIB_ATTR_TDS_VERSION => Pdo\Dblib::ATTR_TDS_VERSION + PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS => Pdo\Dblib::ATTR_SKIP_EMPTY_ROWSETS + PDO::DBLIB_ATTR_DATETIME_CONVERT => Pdo\Dblib::ATTR_DATETIME_CONVERT + PDO::FB_ATTR_DATE_FORMAT => Pdo\Firebird::ATTR_DATE_FORMAT + PDO::FB_ATTR_TIME_FORMAT => Pdo\Firebird::ATTR_TIME_FORMAT + PDO::FB_ATTR_TIMESTAMP_FORMAT => Pdo\Firebird::ATTR_TIMESTAMP_FORMAT + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => Pdo\Mysql::ATTR_USE_BUFFERED_QUERY + PDO::MYSQL_ATTR_LOCAL_INFILE => Pdo\Mysql::ATTR_LOCAL_INFILE + PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY => Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY + PDO::MYSQL_ATTR_INIT_COMMAND => Pdo\Mysql::ATTR_INIT_COMMAND + PDO::MYSQL_ATTR_MAX_BUFFER_SIZE => Pdo\Mysql::ATTR_MAX_BUFFER_SIZE + PDO::MYSQL_ATTR_READ_DEFAULT_FILE => Pdo\Mysql::ATTR_READ_DEFAULT_FILE + PDO::MYSQL_ATTR_READ_DEFAULT_GROUP => Pdo\Mysql::ATTR_READ_DEFAULT_GROUP + PDO::MYSQL_ATTR_COMPRESS => Pdo\Mysql::ATTR_COMPRESS + PDO::MYSQL_ATTR_DIRECT_QUERY => Pdo\Mysql::ATTR_DIRECT_QUERY + PDO::MYSQL_ATTR_FOUND_ROWS => Pdo\Mysql::ATTR_FOUND_ROWS + PDO::MYSQL_ATTR_IGNORE_SPACE => Pdo\Mysql::ATTR_IGNORE_SPACE + PDO::MYSQL_ATTR_SSL_KEY => Pdo\Mysql::ATTR_SSL_KEY + PDO::MYSQL_ATTR_SSL_CERT => Pdo\Mysql::ATTR_SSL_CERT + PDO::MYSQL_ATTR_SSL_CA => Pdo\Mysql::ATTR_SSL_CA + PDO::MYSQL_ATTR_SSL_CAPATH => Pdo\Mysql::ATTR_SSL_CAPATH + PDO::MYSQL_ATTR_SSL_CIPHER => Pdo\Mysql::ATTR_SSL_CIPHER + PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => Pdo\Mysql::ATTR_SSL_VERIFY_SERVER_CERT + PDO::MYSQL_ATTR_SERVER_PUBLIC_KEY => Pdo\Mysql::ATTR_SERVER_PUBLIC_KEY + PDO::MYSQL_ATTR_MULTI_STATEMENTS => Pdo\Mysql::ATTR_MULTI_STATEMENTS + PDO::ODBC_ATTR_USE_CURSOR_LIBRARY => Pdo\Odbc::ATTR_USE_CURSOR_LIBRARY + PDO::ODBC_ATTR_ASSUME_UTF8 => Pdo\Odbc::ATTR_ASSUME_UTF8 + PDO::ODBC_SQL_USE_IF_NEEDED => Pdo\Odbc::SQL_USE_IF_NEEDED + PDO::ODBC_SQL_USE_DRIVER => Pdo\Odbc::SQL_USE_DRIVER + PDO::ODBC_SQL_USE_ODBC => Pdo\Odbc::SQL_USE_ODBC + PDO::PGSQL_ATTR_DISABLE_PREPARES => Pdo\Pgsql::ATTR_DISABLE_PREPARES + PDO::SQLITE_ATTR_EXTENDED_RESULT_CODES => Pdo\Sqlite::ATTR_EXTENDED_RESULT_CODES + PDO::SQLITE_ATTR_OPEN_FLAGS => Pdo\Sqlite::OPEN_FLAGS + PDO::SQLITE_ATTR_READONLY_STATEMENT => Pdo\Sqlite::ATTR_READONLY_STATEMENT + PDO::SQLITE_DETERMINISTIC => Pdo\Sqlite::DETERMINISTIC + PDO::SQLITE_OPEN_READONLY => Pdo\Sqlite::OPEN_READONLY + PDO::SQLITE_OPEN_READWRITE => Pdo\Sqlite::OPEN_READWRITE + PDO::SQLITE_OPEN_CREATE => Pdo\Sqlite::OPEN_CREATE + RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_driver_specific_pdo_constants_and_methods - Reflection: . The setAccessible() methods of various Reflection objects have been diff --git a/Zend/zend_constants.stub.php b/Zend/zend_constants.stub.php index 763b207641f69..6e791ca4abfd0 100644 --- a/Zend/zend_constants.stub.php +++ b/Zend/zend_constants.stub.php @@ -121,6 +121,12 @@ */ const ZEND_DEBUG_BUILD = UNKNOWN; +/** + * @var string + * @cvalue zend_vm_kind_name[ZEND_VM_KIND] + */ +const ZEND_VM_KIND = UNKNOWN; + /* Special constants true/false/null. */ /** diff --git a/Zend/zend_constants_arginfo.h b/Zend/zend_constants_arginfo.h index 04ccc3025f188..56cb3fe232a82 100644 --- a/Zend/zend_constants_arginfo.h +++ b/Zend/zend_constants_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 5e224893a5fb72b3f93249235c2a1634233ce505 */ + * Stub hash: bf2f959978bd6cbd7353ca7bfbb95718cdd51cff */ static void register_zend_constants_symbols(int module_number) { @@ -23,6 +23,7 @@ static void register_zend_constants_symbols(int module_number) REGISTER_LONG_CONSTANT("DEBUG_BACKTRACE_IGNORE_ARGS", DEBUG_BACKTRACE_IGNORE_ARGS, CONST_PERSISTENT); REGISTER_BOOL_CONSTANT("ZEND_THREAD_SAFE", ZTS_V, CONST_PERSISTENT); REGISTER_BOOL_CONSTANT("ZEND_DEBUG_BUILD", ZEND_DEBUG, CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("ZEND_VM_KIND", zend_vm_kind_name[ZEND_VM_KIND], CONST_PERSISTENT); REGISTER_BOOL_CONSTANT("TRUE", true, CONST_PERSISTENT); REGISTER_BOOL_CONSTANT("FALSE", false, CONST_PERSISTENT); REGISTER_NULL_CONSTANT("NULL", CONST_PERSISTENT); diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index cdb5ea3cd7783..eceb07f39020e 100755 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -143,6 +143,7 @@ ZEND_VM_KIND_SWITCH => "ZEND_VM_KIND_SWITCH", ZEND_VM_KIND_GOTO => "ZEND_VM_KIND_GOTO", ZEND_VM_KIND_HYBRID => "ZEND_VM_KIND_HYBRID", + ZEND_VM_KIND_TAILCALL => "ZEND_VM_KIND_TAILCALL", ); $op_types = array( @@ -845,7 +846,7 @@ function($matches) use ($spec, $prefix, $op1, $op2, $extra_spec, $name, $kind) { $handler = $matches[1]; $opcode = $opcodes[$opnames[$handler]]; $inline = - ZEND_VM_KIND == ZEND_VM_KIND_HYBRID && + ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID && isset($opcode["use"]) && is_hot_handler($opcode["hot"], $op1, $op2, $extra_spec) && is_hot_handler($opcodes[$opnames[$name]]["hot"], $op1, $op2, $extra_spec) ? @@ -1090,7 +1091,7 @@ function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno, case ZEND_VM_KIND_CALL: case ZEND_VM_KIND_TAILCALL: $cconv = $kind === ZEND_VM_KIND_TAILCALL ? 'ZEND_OPCODE_HANDLER_CCONV' : 'ZEND_OPCODE_HANDLER_FUNC_CCONV'; - if ($opcode["hot"] && ZEND_VM_KIND == ZEND_VM_KIND_HYBRID && is_hot_handler($opcode["hot"], $op1, $op2, $extra_spec)) { + if ($opcode["hot"] && ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID && is_hot_handler($opcode["hot"], $op1, $op2, $extra_spec)) { if (isset($opcode["use"])) { out($f,"static zend_always_inline ZEND_OPCODE_HANDLER_RET {$cconv} {$spec_name}_INLINE_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n"); $additional_func = true; @@ -1465,7 +1466,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array() switch ($kind) { case ZEND_VM_KIND_CALL: case ZEND_VM_KIND_TAILCALL: - out($f,$prolog."ZEND_NULL${variant}_HANDLER,\n"); + out($f,$prolog."ZEND_NULL{$variant}_HANDLER,\n"); break; case ZEND_VM_KIND_SWITCH: out($f,$prolog."-1,\n"); @@ -1512,7 +1513,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array() switch ($kind) { case ZEND_VM_KIND_CALL: case ZEND_VM_KIND_TAILCALL: - out($f,$prolog."ZEND_NULL${variant}_HANDLER,\n"); + out($f,$prolog."ZEND_NULL{$variant}_HANDLER,\n"); break; case ZEND_VM_KIND_SWITCH: out($f,$prolog."-1,\n"); @@ -2473,20 +2474,31 @@ function gen_vm_opcodes_header( $str .= "#define ZEND_VM_KIND_GOTO\t" . ZEND_VM_KIND_GOTO . "\n"; $str .= "#define ZEND_VM_KIND_HYBRID\t" . ZEND_VM_KIND_HYBRID . "\n"; $str .= "#define ZEND_VM_KIND_TAILCALL\t" . ZEND_VM_KIND_TAILCALL . "\n"; + $str .= <<opcode], opline);\n"); out($f, "\thandler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n"); @@ -3152,7 +3164,7 @@ function gen_vm($def, $skel) { out($f,"#else\n"); } out($f, "\t(OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n"); - if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) { + if (ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID) { out($f, "\tif (EXPECTED(opline)) {\n"); out($f,"#endif\n"); } else { @@ -3235,16 +3247,16 @@ function usage() { $kind = substr($argv[$i], strlen("--with-vm-kind=")); switch ($kind) { case "CALL": - define("ZEND_VM_KIND", ZEND_VM_KIND_CALL); + define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_CALL); break; case "SWITCH": - define("ZEND_VM_KIND", ZEND_VM_KIND_SWITCH); + define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_SWITCH); break; case "GOTO": - define("ZEND_VM_KIND", ZEND_VM_KIND_GOTO); + define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_GOTO); break; case "HYBRID": - define("ZEND_VM_KIND", ZEND_VM_KIND_HYBRID); + define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_HYBRID); break; default: echo("ERROR: Invalid vm kind '$kind'\n"); @@ -3268,9 +3280,9 @@ function usage() { } // Using defaults -if (!defined("ZEND_VM_KIND")) { +if (!defined("ZEND_VM_GEN_KIND")) { // Using CALL threading by default - define("ZEND_VM_KIND", ZEND_VM_KIND_HYBRID); + define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_HYBRID); } if (!defined("ZEND_VM_SPEC")) { // Using specialized executor by default diff --git a/Zend/zend_vm_opcodes.h b/Zend/zend_vm_opcodes.h index 900b029e2b112..287dec375f3a9 100644 --- a/Zend/zend_vm_opcodes.h +++ b/Zend/zend_vm_opcodes.h @@ -30,6 +30,14 @@ #define ZEND_VM_KIND_GOTO 3 #define ZEND_VM_KIND_HYBRID 4 #define ZEND_VM_KIND_TAILCALL 5 +static const char *const zend_vm_kind_name[] = { + NULL, + "ZEND_VM_KIND_CALL", + "ZEND_VM_KIND_SWITCH", + "ZEND_VM_KIND_GOTO", + "ZEND_VM_KIND_HYBRID", + "ZEND_VM_KIND_TAILCALL", +}; #if 0 /* HYBRID requires support for computed GOTO and global register variables*/ #elif (defined(__GNUC__) && defined(HAVE_GCC_GLOBAL_REGS)) diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c index b6d57739b2b9b..719b66767980f 100644 --- a/ext/filter/callback_filter.c +++ b/ext/filter/callback_filter.c @@ -16,7 +16,7 @@ #include "php_filter.h" -void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) +zend_result php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) { zval retval; int status; @@ -25,7 +25,7 @@ void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) zend_type_error("%s(): Option must be a valid callback", get_active_function_name()); zval_ptr_dtor(value); ZVAL_NULL(value); - return; + return SUCCESS; } status = call_user_function(NULL, NULL, option_array, &retval, 1, value); @@ -37,4 +37,5 @@ void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) zval_ptr_dtor(value); ZVAL_NULL(value); } + return SUCCESS; } diff --git a/ext/filter/filter.c b/ext/filter/filter.c index 7f3624eb4c07a..091e253842d52 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -30,11 +30,12 @@ ZEND_DECLARE_MODULE_GLOBALS(filter) #include "zend_attributes.h" #include "filter_private.h" #include "filter_arginfo.h" +#include "zend_exceptions.h" typedef struct filter_list_entry { const char *name; int id; - void (*function)(PHP_INPUT_FILTER_PARAM_DECL); + zend_result (*function)(PHP_INPUT_FILTER_PARAM_DECL); } filter_list_entry; /* {{{ filter_list */ @@ -77,6 +78,9 @@ static const filter_list_entry filter_list[] = { static unsigned int php_sapi_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len); static unsigned int php_sapi_filter_init(void); +zend_class_entry *php_filter_exception_ce; +zend_class_entry *php_filter_failed_exception_ce; + /* {{{ filter_module_entry */ zend_module_entry filter_module_entry = { STANDARD_MODULE_HEADER, @@ -160,6 +164,9 @@ PHP_MINIT_FUNCTION(filter) sapi_register_input_filter(php_sapi_filter, php_sapi_filter_init); + php_filter_exception_ce = register_class_Filter_FilterException(zend_ce_exception); + php_filter_failed_exception_ce = register_class_Filter_FilterFailedException(php_filter_exception_ce); + return SUCCESS; } /* }}} */ @@ -251,6 +258,16 @@ static void php_zval_filter(zval *value, zend_long filter, zend_long flags, zval ce = Z_OBJCE_P(value); if (!ce->__tostring) { zval_ptr_dtor(value); + if (flags & FILTER_THROW_ON_FAILURE) { + zend_throw_exception_ex( + php_filter_failed_exception_ce, + 0, + "filter validation failed: object of type %s has no __toString() method", + ZSTR_VAL(ce->name) + ); + ZVAL_NULL(value); + return; + } /* #67167: doesn't return null on failure for objects */ if (flags & FILTER_NULL_ON_FAILURE) { ZVAL_NULL(value); @@ -264,7 +281,29 @@ static void php_zval_filter(zval *value, zend_long filter, zend_long flags, zval /* Here be strings */ convert_to_string(value); - filter_func.function(value, flags, options, charset); + zend_string *copy_for_throwing = NULL; + if (flags & FILTER_THROW_ON_FAILURE) { + copy_for_throwing = zend_string_copy(Z_STR_P(value)); + } + + zend_result result = filter_func.function(value, flags, options, charset); + + if (flags & FILTER_THROW_ON_FAILURE) { + ZEND_ASSERT(copy_for_throwing != NULL); + if (result == FAILURE) { + zend_throw_exception_ex( + php_filter_failed_exception_ce, + 0, + "filter validation failed: filter %s not satisfied by '%s'", + filter_func.name, + ZSTR_VAL(copy_for_throwing) + ); + zend_string_delref(copy_for_throwing); + return; + } + zend_string_delref(copy_for_throwing); + copy_for_throwing = NULL; + } handle_default: if (options && Z_TYPE_P(options) == IS_ARRAY && @@ -450,7 +489,8 @@ PHP_FUNCTION(filter_has_var) static void php_filter_call( zval *filtered, zend_long filter, HashTable *filter_args_ht, zend_long filter_args_long, - zend_long filter_flags + zend_long filter_flags, + uint32_t options_arg_num ) /* {{{ */ { zval *options = NULL; char *charset = NULL; @@ -492,10 +532,28 @@ static void php_filter_call( } } + /* Cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE */ + if ((filter_flags & FILTER_NULL_ON_FAILURE) && (filter_flags & FILTER_THROW_ON_FAILURE)) { + zval_ptr_dtor(filtered); + ZVAL_NULL(filtered); + zend_argument_value_error( + options_arg_num, + "cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE" + ); + return; + } + if (Z_TYPE_P(filtered) == IS_ARRAY) { if (filter_flags & FILTER_REQUIRE_SCALAR) { zval_ptr_dtor(filtered); - if (filter_flags & FILTER_NULL_ON_FAILURE) { + if (filter_flags & FILTER_THROW_ON_FAILURE) { + ZVAL_NULL(filtered); + zend_throw_exception( + php_filter_failed_exception_ce, + "filter validation failed: not a scalar value (got an array)", + 0 + ); + } else if (filter_flags & FILTER_NULL_ON_FAILURE) { ZVAL_NULL(filtered); } else { ZVAL_FALSE(filtered); @@ -506,6 +564,17 @@ static void php_filter_call( return; } if (filter_flags & FILTER_REQUIRE_ARRAY) { + if (filter_flags & FILTER_THROW_ON_FAILURE) { + zend_throw_exception_ex( + php_filter_failed_exception_ce, + 0, + "filter validation failed: not an array (got %s)", + zend_zval_value_name(filtered) + ); + zval_ptr_dtor(filtered); + ZVAL_NULL(filtered); + return; + } zval_ptr_dtor(filtered); if (filter_flags & FILTER_NULL_ON_FAILURE) { ZVAL_NULL(filtered); @@ -516,6 +585,10 @@ static void php_filter_call( } php_zval_filter(filtered, filter, filter_flags, options, charset); + /* Don't wrap in an array if we are throwing an exception */ + if (EG(exception)) { + return; + } if (filter_flags & FILTER_FORCE_ARRAY) { zval tmp; ZVAL_COPY_VALUE(&tmp, filtered); @@ -530,7 +603,7 @@ static void php_filter_array_handler(zval *input, HashTable *op_ht, zend_long op ) /* {{{ */ { if (!op_ht) { ZVAL_DUP(return_value, input); - php_filter_call(return_value, -1, NULL, op_long, FILTER_REQUIRE_ARRAY); + php_filter_call(return_value, -1, NULL, op_long, FILTER_REQUIRE_ARRAY, 2); } else { array_init(return_value); zend_string *arg_key; @@ -557,8 +630,12 @@ static void php_filter_array_handler(zval *input, HashTable *op_ht, zend_long op php_filter_call(&nval, -1, Z_TYPE_P(arg_elm) == IS_ARRAY ? Z_ARRVAL_P(arg_elm) : NULL, Z_TYPE_P(arg_elm) == IS_ARRAY ? 0 : zval_get_long(arg_elm), - FILTER_REQUIRE_SCALAR + FILTER_REQUIRE_SCALAR, + 2 ); + if (EG(exception)) { + RETURN_THROWS(); + } zend_hash_update(Z_ARRVAL_P(return_value), arg_key, &nval); } } ZEND_HASH_FOREACH_END(); @@ -598,11 +675,35 @@ PHP_FUNCTION(filter_input) if (!filter_args_ht) { filter_flags = filter_args_long; } else { - zval *option, *opt, *def; + zval *option; if ((option = zend_hash_str_find(filter_args_ht, "flags", sizeof("flags") - 1)) != NULL) { filter_flags = zval_get_long(option); } + } + + /* Cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE */ + if ((filter_flags & FILTER_NULL_ON_FAILURE) && (filter_flags & FILTER_THROW_ON_FAILURE)) { + zend_argument_value_error( + 4, + "cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE" + ); + RETURN_THROWS(); + } + + if (filter_flags & FILTER_THROW_ON_FAILURE) { + zend_throw_exception_ex( + php_filter_failed_exception_ce, + 0, + "input value '%s' not found", + ZSTR_VAL(var) + ); + RETURN_THROWS(); + } + /* FILTER_THROW_ON_FAILURE overrides defaults, needs to be checked + * before the default is used. */ + if (filter_args_ht) { + zval *opt, *def; if ((opt = zend_hash_str_find_deref(filter_args_ht, "options", sizeof("options") - 1)) != NULL && Z_TYPE_P(opt) == IS_ARRAY && (def = zend_hash_str_find_deref(Z_ARRVAL_P(opt), "default", sizeof("default") - 1)) != NULL @@ -626,7 +727,7 @@ PHP_FUNCTION(filter_input) ZVAL_DUP(return_value, tmp); - php_filter_call(return_value, filter, filter_args_ht, filter_args_long, FILTER_REQUIRE_SCALAR); + php_filter_call(return_value, filter, filter_args_ht, filter_args_long, FILTER_REQUIRE_SCALAR, 4); } /* }}} */ @@ -652,7 +753,7 @@ PHP_FUNCTION(filter_var) ZVAL_DUP(return_value, data); - php_filter_call(return_value, filter, filter_args_ht, filter_args_long, FILTER_REQUIRE_SCALAR); + php_filter_call(return_value, filter, filter_args_ht, filter_args_long, FILTER_REQUIRE_SCALAR, 3); } /* }}} */ diff --git a/ext/filter/filter.stub.php b/ext/filter/filter.stub.php index a8790bb7cd615..4332f9261e982 100644 --- a/ext/filter/filter.stub.php +++ b/ext/filter/filter.stub.php @@ -2,6 +2,7 @@ /** @generate-class-entries */ +namespace { /** * @var int * @cvalue PARSE_POST @@ -54,6 +55,11 @@ * @cvalue FILTER_NULL_ON_FAILURE */ const FILTER_NULL_ON_FAILURE = UNKNOWN; +/** + * @var int + * @cvalue FILTER_THROW_ON_FAILURE + */ +const FILTER_THROW_ON_FAILURE = UNKNOWN; /** * @var int @@ -313,3 +319,13 @@ function filter_var_array(array $array, array|int $options = FILTER_DEFAULT, boo function filter_list(): array {} function filter_id(string $name): int|false {} + +} + +namespace Filter { + + class FilterException extends \Exception {} + + class FilterFailedException extends FilterException {} + +} diff --git a/ext/filter/filter_arginfo.h b/ext/filter/filter_arginfo.h index fde47bfc7f100..c777b6ffe77e0 100644 --- a/ext/filter/filter_arginfo.h +++ b/ext/filter/filter_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: a0f9a546d59bb27854af79a92e353f118ca6bdaf */ + * Stub hash: c3eb55dfec619af1e46be206f51a2b0893ed399f */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_filter_has_var, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, input_type, IS_LONG, 0) @@ -69,6 +69,7 @@ static void register_filter_symbols(int module_number) REGISTER_LONG_CONSTANT("FILTER_REQUIRE_ARRAY", FILTER_REQUIRE_ARRAY, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_FORCE_ARRAY", FILTER_FORCE_ARRAY, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_NULL_ON_FAILURE", FILTER_NULL_ON_FAILURE, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("FILTER_THROW_ON_FAILURE", FILTER_THROW_ON_FAILURE, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_VALIDATE_INT", FILTER_VALIDATE_INT, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_VALIDATE_BOOLEAN", FILTER_VALIDATE_BOOL, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_VALIDATE_BOOL", FILTER_VALIDATE_BOOL, CONST_PERSISTENT); @@ -129,3 +130,23 @@ static void register_filter_symbols(int module_number) ZVAL_STR_COPY(&attribute_Deprecated_const_FILTER_SANITIZE_STRIPPED_0->args[1].value, attribute_Deprecated_const_FILTER_SANITIZE_STRING_0_arg1_str); attribute_Deprecated_const_FILTER_SANITIZE_STRIPPED_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); } + +static zend_class_entry *register_class_Filter_FilterException(zend_class_entry *class_entry_Exception) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "Filter", "FilterException", NULL); + class_entry = zend_register_internal_class_with_flags(&ce, class_entry_Exception, 0); + + return class_entry; +} + +static zend_class_entry *register_class_Filter_FilterFailedException(zend_class_entry *class_entry_Filter_FilterException) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "Filter", "FilterFailedException", NULL); + class_entry = zend_register_internal_class_with_flags(&ce, class_entry_Filter_FilterException, 0); + + return class_entry; +} diff --git a/ext/filter/filter_private.h b/ext/filter/filter_private.h index a1bbb500f8db4..709b7fbc45edc 100644 --- a/ext/filter/filter_private.h +++ b/ext/filter/filter_private.h @@ -24,6 +24,7 @@ #define FILTER_FORCE_ARRAY 0x4000000 #define FILTER_NULL_ON_FAILURE 0x8000000 +#define FILTER_THROW_ON_FAILURE 0x10000000 #define FILTER_FLAG_ALLOW_OCTAL 0x0001 #define FILTER_FLAG_ALLOW_HEX 0x0002 @@ -50,7 +51,7 @@ #define FILTER_FLAG_IPV6 0x00200000 #define FILTER_FLAG_NO_RES_RANGE 0x00400000 #define FILTER_FLAG_NO_PRIV_RANGE 0x00800000 -#define FILTER_FLAG_GLOBAL_RANGE 0x10000000 +#define FILTER_FLAG_GLOBAL_RANGE 0x20000000 #define FILTER_FLAG_HOSTNAME 0x100000 @@ -93,9 +94,18 @@ || (id >= FILTER_VALIDATE_ALL && id <= FILTER_VALIDATE_LAST) \ || id == FILTER_CALLBACK) + +/* When using FILTER_THROW_ON_FAILURE, we can't actually throw the error here + * because we don't have access to the name of the filter. Returning FAILURE + * from the filter handler indicates that validation failed *and* an exception + * should thus be thrown. */ #define RETURN_VALIDATION_FAILED \ if (EG(exception)) { \ - return; \ + return SUCCESS; \ + } else if (flags & FILTER_THROW_ON_FAILURE) { \ + zval_ptr_dtor(value); \ + ZVAL_NULL(value); \ + return FAILURE; \ } else if (flags & FILTER_NULL_ON_FAILURE) { \ zval_ptr_dtor(value); \ ZVAL_NULL(value); \ @@ -103,7 +113,7 @@ zval_ptr_dtor(value); \ ZVAL_FALSE(value); \ } \ - return; \ + return SUCCESS; \ #define PHP_FILTER_TRIM_DEFAULT(p, len) PHP_FILTER_TRIM_DEFAULT_EX(p, len, 1); diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 2c64de3f58724..cf5602e39291d 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -198,7 +198,7 @@ static bool php_filter_parse_hex(const char *str, size_t str_len, zend_long *ret } /* }}} */ -void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ +zend_result php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { zval *option_val; zend_long min_range, max_range, option_flags; @@ -269,12 +269,12 @@ void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ } else { zval_ptr_dtor(value); ZVAL_LONG(value, ctx_value); - return; } + return SUCCESS; } /* }}} */ -void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ +zend_result php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { const char *str = Z_STRVAL_P(value); size_t len = Z_STRLEN_P(value); @@ -340,10 +340,11 @@ void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ zval_ptr_dtor(value); ZVAL_BOOL(value, ret); } + return SUCCESS; } /* }}} */ -void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ +zend_result php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { size_t len; const char *str, *end; @@ -470,10 +471,11 @@ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ RETURN_VALIDATION_FAILED } efree(num); + return SUCCESS; } /* }}} */ -void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ +zend_result php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { zval *option_val; zend_string *regexp; @@ -506,6 +508,7 @@ void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ if (rc < 0) { RETURN_VALIDATION_FAILED } + return SUCCESS; } static bool php_filter_validate_domain_ex(const zend_string *domain, zend_long flags) /* {{{ */ @@ -560,11 +563,12 @@ static bool php_filter_validate_domain_ex(const zend_string *domain, zend_long f } /* }}} */ -void php_filter_validate_domain(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ +zend_result php_filter_validate_domain(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { if (!php_filter_validate_domain_ex(Z_STR_P(value), flags)) { RETURN_VALIDATION_FAILED } + return SUCCESS; } /* }}} */ @@ -592,7 +596,7 @@ static bool php_filter_is_valid_ipv6_hostname(const zend_string *s) return *ZSTR_VAL(s) == '[' && *t == ']' && _php_filter_validate_ipv6(ZSTR_VAL(s) + 1, ZSTR_LEN(s) - 2, NULL); } -void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ +zend_result php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { size_t old_len = Z_STRLEN_P(value); @@ -662,10 +666,11 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ } php_uri_struct_free(uri); + return SUCCESS; } /* }}} */ -void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ +zend_result php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { /* * The regex below is based on a regex by Michael Rushton. @@ -731,6 +736,7 @@ void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ if (rc < 0) { RETURN_VALIDATION_FAILED } + return SUCCESS; } /* }}} */ @@ -991,7 +997,7 @@ static bool ipv6_get_status_flags(const int ip[8], bool *global, bool *reserved, * to throw out reserved ranges; multicast ranges... etc. If both allow_ipv4 * and allow_ipv6 flags flag are used, then the first dot or colon determine * the format */ -void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ +zend_result php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { int ip[8]; int mode; @@ -1019,7 +1025,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ } if (!ipv4_get_status_flags(ip, &flag_global, &flag_reserved, &flag_private)) { - return; /* no special block */ + return SUCCESS; /* no special block */ } } else if (mode == FORMAT_IPV6) { @@ -1028,7 +1034,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ } if (!ipv6_get_status_flags(ip, &flag_global, &flag_reserved, &flag_private)) { - return; /* no special block */ + return SUCCESS; /* no special block */ } } @@ -1043,10 +1049,11 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ if ((flags & FILTER_FLAG_NO_RES_RANGE) && flag_reserved == true) { RETURN_VALIDATION_FAILED } + return SUCCESS; } /* }}} */ -void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ +zend_result php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ { const char *input = Z_STRVAL_P(value); size_t input_len = Z_STRLEN_P(value); @@ -1105,5 +1112,6 @@ void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ RETURN_VALIDATION_FAILED } } + return SUCCESS; } /* }}} */ diff --git a/ext/filter/php_filter.h b/ext/filter/php_filter.h index f782907898fca..48ad5cc07943e 100644 --- a/ext/filter/php_filter.h +++ b/ext/filter/php_filter.h @@ -53,27 +53,27 @@ ZEND_TSRMLS_CACHE_EXTERN() #define IF_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(filter, v) #define PHP_INPUT_FILTER_PARAM_DECL zval *value, zend_long flags, zval *option_array, char *charset -void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_validate_domain(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_int(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_float(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_validate_domain(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_encoded(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_special_chars(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_full_special_chars(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_email(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_url(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_add_slashes(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_string(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_encoded(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_special_chars(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_full_special_chars(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_email(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_url(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_add_slashes(PHP_INPUT_FILTER_PARAM_DECL); -void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL); +zend_result php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL); #endif /* FILTER_H */ diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c index ebc20e47711db..94cbd0c34bba7 100644 --- a/ext/filter/sanitizing_filters.c +++ b/ext/filter/sanitizing_filters.c @@ -168,7 +168,7 @@ static void filter_map_apply(zval *value, const filter_map *map) /* }}} */ /* {{{ php_filter_string */ -void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL) +zend_result php_filter_string(PHP_INPUT_FILTER_PARAM_DECL) { size_t new_len; unsigned char enc[256] = {0}; @@ -206,23 +206,24 @@ void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL) } else { ZVAL_EMPTY_STRING(value); } - return; } + return SUCCESS; } /* }}} */ /* {{{ php_filter_encoded */ -void php_filter_encoded(PHP_INPUT_FILTER_PARAM_DECL) +zend_result php_filter_encoded(PHP_INPUT_FILTER_PARAM_DECL) { /* apply strip_high and strip_low filters */ php_filter_strip(value, flags); /* urlencode */ php_filter_encode_url(value, (unsigned char *)DEFAULT_URL_ENCODE, sizeof(DEFAULT_URL_ENCODE)-1); + return SUCCESS; } /* }}} */ /* {{{ php_filter_special_chars */ -void php_filter_special_chars(PHP_INPUT_FILTER_PARAM_DECL) +zend_result php_filter_special_chars(PHP_INPUT_FILTER_PARAM_DECL) { unsigned char enc[256] = {0}; @@ -239,11 +240,12 @@ void php_filter_special_chars(PHP_INPUT_FILTER_PARAM_DECL) } php_filter_encode_html(value, enc); + return SUCCESS; } /* }}} */ /* {{{ php_filter_full_special_chars */ -void php_filter_full_special_chars(PHP_INPUT_FILTER_PARAM_DECL) +zend_result php_filter_full_special_chars(PHP_INPUT_FILTER_PARAM_DECL) { zend_string *buf; int quotes; @@ -258,11 +260,12 @@ void php_filter_full_special_chars(PHP_INPUT_FILTER_PARAM_DECL) /* charset_hint */ NULL, /* double_encode */ 0, /* quiet */ 0); zval_ptr_dtor(value); ZVAL_STR(value, buf); + return SUCCESS; } /* }}} */ /* {{{ php_filter_unsafe_raw */ -void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL) +zend_result php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL) { /* Only if no flags are set (optimization) */ if (flags != 0 && Z_STRLEN_P(value) > 0) { @@ -285,6 +288,7 @@ void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL) zval_ptr_dtor(value); ZVAL_NULL(value); } + return SUCCESS; } /* }}} */ @@ -295,7 +299,7 @@ void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL) #define PUNCTUATION "<>#%\"" #define RESERVED ";/?:@&=" -void php_filter_email(PHP_INPUT_FILTER_PARAM_DECL) +zend_result php_filter_email(PHP_INPUT_FILTER_PARAM_DECL) { /* Check section 6 of rfc 822 http://www.faqs.org/rfcs/rfc822.html */ const unsigned char allowed_list[] = LOWALPHA HIALPHA DIGIT "!#$%&'*+-=?^_`{|}~@.[]"; @@ -304,11 +308,12 @@ void php_filter_email(PHP_INPUT_FILTER_PARAM_DECL) filter_map_init(&map); filter_map_update(&map, 1, allowed_list); filter_map_apply(value, &map); + return SUCCESS; } /* }}} */ /* {{{ php_filter_url */ -void php_filter_url(PHP_INPUT_FILTER_PARAM_DECL) +zend_result php_filter_url(PHP_INPUT_FILTER_PARAM_DECL) { /* Strip all chars not part of section 5 of * http://www.faqs.org/rfcs/rfc1738.html */ @@ -318,11 +323,12 @@ void php_filter_url(PHP_INPUT_FILTER_PARAM_DECL) filter_map_init(&map); filter_map_update(&map, 1, allowed_list); filter_map_apply(value, &map); + return SUCCESS; } /* }}} */ /* {{{ php_filter_number_int */ -void php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL) +zend_result php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL) { /* strip everything [^0-9+-] */ const unsigned char allowed_list[] = "+-" DIGIT; @@ -331,11 +337,12 @@ void php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL) filter_map_init(&map); filter_map_update(&map, 1, allowed_list); filter_map_apply(value, &map); + return SUCCESS; } /* }}} */ /* {{{ php_filter_number_float */ -void php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL) +zend_result php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL) { /* strip everything [^0-9+-] */ const unsigned char allowed_list[] = "+-" DIGIT; @@ -355,15 +362,17 @@ void php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL) filter_map_update(&map, 4, (const unsigned char *) "eE"); } filter_map_apply(value, &map); + return SUCCESS; } /* }}} */ /* {{{ php_filter_add_slashes */ -void php_filter_add_slashes(PHP_INPUT_FILTER_PARAM_DECL) +zend_result php_filter_add_slashes(PHP_INPUT_FILTER_PARAM_DECL) { zend_string *buf = php_addslashes(Z_STR_P(value)); zval_ptr_dtor(value); ZVAL_STR(value, buf); + return SUCCESS; } /* }}} */ diff --git a/ext/filter/tests/throw-on-failure/filter_input_array_failure.phpt b/ext/filter/tests/throw-on-failure/filter_input_array_failure.phpt new file mode 100644 index 0000000000000..868829dbbac05 --- /dev/null +++ b/ext/filter/tests/throw-on-failure/filter_input_array_failure.phpt @@ -0,0 +1,29 @@ +--TEST-- +FILTER_THROW_ON_FAILURE: filter_input_array() failure +--EXTENSIONS-- +filter +--GET-- +a=1 +--FILE-- + ['flags' => FILTER_REQUIRE_ARRAY | FILTER_THROW_ON_FAILURE]]); +} catch (Filter\FilterFailedException $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} + +echo "\nvalidation fails (filter value)\n"; +try { + filter_input_array(INPUT_GET, ['a' => ['filter' => FILTER_VALIDATE_EMAIL, 'flags' => FILTER_THROW_ON_FAILURE]]); +} catch (Filter\FilterFailedException $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} +?> +--EXPECT-- +validation fails (array type check) +Filter\FilterFailedException: filter validation failed: not an array (got string) + +validation fails (filter value) +Filter\FilterFailedException: filter validation failed: filter validate_email not satisfied by '1' diff --git a/ext/filter/tests/throw-on-failure/filter_input_failure.phpt b/ext/filter/tests/throw-on-failure/filter_input_failure.phpt new file mode 100644 index 0000000000000..8ec2d572e7f11 --- /dev/null +++ b/ext/filter/tests/throw-on-failure/filter_input_failure.phpt @@ -0,0 +1,39 @@ +--TEST-- +FILTER_THROW_ON_FAILURE: filter_input() failure +--EXTENSIONS-- +filter +--GET-- +a=1 +--FILE-- +getMessage() . "\n"; +} + +echo "\nvalidation fails (array type check)\n"; +try { + filter_input(INPUT_GET, 'a', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY | FILTER_THROW_ON_FAILURE); +} catch (Filter\FilterFailedException $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} + +echo "\nvalidation fails (filter value)\n"; +try { + filter_input(INPUT_GET, 'a', FILTER_VALIDATE_EMAIL, FILTER_THROW_ON_FAILURE); +} catch (Filter\FilterFailedException $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} +?> +--EXPECT-- +missing value +Filter\FilterFailedException: input value 'b' not found + +validation fails (array type check) +Filter\FilterFailedException: filter validation failed: not an array (got string) + +validation fails (filter value) +Filter\FilterFailedException: filter validation failed: filter validate_email not satisfied by '1' diff --git a/ext/filter/tests/throw-on-failure/filter_success.phpt b/ext/filter/tests/throw-on-failure/filter_success.phpt new file mode 100644 index 0000000000000..c5b0e2fc9fdd5 --- /dev/null +++ b/ext/filter/tests/throw-on-failure/filter_success.phpt @@ -0,0 +1,68 @@ +--TEST-- +FILTER_THROW_ON_FAILURE: successful filters do not throw +--EXTENSIONS-- +filter +--GET-- +a=daniel.e.scherzer@gmail.com +--FILE-- +wrapped; } +} + +echo "filter_input:\n"; +var_dump(filter_input(INPUT_GET, 'a', FILTER_DEFAULT, FILTER_THROW_ON_FAILURE)); +var_dump(filter_input(INPUT_GET, 'a', FILTER_DEFAULT, FILTER_REQUIRE_SCALAR | FILTER_THROW_ON_FAILURE)); +var_dump(filter_input(INPUT_GET, 'a', FILTER_VALIDATE_EMAIL, FILTER_THROW_ON_FAILURE)); + +echo "\nfilter_input_array:\n"; +var_dump(filter_input_array(INPUT_GET, ['a' => ['flags' => FILTER_REQUIRE_SCALAR | FILTER_THROW_ON_FAILURE]])); +var_dump(filter_input_array(INPUT_GET, ['a' => ['filter' => FILTER_VALIDATE_EMAIL, 'flags' => FILTER_THROW_ON_FAILURE]])); + +echo "\nfilter_var:\n"; +var_dump(filter_var('a', FILTER_DEFAULT, FILTER_REQUIRE_SCALAR | FILTER_THROW_ON_FAILURE)); +var_dump(filter_var(new MyString('daniel.e.scherzer@gmail.com'), FILTER_VALIDATE_EMAIL, FILTER_THROW_ON_FAILURE)); +var_dump(filter_var('daniel.e.scherzer@gmail.com', FILTER_VALIDATE_EMAIL, FILTER_THROW_ON_FAILURE)); + +echo "\nfilter_var_array:\n"; +var_dump(filter_var_array(['a' => 'a'], ['a' => ['flags' => FILTER_REQUIRE_SCALAR | FILTER_THROW_ON_FAILURE]])); +var_dump(filter_var_array(['a' => new MyString('bar')], ['a' => ['flags' => FILTER_THROW_ON_FAILURE]])); +var_dump(filter_var_array(['a' => 'daniel.e.scherzer@gmail.com'], ['a' => ['filter' => FILTER_VALIDATE_EMAIL, 'flags' => FILTER_THROW_ON_FAILURE]])); + +?> +--EXPECT-- +filter_input: +string(27) "daniel.e.scherzer@gmail.com" +string(27) "daniel.e.scherzer@gmail.com" +string(27) "daniel.e.scherzer@gmail.com" + +filter_input_array: +array(1) { + ["a"]=> + string(27) "daniel.e.scherzer@gmail.com" +} +array(1) { + ["a"]=> + string(27) "daniel.e.scherzer@gmail.com" +} + +filter_var: +string(1) "a" +string(27) "daniel.e.scherzer@gmail.com" +string(27) "daniel.e.scherzer@gmail.com" + +filter_var_array: +array(1) { + ["a"]=> + string(1) "a" +} +array(1) { + ["a"]=> + string(3) "bar" +} +array(1) { + ["a"]=> + string(27) "daniel.e.scherzer@gmail.com" +} diff --git a/ext/filter/tests/throw-on-failure/filter_var_array_failure.phpt b/ext/filter/tests/throw-on-failure/filter_var_array_failure.phpt new file mode 100644 index 0000000000000..f40dec1537dd8 --- /dev/null +++ b/ext/filter/tests/throw-on-failure/filter_var_array_failure.phpt @@ -0,0 +1,37 @@ +--TEST-- +FILTER_THROW_ON_FAILURE: filter_var_array() failure +--EXTENSIONS-- +filter +--FILE-- + 'a'], ['a' => ['flags' => FILTER_REQUIRE_ARRAY | FILTER_THROW_ON_FAILURE]]); +} catch (Filter\FilterFailedException $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} + +echo "\nvalidation fails (object without __toString)\n"; +try { + filter_var_array(['a' => new stdClass()], ['a' => ['flags' => FILTER_THROW_ON_FAILURE]]); +} catch (Filter\FilterFailedException $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} + +echo "\nvalidation fails (filter value)\n"; +try { + filter_var_array(['a' => true], ['a' => ['filter' => FILTER_VALIDATE_EMAIL, 'flags' => FILTER_THROW_ON_FAILURE]]); +} catch (Filter\FilterFailedException $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} +?> +--EXPECT-- +validation fails (array type check) +Filter\FilterFailedException: filter validation failed: not an array (got string) + +validation fails (object without __toString) +Filter\FilterFailedException: filter validation failed: object of type stdClass has no __toString() method + +validation fails (filter value) +Filter\FilterFailedException: filter validation failed: filter validate_email not satisfied by '1' diff --git a/ext/filter/tests/throw-on-failure/filter_var_failure.phpt b/ext/filter/tests/throw-on-failure/filter_var_failure.phpt new file mode 100644 index 0000000000000..fccc61da4d0ff --- /dev/null +++ b/ext/filter/tests/throw-on-failure/filter_var_failure.phpt @@ -0,0 +1,37 @@ +--TEST-- +FILTER_THROW_ON_FAILURE: filter_input() failure +--EXTENSIONS-- +filter +--FILE-- +getMessage() . "\n"; +} + +echo "\nvalidation fails (object without __toString)\n"; +try { + filter_var(new stdClass(), FILTER_VALIDATE_EMAIL, FILTER_THROW_ON_FAILURE); +} catch (Filter\FilterFailedException $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} + +echo "\nvalidation fails (filter value)\n"; +try { + filter_var('a', FILTER_VALIDATE_EMAIL, FILTER_THROW_ON_FAILURE); +} catch (Filter\FilterFailedException $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} +?> +--EXPECT-- +validation fails (array type check) +Filter\FilterFailedException: filter validation failed: not an array (got string) + +validation fails (object without __toString) +Filter\FilterFailedException: filter validation failed: object of type stdClass has no __toString() method + +validation fails (filter value) +Filter\FilterFailedException: filter validation failed: filter validate_email not satisfied by 'a' diff --git a/ext/filter/tests/throw-on-failure/throw-and-null-error.phpt b/ext/filter/tests/throw-on-failure/throw-and-null-error.phpt new file mode 100644 index 0000000000000..48c37618ed917 --- /dev/null +++ b/ext/filter/tests/throw-on-failure/throw-and-null-error.phpt @@ -0,0 +1,86 @@ +--TEST-- +Cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE +--EXTENSIONS-- +filter +--GET-- +a=1 +--FILE-- +getMessage() . "\n"; +} +try { + filter_input(INPUT_GET, 'b', FILTER_DEFAULT, ['flags' => $flags]); +} catch (ValueError $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} +echo "\nfilter_input(), with a missing value and a default\n"; +try { + filter_input(INPUT_GET, 'b', FILTER_DEFAULT, ['flags' => $flags, 'options' => ['default' => 'a']]); +} catch (ValueError $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} +echo "\nfilter_input(), with a present value\n"; +try { + filter_input(INPUT_GET, 'a', FILTER_DEFAULT, $flags); +} catch (ValueError $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} +try { + filter_input(INPUT_GET, 'a', FILTER_DEFAULT, ['flags' => $flags]); +} catch (ValueError $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} +echo "\nfilter_var()\n"; +try { + filter_var(true, FILTER_DEFAULT, $flags); +} catch (ValueError $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} +try { + filter_var(true, FILTER_DEFAULT, ['flags' => $flags]); +} catch (ValueError $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} + +echo "\nfilter_input_array()\n"; +try { + filter_input_array(INPUT_GET, ['a' => ['flags' => $flags]]); +} catch (ValueError $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} + +echo "\nfilter_var_array()\n"; +try { + filter_var_array(['a' => true], ['a' => ['flags' => $flags]]); +} catch (ValueError $e) { + echo get_class($e) . ": " . $e->getMessage() . "\n"; +} +?> +--EXPECT-- +filter_input(), with a missing value +ValueError: filter_input(): Argument #4 ($options) cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE +ValueError: filter_input(): Argument #4 ($options) cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE + +filter_input(), with a missing value and a default +ValueError: filter_input(): Argument #4 ($options) cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE + +filter_input(), with a present value +ValueError: filter_input(): Argument #4 ($options) cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE +ValueError: filter_input(): Argument #4 ($options) cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE + +filter_var() +ValueError: filter_var(): Argument #3 ($options) cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE +ValueError: filter_var(): Argument #3 ($options) cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE + +filter_input_array() +ValueError: filter_input_array(): Argument #2 ($options) cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE + +filter_var_array() +ValueError: filter_var_array(): Argument #2 ($options) cannot use both FILTER_NULL_ON_FAILURE and FILTER_THROW_ON_FAILURE diff --git a/ext/mysqli/tests/bug77956.phpt b/ext/mysqli/tests/bug77956.phpt index 28cf694a606a8..d5409f9527511 100644 --- a/ext/mysqli/tests/bug77956.phpt +++ b/ext/mysqli/tests/bug77956.phpt @@ -57,5 +57,5 @@ $link->close(); unlink('bug77956.data'); ?> --EXPECT-- -[006] [2000] LOAD DATA LOCAL INFILE is forbidden, check related settings like mysqli.allow_local_infile|mysqli.local_infile_directory or PDO::MYSQL_ATTR_LOCAL_INFILE|PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY +[006] [2000] LOAD DATA LOCAL INFILE is forbidden, check related settings like mysqli.allow_local_infile|mysqli.local_infile_directory or Pdo\Mysql::ATTR_LOCAL_INFILE|Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY done diff --git a/ext/mysqlnd/mysqlnd_loaddata.c b/ext/mysqlnd/mysqlnd_loaddata.c index ba2dabf95a2c5..a1e04de270085 100644 --- a/ext/mysqlnd/mysqlnd_loaddata.c +++ b/ext/mysqlnd/mysqlnd_loaddata.c @@ -167,7 +167,7 @@ mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * const filenam SET_CLIENT_ERROR(conn->error_info, CR_LOAD_DATA_LOCAL_INFILE_REJECTED, UNKNOWN_SQLSTATE, "LOAD DATA LOCAL INFILE is forbidden, check related settings like " "mysqli.allow_local_infile|mysqli.local_infile_directory or " - "PDO::MYSQL_ATTR_LOCAL_INFILE|PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY"); + "Pdo\\Mysql::ATTR_LOCAL_INFILE|Pdo\\Mysql::ATTR_LOCAL_INFILE_DIRECTORY"); prerequisities_ok = FALSE; } diff --git a/ext/pdo/php_pdo.h b/ext/pdo/php_pdo.h index 1618c78d62284..59789a04c73f2 100644 --- a/ext/pdo/php_pdo.h +++ b/ext/pdo/php_pdo.h @@ -18,6 +18,9 @@ #define PHP_PDO_H #include "zend.h" +#include "Zend/zend_compile.h" +#include "Zend/zend_API.h" +#include "Zend/zend_attributes.h" PHPAPI extern zend_module_entry pdo_module_entry; #define phpext_pdo_ptr &pdo_module_entry @@ -50,8 +53,47 @@ PHP_MINIT_FUNCTION(pdo); PHP_MSHUTDOWN_FUNCTION(pdo); PHP_MINFO_FUNCTION(pdo); -#define REGISTER_PDO_CLASS_CONST_LONG(const_name, value) \ - zend_declare_class_constant_long(php_pdo_get_dbh_ce(), const_name, sizeof(const_name)-1, (zend_long)value); +static inline void pdo_declare_deprecated_class_constant_long( + zend_class_entry *ce, const char *name, zend_long value, + zend_string *since, const char *message) { + + zval zvalue; + ZVAL_LONG(&zvalue, value); + + zend_string *name_str = zend_string_init_interned(name, strlen(name), true); + + zend_class_constant *constant = zend_declare_class_constant_ex( + ce, name_str, &zvalue, + ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL); + + zend_attribute *attr = zend_add_class_constant_attribute(ce, constant, + ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), + 1 + (message != NULL)); + + attr->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); + ZVAL_STR(&attr->args[0].value, since); + + if (message) { + zend_string *message_str = zend_string_init_interned(message, strlen(message), true); + + attr->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + ZVAL_STR(&attr->args[1].value, message_str); + } +} + +/* Declare a constant deprecated in 8.5 */ +#define REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_85(const_name, value) \ + pdo_declare_deprecated_class_constant_long(php_pdo_get_dbh_ce(), \ + const_name, (zend_long)value, \ + ZSTR_KNOWN(ZEND_STR_8_DOT_5), NULL) + +/* Declare one of the constants deprecated in https://wiki.php.net/rfc/deprecations_php_8_5 + * "Deprecate driver specific PDO constants and methods" */ +#define REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(name, old_prefix, new_prefix, value) \ + pdo_declare_deprecated_class_constant_long(php_pdo_get_dbh_ce(), \ + old_prefix name, (zend_long)value, \ + ZSTR_KNOWN(ZEND_STR_8_DOT_5), \ + "use " new_prefix name " instead") #define LONG_CONST(c) (zend_long) c diff --git a/ext/pdo/tests/pdo_016.phpt b/ext/pdo/tests/pdo_016.phpt index 5b99930f2495c..2a5fa8d85f512 100644 --- a/ext/pdo/tests/pdo_016.phpt +++ b/ext/pdo/tests/pdo_016.phpt @@ -17,7 +17,7 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true); } $db->exec('CREATE TABLE test016(idx int NOT NULL PRIMARY KEY, txt VARCHAR(20))'); diff --git a/ext/pdo/tests/pdo_016a.phpt b/ext/pdo/tests/pdo_016a.phpt index d7dcb2c65430b..2c0590594a84f 100644 --- a/ext/pdo/tests/pdo_016a.phpt +++ b/ext/pdo/tests/pdo_016a.phpt @@ -17,7 +17,7 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true); } $db->exec('CREATE TABLE test016a(idx int NOT NULL PRIMARY KEY, txt VARCHAR(20))'); diff --git a/ext/pdo/tests/pdo_021.phpt b/ext/pdo/tests/pdo_021.phpt index 494ad3c39c50f..7ca3b075881f4 100644 --- a/ext/pdo/tests/pdo_021.phpt +++ b/ext/pdo/tests/pdo_021.phpt @@ -16,7 +16,7 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true); } $db->exec('CREATE TABLE test021(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); diff --git a/ext/pdo_dblib/pdo_dblib.c b/ext/pdo_dblib/pdo_dblib.c index b16208fbd8e78..9c59ddbc61849 100644 --- a/ext/pdo_dblib/pdo_dblib.c +++ b/ext/pdo_dblib/pdo_dblib.c @@ -190,15 +190,18 @@ PHP_RSHUTDOWN_FUNCTION(pdo_dblib) return SUCCESS; } +#define REGISTER_PDO_DBLIB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, value) \ + REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, "DBLIB_", "Pdo\\Dblib::", value) + PHP_MINIT_FUNCTION(pdo_dblib) { - REGISTER_PDO_CLASS_CONST_LONG("DBLIB_ATTR_CONNECTION_TIMEOUT", (long) PDO_DBLIB_ATTR_CONNECTION_TIMEOUT); - REGISTER_PDO_CLASS_CONST_LONG("DBLIB_ATTR_QUERY_TIMEOUT", (long) PDO_DBLIB_ATTR_QUERY_TIMEOUT); - REGISTER_PDO_CLASS_CONST_LONG("DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER", (long) PDO_DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER); - REGISTER_PDO_CLASS_CONST_LONG("DBLIB_ATTR_VERSION", (long) PDO_DBLIB_ATTR_VERSION); - REGISTER_PDO_CLASS_CONST_LONG("DBLIB_ATTR_TDS_VERSION", (long) PDO_DBLIB_ATTR_TDS_VERSION); - REGISTER_PDO_CLASS_CONST_LONG("DBLIB_ATTR_SKIP_EMPTY_ROWSETS", (long) PDO_DBLIB_ATTR_SKIP_EMPTY_ROWSETS); - REGISTER_PDO_CLASS_CONST_LONG("DBLIB_ATTR_DATETIME_CONVERT", (long) PDO_DBLIB_ATTR_DATETIME_CONVERT); + REGISTER_PDO_DBLIB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_CONNECTION_TIMEOUT", (long) PDO_DBLIB_ATTR_CONNECTION_TIMEOUT); + REGISTER_PDO_DBLIB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_QUERY_TIMEOUT", (long) PDO_DBLIB_ATTR_QUERY_TIMEOUT); + REGISTER_PDO_DBLIB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_STRINGIFY_UNIQUEIDENTIFIER", (long) PDO_DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER); + REGISTER_PDO_DBLIB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_VERSION", (long) PDO_DBLIB_ATTR_VERSION); + REGISTER_PDO_DBLIB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_TDS_VERSION", (long) PDO_DBLIB_ATTR_TDS_VERSION); + REGISTER_PDO_DBLIB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_SKIP_EMPTY_ROWSETS", (long) PDO_DBLIB_ATTR_SKIP_EMPTY_ROWSETS); + REGISTER_PDO_DBLIB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_DATETIME_CONVERT", (long) PDO_DBLIB_ATTR_DATETIME_CONVERT); if (FAIL == dbinit()) { return FAILURE; diff --git a/ext/pdo_dblib/tests/bug_69592.phpt b/ext/pdo_dblib/tests/bug_69592.phpt index d7114e8fa09d6..711713775c446 100644 --- a/ext/pdo_dblib/tests/bug_69592.phpt +++ b/ext/pdo_dblib/tests/bug_69592.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO_DBLIB: PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS for skip junk resultsets on SET NOCOUNT expression +PDO_DBLIB: Pdo\Dblib::ATTR_SKIP_EMPTY_ROWSETS for skip junk resultsets on SET NOCOUNT expression --EXTENSIONS-- pdo_dblib --SKIPIF-- @@ -18,7 +18,7 @@ $sql = ' SELECT 0 AS [result] '; -var_dump($db->getAttribute(PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS)); +var_dump($db->getAttribute(Pdo\Dblib::ATTR_SKIP_EMPTY_ROWSETS)); $stmt = $db->query($sql); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); @@ -27,15 +27,15 @@ var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); $stmt->closeCursor(); -$db->setAttribute(PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS, true); -var_dump($db->getAttribute(PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS)); +$db->setAttribute(Pdo\Dblib::ATTR_SKIP_EMPTY_ROWSETS, true); +var_dump($db->getAttribute(Pdo\Dblib::ATTR_SKIP_EMPTY_ROWSETS)); $stmt = $db->query($sql); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); var_dump($stmt->nextRowset()); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); $stmt->closeCursor(); -var_dump($db->getAttribute(PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS)); +var_dump($db->getAttribute(Pdo\Dblib::ATTR_SKIP_EMPTY_ROWSETS)); ?> --EXPECT-- diff --git a/ext/pdo_dblib/tests/bug_73396.phpt b/ext/pdo_dblib/tests/bug_73396.phpt index b2f96f8ec1c98..93dc66778a16a 100644 --- a/ext/pdo_dblib/tests/bug_73396.phpt +++ b/ext/pdo_dblib/tests/bug_73396.phpt @@ -6,7 +6,7 @@ pdo_dblib getAttribute(PDO::DBLIB_ATTR_TDS_VERSION), ['4.2', '4.6', '5.0', '6.0', '7.0'])) die('skip bigint type is unsupported by active TDS version'); +if (in_array($db->getAttribute(Pdo\Dblib::ATTR_TDS_VERSION), ['4.2', '4.6', '5.0', '6.0', '7.0'])) die('skip bigint type is unsupported by active TDS version'); ?> --FILE-- =1.1 function driver_supports_batch_statements_without_select($db) { - $version = $db->getAttribute(PDO::DBLIB_ATTR_VERSION); + $version = $db->getAttribute(Pdo\Dblib::ATTR_VERSION); return !strstartswith($version, 'freetds ') || !strstartswith($version, 'freetds v1.0'); } diff --git a/ext/pdo_dblib/tests/datetime2.phpt b/ext/pdo_dblib/tests/datetime2.phpt index e4f65048dd897..2b54361a30e59 100644 --- a/ext/pdo_dblib/tests/datetime2.phpt +++ b/ext/pdo_dblib/tests/datetime2.phpt @@ -6,7 +6,7 @@ pdo_dblib getAttribute(PDO::DBLIB_ATTR_TDS_VERSION), ['4.2', '4.6', '5.0', '6.0', '7.0', '7.1', '7.2'])) die('skip feature unsupported by this TDS version'); +if (in_array($db->getAttribute(Pdo\Dblib::ATTR_TDS_VERSION), ['4.2', '4.6', '5.0', '6.0', '7.0', '7.1', '7.2'])) die('skip feature unsupported by this TDS version'); ?> --FILE-- getAttribute(PDO::DBLIB_ATTR_DATETIME_CONVERT)); +var_dump($db->getAttribute(Pdo\Dblib::ATTR_DATETIME_CONVERT)); $stmt = $db->query($sql); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); -$db->setAttribute(PDO::DBLIB_ATTR_DATETIME_CONVERT, 1); -var_dump($db->getAttribute(PDO::DBLIB_ATTR_DATETIME_CONVERT)); +$db->setAttribute(Pdo\Dblib::ATTR_DATETIME_CONVERT, 1); +var_dump($db->getAttribute(Pdo\Dblib::ATTR_DATETIME_CONVERT)); $stmt = $db->query($sql); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); diff --git a/ext/pdo_dblib/tests/datetime_convert.phpt b/ext/pdo_dblib/tests/datetime_convert.phpt index ec858cf351c57..0934dd7f83e76 100644 --- a/ext/pdo_dblib/tests/datetime_convert.phpt +++ b/ext/pdo_dblib/tests/datetime_convert.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO_DBLIB: PDO::DBLIB_ATTR_DATETIME_CONVERT +PDO_DBLIB: Pdo\Dblib::ATTR_DATETIME_CONVERT --EXTENSIONS-- pdo_dblib --SKIPIF-- @@ -15,14 +15,14 @@ $db = getDbConnection(); $sql = "SELECT convert(datetime, '20171027 10:22:44.135') AS [d]"; -var_dump($db->getAttribute(PDO::DBLIB_ATTR_DATETIME_CONVERT)); +var_dump($db->getAttribute(Pdo\Dblib::ATTR_DATETIME_CONVERT)); $stmt = $db->query($sql); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); // assume default date format: %b %e %Y %I:%M:%S:%z%p -$db->setAttribute(PDO::DBLIB_ATTR_DATETIME_CONVERT, 1); -var_dump($db->getAttribute(PDO::DBLIB_ATTR_DATETIME_CONVERT)); +$db->setAttribute(Pdo\Dblib::ATTR_DATETIME_CONVERT, 1); +var_dump($db->getAttribute(Pdo\Dblib::ATTR_DATETIME_CONVERT)); $stmt = $db->query($sql); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); diff --git a/ext/pdo_dblib/tests/dbtds.phpt b/ext/pdo_dblib/tests/dbtds.phpt index aa05606a93269..fb2402eec080c 100644 --- a/ext/pdo_dblib/tests/dbtds.phpt +++ b/ext/pdo_dblib/tests/dbtds.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO_DBLIB: \PDO::DBLIB_ATTR_TDS_VERSION exposes a string or false +PDO_DBLIB: \Pdo\Dblib::ATTR_TDS_VERSION exposes a string or false --EXTENSIONS-- pdo_dblib --SKIPIF-- @@ -13,7 +13,7 @@ require __DIR__ . '/config.inc'; $db = getDbConnection(); -$version = $db->getAttribute(PDO::DBLIB_ATTR_TDS_VERSION); +$version = $db->getAttribute(Pdo\Dblib::ATTR_TDS_VERSION); var_dump((is_string($version) && strlen($version)) || $version === false); ?> diff --git a/ext/pdo_dblib/tests/dbversion.phpt b/ext/pdo_dblib/tests/dbversion.phpt index 44dd8f4a86dc3..aa61a26beeb23 100644 --- a/ext/pdo_dblib/tests/dbversion.phpt +++ b/ext/pdo_dblib/tests/dbversion.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO_DBLIB: \PDO::DBLIB_ATTR_VERSION exposes a string +PDO_DBLIB: \Pdo\Dblib::ATTR_VERSION exposes a string --EXTENSIONS-- pdo_dblib --SKIPIF-- @@ -13,7 +13,7 @@ require __DIR__ . '/config.inc'; $db = getDbConnection(); -$version = $db->getAttribute(PDO::DBLIB_ATTR_VERSION); +$version = $db->getAttribute(Pdo\Dblib::ATTR_VERSION); var_dump(is_string($version) && strlen($version)); ?> diff --git a/ext/pdo_dblib/tests/php_8.5_deprecations.phpt b/ext/pdo_dblib/tests/php_8.5_deprecations.phpt new file mode 100644 index 0000000000000..bf0e84cb40800 --- /dev/null +++ b/ext/pdo_dblib/tests/php_8.5_deprecations.phpt @@ -0,0 +1,39 @@ +--TEST-- +PDO_dblib: PHP 8.5 deprecations +--EXTENSIONS-- +pdo_dblib +--FILE-- + +--EXPECTF-- +Deprecated: Constant PDO::DBLIB_ATTR_CONNECTION_TIMEOUT is deprecated since 8.5, use Pdo\Dblib::ATTR_CONNECTION_TIMEOUT instead in %s on line %d + +Deprecated: Constant PDO::DBLIB_ATTR_QUERY_TIMEOUT is deprecated since 8.5, use Pdo\Dblib::ATTR_QUERY_TIMEOUT instead in %s on line %d + +Deprecated: Constant PDO::DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER is deprecated since 8.5, use Pdo\Dblib::ATTR_STRINGIFY_UNIQUEIDENTIFIER instead in %s on line %d + +Deprecated: Constant PDO::DBLIB_ATTR_VERSION is deprecated since 8.5, use Pdo\Dblib::ATTR_VERSION instead in %s on line %d + +Deprecated: Constant PDO::DBLIB_ATTR_TDS_VERSION is deprecated since 8.5, use Pdo\Dblib::ATTR_TDS_VERSION instead in %s on line %d + +Deprecated: Constant PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS is deprecated since 8.5, use Pdo\Dblib::ATTR_SKIP_EMPTY_ROWSETS instead in %s on line %d + +Deprecated: Constant PDO::DBLIB_ATTR_DATETIME_CONVERT is deprecated since 8.5, use Pdo\Dblib::ATTR_DATETIME_CONVERT instead in %s on line %d +int(1000) +int(1001) +int(1002) +int(1003) +int(1004) +int(1005) +int(1006) diff --git a/ext/pdo_dblib/tests/stringify_uniqueidentifier.phpt b/ext/pdo_dblib/tests/stringify_uniqueidentifier.phpt index 86c94877c63c1..3e87b4790ca9e 100644 --- a/ext/pdo_dblib/tests/stringify_uniqueidentifier.phpt +++ b/ext/pdo_dblib/tests/stringify_uniqueidentifier.phpt @@ -6,7 +6,7 @@ pdo_dblib getAttribute(PDO::DBLIB_ATTR_TDS_VERSION), ['4.2', '4.6'])) die('skip feature unsupported by this TDS version'); +if (in_array($db->getAttribute(Pdo\Dblib::ATTR_TDS_VERSION), ['4.2', '4.6'])) die('skip feature unsupported by this TDS version'); ?> --FILE-- setAttribute(PDO::DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER, true); -var_dump(true === $db->getAttribute(PDO::DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER)); -$db->setAttribute(PDO::DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER, false); -var_dump(false === $db->getAttribute(PDO::DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER)); +$db->setAttribute(Pdo\Dblib::ATTR_STRINGIFY_UNIQUEIDENTIFIER, true); +var_dump(true === $db->getAttribute(Pdo\Dblib::ATTR_STRINGIFY_UNIQUEIDENTIFIER)); +$db->setAttribute(Pdo\Dblib::ATTR_STRINGIFY_UNIQUEIDENTIFIER, false); +var_dump(false === $db->getAttribute(Pdo\Dblib::ATTR_STRINGIFY_UNIQUEIDENTIFIER)); //-------------------------------------------------------------------------------- @@ -54,7 +54,7 @@ var_dump($row['guid'] === $testGUIDBinary); // TODO: something from PDO::ATTR_SERVER_VERSION, PDO::ATTR_CLIENT_VERSION or PDO::ATTR_SERVER_INFO should be used // to get TDS version and skip this test in this case. //-------------------------------------------------------------------------------- -$db->setAttribute(PDO::DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER, true); +$db->setAttribute(Pdo\Dblib::ATTR_STRINGIFY_UNIQUEIDENTIFIER, true); $stmt = $db->query($sql); $row = $stmt->fetch(PDO::FETCH_ASSOC); diff --git a/ext/pdo_dblib/tests/timeout.phpt b/ext/pdo_dblib/tests/timeout.phpt index 08e8ef54ecaba..5f935a3d01b89 100644 --- a/ext/pdo_dblib/tests/timeout.phpt +++ b/ext/pdo_dblib/tests/timeout.phpt @@ -33,7 +33,7 @@ if (!$stmt->execute()) { // pdo_dblib-specific timeout attribute, set after instance created, will control query timeout, causing this query to fail $db = getDbConnection(); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); -$db->setAttribute(PDO::DBLIB_ATTR_QUERY_TIMEOUT, 1); +$db->setAttribute(Pdo\Dblib::ATTR_QUERY_TIMEOUT, 1); $stmt = $db->prepare($sql); if (!$stmt->execute()) { echo "OK\n"; @@ -57,7 +57,7 @@ if (!$stmt->execute()) { } // pdo_dblib-specific timeout attribute will control query timeout, causing this query to fail -$db = getDbConnection(PDO::class, [PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, PDO::DBLIB_ATTR_QUERY_TIMEOUT => 1]); +$db = getDbConnection(PDO::class, [PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, Pdo\Dblib::ATTR_QUERY_TIMEOUT => 1]); $stmt = $db->prepare($sql); if (!$stmt->execute()) { echo "OK\n"; diff --git a/ext/pdo_dblib/tests/types.phpt b/ext/pdo_dblib/tests/types.phpt index a58a969c6f1b0..df04115fee9ee 100644 --- a/ext/pdo_dblib/tests/types.phpt +++ b/ext/pdo_dblib/tests/types.phpt @@ -16,7 +16,7 @@ $db = getDbConnection(); function get_expected_float_string() { global $db; - switch ($db->getAttribute(PDO::DBLIB_ATTR_TDS_VERSION)) { + switch ($db->getAttribute(Pdo\Dblib::ATTR_TDS_VERSION)) { case '5.0': case '6.0': case '7.0': diff --git a/ext/pdo_firebird/pdo_firebird.c b/ext/pdo_firebird/pdo_firebird.c index 0fbdb7f8c97c5..abc43dd3ad587 100644 --- a/ext/pdo_firebird/pdo_firebird.c +++ b/ext/pdo_firebird/pdo_firebird.c @@ -55,11 +55,14 @@ zend_module_entry pdo_firebird_module_entry = { /* {{{ */ ZEND_GET_MODULE(pdo_firebird) #endif +#define REGISTER_PDO_FB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, value) \ + REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, "FB_", "Pdo\\Firebird::", value) + PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */ { - REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_DATE_FORMAT", (zend_long) PDO_FB_ATTR_DATE_FORMAT); - REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIME_FORMAT", (zend_long) PDO_FB_ATTR_TIME_FORMAT); - REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIMESTAMP_FORMAT", (zend_long) PDO_FB_ATTR_TIMESTAMP_FORMAT); + REGISTER_PDO_FB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_DATE_FORMAT", (zend_long) PDO_FB_ATTR_DATE_FORMAT); + REGISTER_PDO_FB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_TIME_FORMAT", (zend_long) PDO_FB_ATTR_TIME_FORMAT); + REGISTER_PDO_FB_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_TIMESTAMP_FORMAT", (zend_long) PDO_FB_ATTR_TIMESTAMP_FORMAT); if (FAILURE == php_pdo_register_driver(&pdo_firebird_driver)) { return FAILURE; diff --git a/ext/pdo_firebird/tests/dialect_1.phpt b/ext/pdo_firebird/tests/dialect_1.phpt index c08b37bf552c1..9b934cd40ec0c 100644 --- a/ext/pdo_firebird/tests/dialect_1.phpt +++ b/ext/pdo_firebird/tests/dialect_1.phpt @@ -14,7 +14,7 @@ require("testdb.inc"); $dbh = getDbConnection(); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); -$dbh->setAttribute(PDO::FB_ATTR_TIMESTAMP_FORMAT, '%Y-%m-%d %H:%M:%S'); +$dbh->setAttribute(Pdo\Firebird::ATTR_TIMESTAMP_FORMAT, '%Y-%m-%d %H:%M:%S'); $sql = 'SELECT diff --git a/ext/pdo_firebird/tests/execute.phpt b/ext/pdo_firebird/tests/execute.phpt index 464c8c29a9c44..cb749956ecfb1 100644 --- a/ext/pdo_firebird/tests/execute.phpt +++ b/ext/pdo_firebird/tests/execute.phpt @@ -12,7 +12,7 @@ $dbh = getDbConnection(); var_dump($dbh->getAttribute(PDO::ATTR_CONNECTION_STATUS)); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); -$dbh->setAttribute(PDO::FB_ATTR_TIMESTAMP_FORMAT, '%Y-%m-%d %H:%M:%S'); +$dbh->setAttribute(Pdo\Firebird::ATTR_TIMESTAMP_FORMAT, '%Y-%m-%d %H:%M:%S'); $dbh->exec("CREATE TABLE test_execute (id SMALLINT NOT NULL PRIMARY KEY, text VARCHAR(32), datetime TIMESTAMP DEFAULT '2000-02-12' NOT NULL)"); diff --git a/ext/pdo_firebird/tests/gh18276.phpt b/ext/pdo_firebird/tests/gh18276.phpt index 610876166ccf7..5a1c4b4de295d 100644 --- a/ext/pdo_firebird/tests/gh18276.phpt +++ b/ext/pdo_firebird/tests/gh18276.phpt @@ -23,9 +23,9 @@ for ($i = 0; $i < 2; $i++) { ], ); // Avoid interned - $dbh->setAttribute(PDO::FB_ATTR_DATE_FORMAT, str_repeat('Y----m----d', random_int(1, 1))); - $dbh->setAttribute(PDO::FB_ATTR_TIME_FORMAT, str_repeat('H::::i::::s', random_int(1, 1))); - $dbh->setAttribute(PDO::FB_ATTR_TIMESTAMP_FORMAT, str_repeat('Y----m----d....H::::i::::s', random_int(1, 1))); + $dbh->setAttribute(Pdo\Firebird::ATTR_DATE_FORMAT, str_repeat('Y----m----d', random_int(1, 1))); + $dbh->setAttribute(Pdo\Firebird::ATTR_TIME_FORMAT, str_repeat('H::::i::::s', random_int(1, 1))); + $dbh->setAttribute(Pdo\Firebird::ATTR_TIMESTAMP_FORMAT, str_repeat('Y----m----d....H::::i::::s', random_int(1, 1))); unset($dbh); } diff --git a/ext/pdo_firebird/tests/php_8.5_deprecations.phpt b/ext/pdo_firebird/tests/php_8.5_deprecations.phpt new file mode 100644 index 0000000000000..6919dda408fd3 --- /dev/null +++ b/ext/pdo_firebird/tests/php_8.5_deprecations.phpt @@ -0,0 +1,23 @@ +--TEST-- +PDO_firebird: PHP 8.5 deprecations +--EXTENSIONS-- +pdo_firebird +--FILE-- + +--EXPECTF-- +Deprecated: Constant PDO::FB_ATTR_DATE_FORMAT is deprecated since 8.5, use Pdo\Firebird::ATTR_DATE_FORMAT instead in %s on line %d + +Deprecated: Constant PDO::FB_ATTR_TIME_FORMAT is deprecated since 8.5, use Pdo\Firebird::ATTR_TIME_FORMAT instead in %s on line %d + +Deprecated: Constant PDO::FB_ATTR_TIMESTAMP_FORMAT is deprecated since 8.5, use Pdo\Firebird::ATTR_TIMESTAMP_FORMAT instead in %s on line %d +int(1000) +int(1001) +int(1002) diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index f0a2a887a5c75..786bd9c606cd1 100644 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -84,7 +84,7 @@ int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int lin "Cannot execute queries while other unbuffered queries are active. " "Consider using PDOStatement::fetchAll(). Alternatively, if your code " "is only ever going to run against mysql, you may enable query " - "buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.", + "buffering by setting the Pdo\\Mysql::ATTR_USE_BUFFERED_QUERY attribute.", dbh->is_persistent); } } else if (einfo->errcode == 2057) { diff --git a/ext/pdo_mysql/pdo_mysql.c b/ext/pdo_mysql/pdo_mysql.c index 772022cdbe937..b45dafbf5d986 100644 --- a/ext/pdo_mysql/pdo_mysql.c +++ b/ext/pdo_mysql/pdo_mysql.c @@ -112,37 +112,40 @@ PHP_INI_END() /* true global environment */ +#define REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, value) \ + REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, "MYSQL_", "Pdo\\Mysql::", value) + /* {{{ PHP_MINIT_FUNCTION */ static PHP_MINIT_FUNCTION(pdo_mysql) { REGISTER_INI_ENTRIES(); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_USE_BUFFERED_QUERY", (zend_long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE", (zend_long)PDO_MYSQL_ATTR_LOCAL_INFILE); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (zend_long)PDO_MYSQL_ATTR_INIT_COMMAND); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_USE_BUFFERED_QUERY", (zend_long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_LOCAL_INFILE", (zend_long)PDO_MYSQL_ATTR_LOCAL_INFILE); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_INIT_COMMAND", (zend_long)PDO_MYSQL_ATTR_INIT_COMMAND); #ifndef PDO_USE_MYSQLND - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_MAX_BUFFER_SIZE", (zend_long)PDO_MYSQL_ATTR_MAX_BUFFER_SIZE); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_FILE", (zend_long)PDO_MYSQL_ATTR_READ_DEFAULT_FILE); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_GROUP", (zend_long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_MAX_BUFFER_SIZE", (zend_long)PDO_MYSQL_ATTR_MAX_BUFFER_SIZE); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_READ_DEFAULT_FILE", (zend_long)PDO_MYSQL_ATTR_READ_DEFAULT_FILE); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_READ_DEFAULT_GROUP", (zend_long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP); #endif - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_COMPRESS", (zend_long)PDO_MYSQL_ATTR_COMPRESS); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_DIRECT_QUERY", (zend_long)PDO_ATTR_EMULATE_PREPARES); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_FOUND_ROWS", (zend_long)PDO_MYSQL_ATTR_FOUND_ROWS); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_IGNORE_SPACE", (zend_long)PDO_MYSQL_ATTR_IGNORE_SPACE); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_KEY", (zend_long)PDO_MYSQL_ATTR_SSL_KEY); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CERT", (zend_long)PDO_MYSQL_ATTR_SSL_CERT); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CA", (zend_long)PDO_MYSQL_ATTR_SSL_CA); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CAPATH", (zend_long)PDO_MYSQL_ATTR_SSL_CAPATH); - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CIPHER", (zend_long)PDO_MYSQL_ATTR_SSL_CIPHER); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_COMPRESS", (zend_long)PDO_MYSQL_ATTR_COMPRESS); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_DIRECT_QUERY", (zend_long)PDO_ATTR_EMULATE_PREPARES); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_FOUND_ROWS", (zend_long)PDO_MYSQL_ATTR_FOUND_ROWS); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_IGNORE_SPACE", (zend_long)PDO_MYSQL_ATTR_IGNORE_SPACE); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_SSL_KEY", (zend_long)PDO_MYSQL_ATTR_SSL_KEY); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_SSL_CERT", (zend_long)PDO_MYSQL_ATTR_SSL_CERT); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_SSL_CA", (zend_long)PDO_MYSQL_ATTR_SSL_CA); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_SSL_CAPATH", (zend_long)PDO_MYSQL_ATTR_SSL_CAPATH); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_SSL_CIPHER", (zend_long)PDO_MYSQL_ATTR_SSL_CIPHER); #if MYSQL_VERSION_ID > 50605 || defined(PDO_USE_MYSQLND) - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SERVER_PUBLIC_KEY", (zend_long)PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_SERVER_PUBLIC_KEY", (zend_long)PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY); #endif - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_MULTI_STATEMENTS", (zend_long)PDO_MYSQL_ATTR_MULTI_STATEMENTS); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_MULTI_STATEMENTS", (zend_long)PDO_MYSQL_ATTR_MULTI_STATEMENTS); #ifdef PDO_USE_MYSQLND - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_VERIFY_SERVER_CERT", (zend_long)PDO_MYSQL_ATTR_SSL_VERIFY_SERVER_CERT); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_SSL_VERIFY_SERVER_CERT", (zend_long)PDO_MYSQL_ATTR_SSL_VERIFY_SERVER_CERT); #endif #if MYSQL_VERSION_ID >= 80021 || defined(PDO_USE_MYSQLND) - REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE_DIRECTORY", (zend_long)PDO_MYSQL_ATTR_LOCAL_INFILE_DIRECTORY); + REGISTER_PDO_MYSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_LOCAL_INFILE_DIRECTORY", (zend_long)PDO_MYSQL_ATTR_LOCAL_INFILE_DIRECTORY); #endif #ifdef PDO_USE_MYSQLND diff --git a/ext/pdo_mysql/tests/bug66528.phpt b/ext/pdo_mysql/tests/bug66528.phpt index 31ae2f42e3a9d..4bddfc9dfcf15 100644 --- a/ext/pdo_mysql/tests/bug66528.phpt +++ b/ext/pdo_mysql/tests/bug66528.phpt @@ -13,7 +13,7 @@ require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $dbh = MySQLPDOTest::factory(); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); +$dbh->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); $dbh->exec('CREATE TABLE test_66528 (a INT) ENGINE=InnoDB'); $dbh->beginTransaction(); @@ -46,6 +46,6 @@ $db = MySQLPDOTest::factory(); $db->exec('DROP TABLE IF EXISTS test_66528'); ?> --EXPECT-- -SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. -SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. -SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. +SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the Pdo\Mysql::ATTR_USE_BUFFERED_QUERY attribute. +SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the Pdo\Mysql::ATTR_USE_BUFFERED_QUERY attribute. +SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the Pdo\Mysql::ATTR_USE_BUFFERED_QUERY attribute. diff --git a/ext/pdo_mysql/tests/bug67004.phpt b/ext/pdo_mysql/tests/bug67004.phpt index 019be3fec9dec..39e19a9ed22c4 100644 --- a/ext/pdo_mysql/tests/bug67004.phpt +++ b/ext/pdo_mysql/tests/bug67004.phpt @@ -14,7 +14,7 @@ $dbh = MySQLPDOTest::factory(); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); -$dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); +$dbh->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $dbh->prepare("SELECT ?"); diff --git a/ext/pdo_mysql/tests/bug68371.phpt b/ext/pdo_mysql/tests/bug68371.phpt index 146b8e4684d26..5b5152dd054a9 100644 --- a/ext/pdo_mysql/tests/bug68371.phpt +++ b/ext/pdo_mysql/tests/bug68371.phpt @@ -16,7 +16,7 @@ $pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $attrs = [ // Extensive test: default value and set+get values PDO::ATTR_EMULATE_PREPARES => array(null, true, false), - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => array(null, false, true), + Pdo\Mysql::ATTR_USE_BUFFERED_QUERY => array(null, false, true), // Just test the default PDO::ATTR_AUTOCOMMIT => [null], diff --git a/ext/pdo_mysql/tests/bug70389.phpt b/ext/pdo_mysql/tests/bug70389.phpt index b4f6bf1afeb48..a8bbab8cc16e0 100644 --- a/ext/pdo_mysql/tests/bug70389.phpt +++ b/ext/pdo_mysql/tests/bug70389.phpt @@ -11,8 +11,8 @@ MySQLPDOTest::skip(); true, - PDO::MYSQL_ATTR_LOCAL_INFILE => true, + Pdo\Mysql::ATTR_FOUND_ROWS => true, + Pdo\Mysql::ATTR_LOCAL_INFILE => true, PDO::ATTR_PERSISTENT => true, ]; diff --git a/ext/pdo_mysql/tests/bug71145.phpt b/ext/pdo_mysql/tests/bug71145.phpt index 0c6f1a549dfb9..b25207152666f 100644 --- a/ext/pdo_mysql/tests/bug71145.phpt +++ b/ext/pdo_mysql/tests/bug71145.phpt @@ -13,7 +13,7 @@ require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $attr = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci; SET SESSION sql_mode=traditional', + Pdo\Mysql::ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci; SET SESSION sql_mode=traditional', PDO::ATTR_STRINGIFY_FETCHES => true, ]; diff --git a/ext/pdo_mysql/tests/bug71569.phpt b/ext/pdo_mysql/tests/bug71569.phpt index fe50b669d845b..975474dd55878 100644 --- a/ext/pdo_mysql/tests/bug71569.phpt +++ b/ext/pdo_mysql/tests/bug71569.phpt @@ -13,7 +13,7 @@ require_once __DIR__ . '/inc/mysql_pdo_test.inc'; try { new PDO(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, [ - PDO::MYSQL_ATTR_INIT_COMMAND => null, + Pdo\Mysql::ATTR_INIT_COMMAND => null, ]); } catch (PDOException $e) { echo $e->getMessage(); diff --git a/ext/pdo_mysql/tests/bug79375.phpt b/ext/pdo_mysql/tests/bug79375.phpt index fb118f1db2d53..07ccd183d45f1 100644 --- a/ext/pdo_mysql/tests/bug79375.phpt +++ b/ext/pdo_mysql/tests/bug79375.phpt @@ -52,7 +52,7 @@ function testPrepareExecute(PDO $db, string $name) { } function testUnbuffered(PDO $db, string $name) { - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); $db->exec("SET innodb_lock_wait_timeout = 1"); $db->exec("START TRANSACTION"); $query = "SELECT first FROM test_79375 WHERE first = 1 FOR UPDATE"; diff --git a/ext/pdo_mysql/tests/bug80458.phpt b/ext/pdo_mysql/tests/bug80458.phpt index aecdca6674ccb..a425c69658e15 100644 --- a/ext/pdo_mysql/tests/bug80458.phpt +++ b/ext/pdo_mysql/tests/bug80458.phpt @@ -97,7 +97,7 @@ var_dump($stmt5->fetchAll()); $db->exec("DROP PROCEDURE IF EXISTS {$procedure_ret}"); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); -$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); +$db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); $stmt = $db->prepare('DELETE FROM test_80458 WHERE first=15'); $stmt->execute(); diff --git a/ext/pdo_mysql/tests/bug80908.phpt b/ext/pdo_mysql/tests/bug80908.phpt index 52b7a40dbb3cc..c00c196d9a668 100644 --- a/ext/pdo_mysql/tests/bug80908.phpt +++ b/ext/pdo_mysql/tests/bug80908.phpt @@ -23,7 +23,7 @@ $db->exec('CREATE TABLE test_80908 (`id` BIGINT(20) UNSIGNED AUTO_INCREMENT, `na function testLastInsertId(PDO $db) { echo "Running test lastInsertId\n"; - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); try { $db->exec("INSERT INTO test_80908 (`name`) VALUES ('bar')"); $id = $db->lastInsertId(); diff --git a/ext/pdo_mysql/tests/bug_42499.phpt b/ext/pdo_mysql/tests/bug_42499.phpt index 6f1534859a0ca..b0c009259e00b 100644 --- a/ext/pdo_mysql/tests/bug_42499.phpt +++ b/ext/pdo_mysql/tests/bug_42499.phpt @@ -28,13 +28,13 @@ function bug_42499($db) { print "Emulated Prepared Statements...\n"; $db = MySQLPDOTest::factory(); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); -$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); +$db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, 1); bug_42499($db); print "Native Prepared Statements...\n"; $db = MySQLPDOTest::factory(); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); -$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); +$db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, 1); bug_42499($db); print "done!"; @@ -55,7 +55,7 @@ array(1) { } } -Warning: PDO::exec(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d +Warning: PDO::exec(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the Pdo\Mysql::ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d Native Prepared Statements... array(1) { [0]=> @@ -65,5 +65,5 @@ array(1) { } } -Warning: PDO::exec(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d +Warning: PDO::exec(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the Pdo\Mysql::ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d done! diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt index ba3054247c2b6..2437e7ca12d16 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt @@ -44,11 +44,11 @@ MySQLPDOTest::skip(); PDO::ATTR_TIMEOUT => 'PDO::ATTR_TIMEOUT', PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES', - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY', - PDO::MYSQL_ATTR_LOCAL_INFILE => 'PDO::MYSQL_ATTR_LOCAL_INFILE', - PDO::MYSQL_ATTR_DIRECT_QUERY => 'PDO::MYSQL_ATTR_DIRECT_QUERY', + Pdo\Mysql::ATTR_USE_BUFFERED_QUERY => 'Pdo\Mysql::ATTR_USE_BUFFERED_QUERY', + Pdo\Mysql::ATTR_LOCAL_INFILE => 'Pdo\Mysql::ATTR_LOCAL_INFILE', + Pdo\Mysql::ATTR_DIRECT_QUERY => 'Pdo\Mysql::ATTR_DIRECT_QUERY', - PDO::MYSQL_ATTR_INIT_COMMAND => 'PDO::MYSQL_ATTR_INIT_COMMAND', + Pdo\Mysql::ATTR_INIT_COMMAND => 'Pdo\Mysql::ATTR_INIT_COMMAND', PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES', ]; @@ -58,12 +58,12 @@ MySQLPDOTest::skip(); /* TODO - why is this a valid option if getAttribute() does not support it?! */ PDO::ATTR_TIMEOUT => false, PDO::ATTR_EMULATE_PREPARES => true, - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, + Pdo\Mysql::ATTR_USE_BUFFERED_QUERY => true, /* TODO getAttribute() does not handle it */ - PDO::MYSQL_ATTR_LOCAL_INFILE => false, + Pdo\Mysql::ATTR_LOCAL_INFILE => false, /* TODO getAttribute() does not handle it */ - PDO::MYSQL_ATTR_DIRECT_QUERY => true, - PDO::MYSQL_ATTR_INIT_COMMAND => '', + Pdo\Mysql::ATTR_DIRECT_QUERY => true, + Pdo\Mysql::ATTR_INIT_COMMAND => '', ]; try { @@ -108,56 +108,56 @@ MySQLPDOTest::skip(); if (!is_object($db = new PDO($dsn, $user, $pass, array(PDO::ATTR_TIMEOUT => -PHP_INT_MAX)))) printf("[008] ATTR_TIMEOUT should be accepted\n"); - /* TODO: Its ugly that PDO::ATTR_EMULATE_PREPARES == PDO::MYSQL_ATTR_DIRECT_QUERY */ + /* TODO: Its ugly that PDO::ATTR_EMULATE_PREPARES == Pdo\Mysql::ATTR_DIRECT_QUERY */ $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => true)); if (!is_object($db)) printf("[009] ATTR_EMULATE_PREPARES should be accepted and on\n"); if (!$db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) printf("[010] [TODO][CHANGEREQUEST] ATTR_EMULATE_PREPARES should be on\n"); - if (!$db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[011] As PDO::MYSQL_ATTR_DIRECT_QUERY == PDO::ATTR_EMULATE_PREPARES - and PDO::ATTR_EMULATE_PREPARES overrules the other, PDO::MYSQL_ATTR_DIRECT_QUERY should be on\n"); + if (!$db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) + printf("[011] As Pdo\Mysql::ATTR_DIRECT_QUERY == PDO::ATTR_EMULATE_PREPARES + and PDO::ATTR_EMULATE_PREPARES overrules the other, Pdo\Mysql::ATTR_DIRECT_QUERY should be on\n"); $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => false)); if (!is_object($db)) printf("[012] ATTR_EMULATE_PREPARES should be accepted and on\n"); if ($db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) printf("[013] [TODO][CHANGEREQUEST] ATTR_EMULATE_PREPARES should be off\n"); - if ($db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[014] As PDO::MYSQL_ATTR_DIRECT_QUERY == PDO::ATTR_EMULATE_PREPARES - and PDO::ATTR_EMULATE_PREPARES overrules the other, PDO::MYSQL_ATTR_DIRECT_QUERY should be off\n"); + if ($db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) + printf("[014] As Pdo\Mysql::ATTR_DIRECT_QUERY == PDO::ATTR_EMULATE_PREPARES + and PDO::ATTR_EMULATE_PREPARES overrules the other, Pdo\Mysql::ATTR_DIRECT_QUERY should be off\n"); - // PDO::ATTR_EMULATE_PREPARES overrules PDO::MYSQL_ATTR_DIRECT_QUERY + // PDO::ATTR_EMULATE_PREPARES overrules Pdo\Mysql::ATTR_DIRECT_QUERY // TODO: is it clever that a generic setting overrules a specific setting? - $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => true, PDO::MYSQL_ATTR_DIRECT_QUERY => false)); + $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => true, Pdo\Mysql::ATTR_DIRECT_QUERY => false)); if (!$db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) printf("[015] PDO::ATTR_EMULATE_PREPARES should be on\n"); - if (!$db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[016] PDO::MYSQL_ATTR_DIRECT_QUERY should be on\n"); + if (!$db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) + printf("[016] Pdo\Mysql::ATTR_DIRECT_QUERY should be on\n"); - $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::MYSQL_ATTR_DIRECT_QUERY => true)); + $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => false, Pdo\Mysql::ATTR_DIRECT_QUERY => true)); if ($db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) printf("[017] PDO::ATTR_EMULATE_PREPARES should be off\n"); - if ($db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[018] PDO::MYSQL_ATTR_DIRECT_QUERY should be off\n"); + if ($db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) + printf("[018] Pdo\Mysql::ATTR_DIRECT_QUERY should be off\n"); - set_option_and_check(19, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true, 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY'); - set_option_and_check(20, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false, 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY'); + set_option_and_check(19, Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true, 'Pdo\Mysql::ATTR_USE_BUFFERED_QUERY'); + set_option_and_check(20, Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false, 'Pdo\Mysql::ATTR_USE_BUFFERED_QUERY'); - set_option_and_check(21, PDO::MYSQL_ATTR_LOCAL_INFILE, true, 'PDO::MYSQL_ATTR_LOCAL_INFILE'); - set_option_and_check(22, PDO::MYSQL_ATTR_LOCAL_INFILE, false, 'PDO::MYSQL_ATTR_LOCAL_INFILE'); + set_option_and_check(21, Pdo\Mysql::ATTR_LOCAL_INFILE, true, 'Pdo\Mysql::ATTR_LOCAL_INFILE'); + set_option_and_check(22, Pdo\Mysql::ATTR_LOCAL_INFILE, false, 'Pdo\Mysql::ATTR_LOCAL_INFILE'); - set_option_and_check(23, PDO::MYSQL_ATTR_INIT_COMMAND, 'SET @a=1', 'PDO::MYSQL_ATTR_INIT_COMMAND'); - set_option_and_check(24, PDO::MYSQL_ATTR_INIT_COMMAND, '', 'PDO::MYSQL_ATTR_INIT_COMMAND'); - set_option_and_check(25, PDO::MYSQL_ATTR_INIT_COMMAND, 'INSERT INTO nonexistent(invalid) VALUES (1)', 'PDO::MYSQL_ATTR_INIT_COMMAND'); + set_option_and_check(23, Pdo\Mysql::ATTR_INIT_COMMAND, 'SET @a=1', 'Pdo\Mysql::ATTR_INIT_COMMAND'); + set_option_and_check(24, Pdo\Mysql::ATTR_INIT_COMMAND, '', 'Pdo\Mysql::ATTR_INIT_COMMAND'); + set_option_and_check(25, Pdo\Mysql::ATTR_INIT_COMMAND, 'INSERT INTO nonexistent(invalid) VALUES (1)', 'Pdo\Mysql::ATTR_INIT_COMMAND'); - set_option_and_check(33, PDO::MYSQL_ATTR_DIRECT_QUERY, true, 'PDO::MYSQL_ATTR_DIRECT_QUERY'); - set_option_and_check(34, PDO::MYSQL_ATTR_DIRECT_QUERY, false, 'PDO::MYSQL_ATTR_DIRECT_QUERY'); + set_option_and_check(33, Pdo\Mysql::ATTR_DIRECT_QUERY, true, 'Pdo\Mysql::ATTR_DIRECT_QUERY'); + set_option_and_check(34, Pdo\Mysql::ATTR_DIRECT_QUERY, false, 'Pdo\Mysql::ATTR_DIRECT_QUERY'); - if (defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) { - set_option_and_check(35, PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY, null, 'PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY'); + if (defined('Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY')) { + set_option_and_check(35, Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY, null, 'Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY'); // libmysqlclient returns the directory with a trailing slash. - // set_option_and_check(36, PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY, __DIR__, 'PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY'); + // set_option_and_check(36, Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY, __DIR__, 'Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY'); } } catch (PDOException $e) { printf("[001] %s, [%s] %s Line: %s\n", @@ -171,12 +171,12 @@ MySQLPDOTest::skip(); ?> --EXPECTF-- [003] [TODO][CHANGEREQUEST] Please, lets not ignore invalid options and bail out! -[003a] Expecting default value for 'PDO::MYSQL_ATTR_INIT_COMMAND' of ''/string, getAttribute() reports setting ''/boolean +[003a] Expecting default value for 'Pdo\Mysql::ATTR_INIT_COMMAND' of ''/string, getAttribute() reports setting ''/boolean [015] PDO::ATTR_EMULATE_PREPARES should be on -[016] PDO::MYSQL_ATTR_DIRECT_QUERY should be on +[016] Pdo\Mysql::ATTR_DIRECT_QUERY should be on [017] PDO::ATTR_EMULATE_PREPARES should be off -[018] PDO::MYSQL_ATTR_DIRECT_QUERY should be off -[023] Expecting 'SET @a=1'/string got ''/boolean' for options 'PDO::MYSQL_ATTR_INIT_COMMAND' +[018] Pdo\Mysql::ATTR_DIRECT_QUERY should be off +[023] Expecting 'SET @a=1'/string got ''/boolean' for options 'Pdo\Mysql::ATTR_INIT_COMMAND' [024] SQLSTATE[42000] [1065] Query was empty [025] SQLSTATE[42S02] [1146] Table '%s.nonexistent' doesn't exist done! diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt index e3d8ee2db6583..c56ee9e5d1e98 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt @@ -36,16 +36,16 @@ if (MySQLPDOTest::isPDOMySQLnd()) $pass = PDO_MYSQL_TEST_PASS; $valid_options = []; - $valid_options[PDO::MYSQL_ATTR_MAX_BUFFER_SIZE] = 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE'; - $valid_options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'PDO::MYSQL_ATTR_INIT_COMMAND'; - $valid_options[PDO::MYSQL_ATTR_READ_DEFAULT_FILE] = 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE'; - $valid_options[PDO::MYSQL_ATTR_READ_DEFAULT_GROUP] = 'PDO::MYSQL_ATTR_READ_DEFAULT_GROUP'; + $valid_options[Pdo\Mysql::ATTR_MAX_BUFFER_SIZE] = 'Pdo\Mysql::ATTR_MAX_BUFFER_SIZE'; + $valid_options[Pdo\Mysql::ATTR_INIT_COMMAND] = 'Pdo\Mysql::ATTR_INIT_COMMAND'; + $valid_options[Pdo\Mysql::ATTR_READ_DEFAULT_FILE] = 'Pdo\Mysql::ATTR_READ_DEFAULT_FILE'; + $valid_options[Pdo\Mysql::ATTR_READ_DEFAULT_GROUP] = 'Pdo\Mysql::ATTR_READ_DEFAULT_GROUP'; - $defaults[PDO::MYSQL_ATTR_MAX_BUFFER_SIZE] = 1048576; + $defaults[Pdo\Mysql::ATTR_MAX_BUFFER_SIZE] = 1048576; /* TODO getAttribute() does not handle it */ - $defaults[PDO::MYSQL_ATTR_INIT_COMMAND] = ''; - $defaults[PDO::MYSQL_ATTR_READ_DEFAULT_FILE] = false; - $defaults[PDO::MYSQL_ATTR_READ_DEFAULT_GROUP] = false; + $defaults[Pdo\Mysql::ATTR_INIT_COMMAND] = ''; + $defaults[Pdo\Mysql::ATTR_READ_DEFAULT_FILE] = false; + $defaults[Pdo\Mysql::ATTR_READ_DEFAULT_GROUP] = false; $db = new PDO($dsn, $user, $pass); foreach ($valid_options as $option => $name) { @@ -60,19 +60,19 @@ if (MySQLPDOTest::isPDOMySQLnd()) } } - set_option_and_check(26, PDO::MYSQL_ATTR_READ_DEFAULT_FILE, true, 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE'); - set_option_and_check(27, PDO::MYSQL_ATTR_READ_DEFAULT_FILE, false, 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE'); + set_option_and_check(26, Pdo\Mysql::ATTR_READ_DEFAULT_FILE, true, 'Pdo\Mysql::ATTR_READ_DEFAULT_FILE'); + set_option_and_check(27, Pdo\Mysql::ATTR_READ_DEFAULT_FILE, false, 'Pdo\Mysql::ATTR_READ_DEFAULT_FILE'); - set_option_and_check(30, PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, -1, 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE', true); - set_option_and_check(31, PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, PHP_INT_MAX, 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE'); - set_option_and_check(32, PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, 1, 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE'); + set_option_and_check(30, Pdo\Mysql::ATTR_MAX_BUFFER_SIZE, -1, 'Pdo\Mysql::ATTR_MAX_BUFFER_SIZE', true); + set_option_and_check(31, Pdo\Mysql::ATTR_MAX_BUFFER_SIZE, PHP_INT_MAX, 'Pdo\Mysql::ATTR_MAX_BUFFER_SIZE'); + set_option_and_check(32, Pdo\Mysql::ATTR_MAX_BUFFER_SIZE, 1, 'Pdo\Mysql::ATTR_MAX_BUFFER_SIZE'); print "done!\n"; ?> --EXPECT-- -Failed to getAttribute() for PDO::MYSQL_ATTR_INIT_COMMAND -Failed to getAttribute() for PDO::MYSQL_ATTR_READ_DEFAULT_FILE -Failed to getAttribute() for PDO::MYSQL_ATTR_READ_DEFAULT_GROUP -Failed to getAttribute() for PDO::MYSQL_ATTR_READ_DEFAULT_FILE -Failed to getAttribute() for PDO::MYSQL_ATTR_READ_DEFAULT_FILE +Failed to getAttribute() for Pdo\Mysql::ATTR_INIT_COMMAND +Failed to getAttribute() for Pdo\Mysql::ATTR_READ_DEFAULT_FILE +Failed to getAttribute() for Pdo\Mysql::ATTR_READ_DEFAULT_GROUP +Failed to getAttribute() for Pdo\Mysql::ATTR_READ_DEFAULT_FILE +Failed to getAttribute() for Pdo\Mysql::ATTR_READ_DEFAULT_FILE done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt index 94db61e00ded4..b9562247af863 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO::MYSQL_ATTR_INIT_COMMAND +Pdo\Mysql::ATTR_INIT_COMMAND --EXTENSIONS-- pdo_mysql --SKIPIF-- @@ -22,7 +22,7 @@ error_reporting=E_ALL $create = sprintf('CREATE TABLE %s(id INT)', $table); var_dump($create); - $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => $create)); + $db = new PDO($dsn, $user, $pass, array(Pdo\Mysql::ATTR_INIT_COMMAND => $create)); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); $info = $db->errorInfo(); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt index 293eb71ca0a02..00a0eb0edc105 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt @@ -1,5 +1,5 @@ --TEST-- -MySQL PDO->__construct(), PDO::MYSQL_ATTR_MAX_BUFFER_SIZE +MySQL PDO->__construct(), Pdo\Mysql::ATTR_MAX_BUFFER_SIZE --EXTENSIONS-- pdo_mysql --SKIPIF-- @@ -7,7 +7,7 @@ pdo_mysql require_once __DIR__ . '/inc/mysql_pdo_test.inc'; MySQLPDOTest::skip(); if (MySQLPDOTest::isPDOMySQLnd()) - die("skip PDO::MYSQL_ATTR_MAX_BUFFER_SIZE not supported with mysqlnd"); + die("skip Pdo\Mysql::ATTR_MAX_BUFFER_SIZE not supported with mysqlnd"); ?> --FILE-- $buffer_size, + Pdo\Mysql::ATTR_MAX_BUFFER_SIZE => $buffer_size, /* buffer is only relevant with native PS */ - PDO::MYSQL_ATTR_DIRECT_QUERY => 0, + Pdo\Mysql::ATTR_DIRECT_QUERY => 0, PDO::ATTR_EMULATE_PREPARES => 0, ]); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt index 7d0256500f555..16f19da7d1b05 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_multi_statements.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO::MYSQL_ATTR_MULTI_STATEMENTS +Pdo\Mysql::ATTR_MULTI_STATEMENTS --EXTENSIONS-- pdo_mysql --SKIPIF-- @@ -37,7 +37,7 @@ error_reporting=E_ALL var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); // New connection, does not allow multiple statements. - $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_MULTI_STATEMENTS => false)); + $db = new PDO($dsn, $user, $pass, array(Pdo\Mysql::ATTR_MULTI_STATEMENTS => false)); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); $stmt = $db->query(sprintf('SELECT * FROM %s; INSERT INTO %s(id) VALUES (3)', $table, $table)); diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt index f308f3384f854..d116aa701a142 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt @@ -47,7 +47,7 @@ MySQLPDOTest::skip(); $have_procedures = false; $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); if ($have_procedures && (false !== $db->exec("DROP PROCEDURE IF EXISTS {$procedure}")) && (false !== $db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT NULL as z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, ' e' AS e; END;"))) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt index 9876ae0759f33..066843fa71f65 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt @@ -55,7 +55,7 @@ function exec_and_count($offset, &$db, $sql, $exp) { } require_once __DIR__ . '/inc/mysql_pdo_test.inc'; -$db = MySQLPDOTest::factoryWithAttr([PDO::MYSQL_ATTR_LOCAL_INFILE=>true]); +$db = MySQLPDOTest::factoryWithAttr([Pdo\Mysql::ATTR_LOCAL_INFILE=>true]); /* affected rows related */ diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt index fe1550776dc55..fc52a20f21720 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt @@ -38,7 +38,7 @@ MySQLPDOTest::skip(); exec_and_count(4, $db, "INSERT INTO test_mysql_exec_select(id, col1) VALUES (1, 'a')", 1); // question is: will the result set be cleaned up, will it be possible to run more queries on the line? // buffered or unbuffered does not matter! - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true); exec_and_count(5, $db, 'SELECT id FROM test_mysql_exec_select', 0); exec_and_count(6, $db, "INSERT INTO test_mysql_exec_select(id, col1) VALUES (2, 'b')", 1); @@ -57,6 +57,6 @@ $db = MySQLPDOTest::factory(); $db->query('DROP TABLE IF EXISTS test_mysql_exec_select'); ?> --EXPECTF-- -Warning: PDO::exec(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d -[006] Expecting '1'/integer got ''/boolean when running 'INSERT INTO test_mysql_exec_select(id, col1) VALUES (2, 'b')', [HY000] HY000 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. +Warning: PDO::exec(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the Pdo\Mysql::ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d +[006] Expecting '1'/integer got ''/boolean when running 'INSERT INTO test_mysql_exec_select(id, col1) VALUES (2, 'b')', [HY000] HY000 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the Pdo\Mysql::ATTR_USE_BUFFERED_QUERY attribute. done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt b/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt index 6e83be8e1a8f9..ba4aeb7051ef4 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt @@ -50,27 +50,27 @@ MySQLPDOTest::skipNotTransactionalEngine(); $obj = new stdClass(); set_and_get(4, $db, PDO::ATTR_AUTOCOMMIT, $obj); - set_and_get(5, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, 1); - set_and_get(6, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, 0); - set_and_get(7, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, -1); + set_and_get(5, $db, Pdo\Mysql::ATTR_LOCAL_INFILE, 1); + set_and_get(6, $db, Pdo\Mysql::ATTR_LOCAL_INFILE, 0); + set_and_get(7, $db, Pdo\Mysql::ATTR_LOCAL_INFILE, -1); $tmp = array(); - set_and_get(8, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, $tmp); + set_and_get(8, $db, Pdo\Mysql::ATTR_LOCAL_INFILE, $tmp); - set_and_get(9, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, ''); - set_and_get(10, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, 'SOME SQL'); - set_and_get(11, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, -1); + set_and_get(9, $db, PPdo\Mysql::ATTR_INIT_COMMAND, ''); + set_and_get(10, $db, PPdo\Mysql::ATTR_INIT_COMMAND, 'SOME SQL'); + set_and_get(11, $db, PPdo\Mysql::ATTR_INIT_COMMAND, -1); */ /* - PDO::MYSQL_ATTR_READ_DEFAULT_FILE (integer) + Pdo\Mysql::ATTR_READ_DEFAULT_FILE (integer) Read options from the named option file instead of from my.cnf. - PDO::MYSQL_ATTR_READ_DEFAULT_GROUP (integer) + Pdo\Mysql::ATTR_READ_DEFAULT_GROUP (integer) Read options from the named group from my.cnf or the file specified with MYSQL_READ_DEFAULT_FILE. - PDO::MYSQL_ATTR_MAX_BUFFER_SIZE (integer) + Pdo\Mysql::ATTR_MAX_BUFFER_SIZE (integer) Maximum buffer size. Defaults to 1 MiB. - PDO::MYSQL_ATTR_DIRECT_QUERY (integer) + Pdo\Mysql::ATTR_DIRECT_QUERY (integer) Perform direct queries, don't use prepared statements. */ diff --git a/ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt b/ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt index 91a67260f0397..af065bd7d9075 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt @@ -6,7 +6,7 @@ pdo_mysql @@ -19,8 +19,8 @@ $user = PDO_MYSQL_TEST_USER; $pass = PDO_MYSQL_TEST_PASS; $db = new PDO($dsn, $user, $pass); -echo var_export($db->getAttribute(PDO::MYSQL_ATTR_LOCAL_INFILE)), "\n"; -echo var_export($db->getAttribute(PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY)), "\n"; +echo var_export($db->getAttribute(Pdo\Mysql::ATTR_LOCAL_INFILE)), "\n"; +echo var_export($db->getAttribute(Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY)), "\n"; echo "done!\n"; ?> --EXPECT-- diff --git a/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_allowed.phpt b/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_allowed.phpt index 2b7f4673ddaf3..7c910e2ba80c6 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_allowed.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_allowed.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY vs access allowed +Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY vs access allowed --EXTENSIONS-- pdo_mysql --SKIPIF-- @@ -7,7 +7,7 @@ pdo_mysql require_once __DIR__ . '/inc/mysql_pdo_test.inc'; MySQLPDOTest::skip(); MySQLPDOTest::skipInfileNotAllowed(); -if (!defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) { +if (!defined('Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY')) { die("skip No MYSQL_ATTR_LOCAL_INFILE_DIRECTORY support"); } ?> @@ -33,8 +33,8 @@ if (!defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) { require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $db = MySQLPDOTest::factoryWithAttr([ - PDO::MYSQL_ATTR_LOCAL_INFILE=>false, - PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo", + Pdo\Mysql::ATTR_LOCAL_INFILE=>false, + Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo", ]); try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_denied.phpt b/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_denied.phpt index ccf2abd4a86d9..58bac57748eaa 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_denied.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_local_infile_directory_denied.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY vs access denied +Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY vs access denied --EXTENSIONS-- pdo_mysql --SKIPIF-- @@ -7,7 +7,7 @@ pdo_mysql require_once __DIR__ . '/inc/mysql_pdo_test.inc'; MySQLPDOTest::skip(); MySQLPDOTest::skipInfileNotAllowed(); -if (!defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) { +if (!defined('Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY')) { die("skip No MYSQL_ATTR_LOCAL_INFILE_DIRECTORY support"); } ?> @@ -33,8 +33,8 @@ if (!defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) { require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $db = MySQLPDOTest::factoryWithAttr([ - PDO::MYSQL_ATTR_LOCAL_INFILE=>false, - PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo/bar", + Pdo\Mysql::ATTR_LOCAL_INFILE=>false, + Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo/bar", ]); try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_local_infile_overrides_local_infile_directory.phpt b/ext/pdo_mysql/tests/pdo_mysql_local_infile_overrides_local_infile_directory.phpt index b99375c37b6ee..d454694ef2c30 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_local_infile_overrides_local_infile_directory.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_local_infile_overrides_local_infile_directory.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO::MYSQL_ATTR_LOCAL_INFILE overrides PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY +Pdo\Mysql::ATTR_LOCAL_INFILE overrides Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY --EXTENSIONS-- pdo_mysql --SKIPIF-- @@ -7,7 +7,7 @@ pdo_mysql require_once __DIR__ . '/inc/mysql_pdo_test.inc'; MySQLPDOTest::skip(); MySQLPDOTest::skipInfileNotAllowed(); -if (!defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) { +if (!defined('Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY')) { die("skip No MYSQL_ATTR_LOCAL_INFILE_DIRECTORY support"); } ?> @@ -33,8 +33,8 @@ if (!defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) { require_once __DIR__ . '/inc/mysql_pdo_test.inc'; $db = MySQLPDOTest::factoryWithAttr([ - PDO::MYSQL_ATTR_LOCAL_INFILE=>true, - PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo/bar", + Pdo\Mysql::ATTR_LOCAL_INFILE=>true, + Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY=>__DIR__."/foo/bar", ]); try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt b/ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt index cbdbc063dd8a1..e5176b44f158b 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt @@ -15,8 +15,8 @@ $dsn = MySQLPDOTest::getDSN(); $user = PDO_MYSQL_TEST_USER; $pass = PDO_MYSQL_TEST_PASS; -$db = new PDO($dsn, $user, $pass, [PDO::MYSQL_ATTR_LOCAL_INFILE => true]); -echo var_export($db->getAttribute(PDO::MYSQL_ATTR_LOCAL_INFILE)), "\n"; +$db = new PDO($dsn, $user, $pass, [Pdo\Mysql::ATTR_LOCAL_INFILE => true]); +echo var_export($db->getAttribute(Pdo\Mysql::ATTR_LOCAL_INFILE)), "\n"; echo "done!\n"; ?> --EXPECT-- diff --git a/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt b/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt index b699dbdaa5719..75abb0ca39d5f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_multi_stmt_nextrowset.phpt @@ -1,5 +1,5 @@ --TEST-- -MySQL PDOStatement->nextRowSet() with PDO::MYSQL_ATTR_MULTI_STATEMENTS either true or false +MySQL PDOStatement->nextRowSet() with Pdo\Mysql::ATTR_MULTI_STATEMENTS either true or false --EXTENSIONS-- pdo_mysql --SKIPIF-- @@ -35,21 +35,21 @@ MySQLPDOTest::skip(); printf("Native PS...\n"); foreach (array(false, true) as $multi) { $value = $multi ? 'true' : 'false'; - echo "\nTesting with PDO::MYSQL_ATTR_MULTI_STATEMENTS set to {$value}\n"; + echo "\nTesting with Pdo\Mysql::ATTR_MULTI_STATEMENTS set to {$value}\n"; $dsn = MySQLPDOTest::getDSN(); $user = PDO_MYSQL_TEST_USER; $pass = PDO_MYSQL_TEST_PASS; - $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_MULTI_STATEMENTS => $multi)); + $db = new PDO($dsn, $user, $pass, array(Pdo\Mysql::ATTR_MULTI_STATEMENTS => $multi)); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, 1); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); test_proc($db); - $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_MULTI_STATEMENTS => $multi)); + $db = new PDO($dsn, $user, $pass, array(Pdo\Mysql::ATTR_MULTI_STATEMENTS => $multi)); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 0); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, 0); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); test_proc($db); @@ -81,7 +81,7 @@ $db->exec('DROP PROCEDURE IF EXISTS pdo_mysql_multi_stmt_nextrowset_p'); --EXPECTF-- Native PS... -Testing with PDO::MYSQL_ATTR_MULTI_STATEMENTS set to false +Testing with Pdo\Mysql::ATTR_MULTI_STATEMENTS set to false array(3) { [0]=> array(1) { @@ -172,7 +172,7 @@ bool(false) Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'INSERT INTO pdo_mysql_multi_stmt_nextrowset (id, label) VALUES (99, 'x')' at line 1 in %s on line %d string(5) "42000" -Testing with PDO::MYSQL_ATTR_MULTI_STATEMENTS set to true +Testing with Pdo\Mysql::ATTR_MULTI_STATEMENTS set to true array(3) { [0]=> array(1) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt index 29074fb5505f5..e8ff3781b350b 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt @@ -82,8 +82,8 @@ MySQLPDOTest::skip(); } try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to switch to emulated prepared statements, test will fail\n"); try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt index f16f9078758ff..f8196bcd61add 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt @@ -13,8 +13,8 @@ MySQLPDOTest::skip(); $db = MySQLPDOTest::factory(); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to switch to emulated prepared statements, test will fail\n"); $db->exec(sprintf('CREATE TABLE test_prepare_emulated_anonymous(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); @@ -33,8 +33,8 @@ MySQLPDOTest::skip(); // now the same with native PS printf("now the same with native PS\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[004] Unable to switch off emulated prepared statements, test will fail\n"); $db->exec('DELETE FROM test_prepare_emulated_anonymous'); diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous_placeholders.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous_placeholders.phpt index ac4f85949bb17..409d9b1f86c0a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous_placeholders.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous_placeholders.phpt @@ -83,8 +83,8 @@ MySQLPDOTest::skip(); } try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to switch to emulated prepared statements, test will fail\n"); try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam.phpt index 8406be4db6d76..fdc82d5ab34bc 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam.phpt @@ -82,8 +82,8 @@ MySQLPDOTest::skip(); } try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to switch to emulated prepared statements, test will fail\n"); try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam_index.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam_index.phpt index 1acc055e12a0c..a94014a183a55 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam_index.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_myisam_index.phpt @@ -85,8 +85,8 @@ MySQLPDOTest::skip(); } try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to switch to emulated prepared statements, test will fail\n"); try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt index 92f14a5b2e9bb..3b356cad3dfc8 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt @@ -15,8 +15,8 @@ MySQLPDOTest::skip(); try { // native PS - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to switch off emulated prepared statements, test will fail\n"); $db->exec(sprintf('CREATE TABLE test_prepare_emulated_placeholder_everywhere(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); @@ -35,8 +35,8 @@ MySQLPDOTest::skip(); // now the same with emulated PS printf("now the same with emulated PS\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[004] Unable to switch on emulated prepared statements, test will fail\n"); $stmt = $db->prepare('SELECT ? FROM test_prepare_emulated_placeholder_everywhere WHERE ? > ?'); diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt index 02690d4164c69..7db84207f19cc 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt @@ -91,8 +91,8 @@ MySQLPDOTest::skip(); } try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_anonymous_placeholder.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_anonymous_placeholder.phpt index db7844b1e6fbf..2ac60de4ae624 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_anonymous_placeholder.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_anonymous_placeholder.phpt @@ -91,8 +91,8 @@ MySQLPDOTest::skip(); } try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt index 5d40bc826233f..68cfa4203cfe7 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt @@ -17,8 +17,8 @@ MySQLPDOTest::skip(); $db->exec(sprintf('CREATE TABLE test_prepare_native_clear_error(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); // We need to run the emulated version first. Native version will cause a fatal error - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); // INSERT a single row @@ -40,8 +40,8 @@ MySQLPDOTest::skip(); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); // Native PS - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[005] Unable to turn off emulated prepared statements\n"); $stmt = $db->prepare('SELECT unknown_column FROM test_prepare_native_clear_error WHERE id > :placeholder ORDER BY id ASC'); diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt index 5786b009500aa..ec63d4a4b7501 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_column.phpt @@ -15,8 +15,8 @@ MySQLPDOTest::skip(); $table = 'pdo_mysql_prepare_native_column'; MySQLPDOTest::createTestTable($table, $db); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); $stmt = $db->prepare("SELECT :param FROM {$table} ORDER BY id ASC LIMIT 1"); diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt index 21bbe8728ed8b..ef38604c449b6 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt @@ -16,8 +16,8 @@ MySQLPDOTest::skip(); try { $db->exec(sprintf('CREATE TABLE test_prepare_native_dup_named(id INT, label1 CHAR(255), label2 CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); printf("Native...\n"); @@ -36,8 +36,8 @@ MySQLPDOTest::skip(); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); // Now the same with emulated PS. - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[004] Unable to turn on emulated prepared statements\n"); printf("Emulated...\n"); @@ -72,8 +72,8 @@ MySQLPDOTest::skip(); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); // native... - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[007] Unable to turn off emulated prepared statements\n"); printf("Native...\n"); diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt index 9e5607fa4cefd..adca8ecfc233d 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_mixed_style.phpt @@ -15,8 +15,8 @@ MySQLPDOTest::skip(); $table = 'pdo_mysql_prepare_native_mixed_style'; MySQLPDOTest::createTestTable($table, $db); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); $stmt = $db->query("DELETE FROM {$table}"); diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam.phpt index c8ede104016a3..c4a4f7c6f3832 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam.phpt @@ -91,8 +91,8 @@ MySQLPDOTest::skip(); } try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam_index.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam_index.phpt index f1547281438ec..e84dd18b957c2 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam_index.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_myisam_index.phpt @@ -91,8 +91,8 @@ MySQLPDOTest::skip(); } try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); try { diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt index 2e23def163345..93bedbe9de74a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt @@ -16,8 +16,8 @@ MySQLPDOTest::skip(); $db->exec(sprintf('CREATE TABLE test_prepare_native_named_placeholder(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); // INSERT a single row @@ -39,8 +39,8 @@ MySQLPDOTest::skip(); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); // Now the same with emulated PS. - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[004] Unable to turn on emulated prepared statements\n"); // Note that the "named placeholder" is enclosed by double quotes. diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt index 575af4a8f2c8f..4afccdc9e2987 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt @@ -14,8 +14,8 @@ MySQLPDOTest::skip(); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to switch on emulated prepared statements, test will fail\n"); $db->exec(sprintf('CREATE TABLE test_prepare_native_named_placeholder_everywhere(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); @@ -31,8 +31,8 @@ MySQLPDOTest::skip(); // now the same with native PS printf("now the same with native PS\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[004] Unable to switch off emulated prepared statements, test_prepare_native_named_placeholder_everywhere will fail\n"); $stmt = $db->prepare('SELECT ?, id, label FROM test_prepare_native_named_placeholder_everywhere WHERE ? = ? ORDER BY id ASC'); diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt index cce3dc9393a37..8f144b611df76 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindcolumn.phpt @@ -16,8 +16,8 @@ MySQLPDOTest::skip(); MySQLPDOTest::createTestTable($table, $db); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); $stmt = $db->prepare("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 2"); @@ -56,8 +56,8 @@ MySQLPDOTest::skip(); $index++; } - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[007] Unable to turn off emulated prepared statements\n"); $stmt = $db->prepare("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 2, 2"); diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt index b0bbad59d8e92..92e6f446e1b36 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam.phpt @@ -84,32 +84,32 @@ MySQLPDOTest::skip(); try { printf("Emulated PS...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); printf("Buffered...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true); pdo_mysql_stmt_bindparam($db, 3); printf("Unbuffered...\n"); MySQLPDOTest::createTestTable($table, $db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); pdo_mysql_stmt_bindparam($db, 4); printf("Native PS...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[004] Unable to turn off emulated prepared statements\n"); printf("Buffered...\n"); MySQLPDOTest::createTestTable($table, $db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true); pdo_mysql_stmt_bindparam($db, 5); printf("Unbuffered...\n"); MySQLPDOTest::createTestTable($table, $db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); pdo_mysql_stmt_bindparam($db, 6); } catch (PDOException $e) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt index b315c97b91203..fde08dfa6932a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindparam_types.phpt @@ -14,9 +14,9 @@ MySQLPDOTest::skip(); function pdo_mysql_stmt_bindparam_types_do($db, $offset, $native, $sql_type, $value) { if ($native) - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); else - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); $sql = sprintf('CREATE TABLE test_stmt_bindparam_types(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); if ((!$stmt = $db->prepare($sql)) || (!$stmt->execute())) diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt index c558eb6f81dad..7d214e0c7e239 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_bindvalue.phpt @@ -17,8 +17,8 @@ MySQLPDOTest::skip(); printf("Testing native PS...\n"); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); printf("Binding variable...\n"); @@ -157,8 +157,8 @@ MySQLPDOTest::skip(); printf("Testing emulated PS...\n"); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); printf("Binding variable...\n"); diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt index af052a02423ff..65dfbb660bc3a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor.phpt @@ -21,7 +21,7 @@ MySQLPDOTest::skip(); // This one should fail. I let it fail to prove that closeCursor() makes a difference. // If no error messages gets printed do not know if proper usage of closeCursor() makes any // difference or not. That's why we need to cause an error here. - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); $stmt1 = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC"); // query() shall fail! $stmt2 = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC"); @@ -46,7 +46,7 @@ MySQLPDOTest::skip(); $stmt2->execute(); $stmt2->closeCursor(); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true); // check if changing the fetch mode from unbuffered to buffered will // cause any harm to a statement created prior to the change $stmt1->execute(); @@ -110,33 +110,33 @@ MySQLPDOTest::skip(); try { printf("Testing emulated PS...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); printf("Buffered...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true); MySQLPDOTest::createTestTable($table, $db); pdo_mysql_stmt_closecursor($db); printf("Unbuffered...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); MySQLPDOTest::createTestTable($table, $db); pdo_mysql_stmt_closecursor($db); printf("Testing native PS...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); printf("Buffered...\n"); MySQLPDOTest::createTestTable($table, $db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true); pdo_mysql_stmt_closecursor($db); printf("Unbuffered...\n"); MySQLPDOTest::createTestTable($table, $db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); pdo_mysql_stmt_closecursor($db); } catch (PDOException $e) { @@ -156,23 +156,23 @@ $db->exec('DROP TABLE IF EXISTS pdo_mysql_stmt_closecursor'); Testing emulated PS... Buffered... -Warning: PDO::query(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d +Warning: PDO::query(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the Pdo\Mysql::ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d in = 0 -> id = 1 (integer) / label = 'a' (string) in = 0 -> id = 2 (integer) / label = 'b' (string) Unbuffered... -Warning: PDO::query(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d +Warning: PDO::query(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the Pdo\Mysql::ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d in = 0 -> id = 1 (integer) / label = 'a' (string) in = 0 -> id = 2 (integer) / label = 'b' (string) Testing native PS... Buffered... -Warning: PDO::query(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d +Warning: PDO::query(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the Pdo\Mysql::ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d in = 0 -> id = 1 (integer) / label = 'a' (string) in = 0 -> id = 2 (integer) / label = 'b' (string) Unbuffered... -Warning: PDO::query(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d +Warning: PDO::query(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the Pdo\Mysql::ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d in = 0 -> id = 1 (integer) / label = 'a' (string) in = 0 -> id = 2 (integer) / label = 'b' (string) done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt index 33127f4ee242f..b0880f3548985 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_closecursor_empty.phpt @@ -16,11 +16,11 @@ MySQLPDOTest::skip(); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); MySQLPDOTest::createTestTable($table, $db); $stmt = $db->prepare("SELECT id, label FROM {$table} WHERE id > ? ORDER BY id ASC LIMIT 2"); diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt index b55725057e234..81d2bd6386e3a 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt @@ -20,8 +20,8 @@ MySQLPDOTest::skip(); // Internal data structures should be the same in both cases. printf("Testing emulated PS...\n"); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); $stmt = $db->prepare("SELECT id, label, '?' as foo FROM {$table}"); @@ -38,8 +38,8 @@ MySQLPDOTest::skip(); printf("Testing native PS...\n"); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[004] Unable to turn off emulated prepared statements\n"); $stmt = $db->prepare("SELECT id, label, '?' as foo, 'TODO - Stored Procedure' as bar FROM {$table}"); diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt index de4cb8b97bfb6..8602fa7b36008 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorcode.phpt @@ -16,8 +16,8 @@ MySQLPDOTest::skip(); printf("Testing emulated PS...\n"); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); $stmt = $db->prepare('SELECT id FROM pdo_mysql_stmt_errorcode_ihopeitdoesnotexist ORDER BY id ASC'); @@ -32,8 +32,8 @@ MySQLPDOTest::skip(); printf("Testing native PS...\n"); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[004] Unable to turn off emulated prepared statements\n"); $stmt = $db->prepare('SELECT id FROM pdo_mysql_stmt_errorcode_ihopeitdoesnotexist ORDER BY id ASC'); diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt index 6b2a9281d9c21..04fb7d802e62b 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt @@ -17,8 +17,8 @@ MySQLPDOTest::skip(); printf("Testing emulated PS...\n"); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); $stmt = $db->prepare('SELECT id FROM pdo_mysql_stmt_errorinfo_ihopeitdoesnotexist ORDER BY id ASC'); @@ -40,8 +40,8 @@ MySQLPDOTest::skip(); printf("Testing native PS...\n"); try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[004] Unable to turn off emulated prepared statements\n"); $stmt = $db->prepare('SELECT id FROM pdo_mysql_stmt_errorinfo_ihopeitdoesnotexist ORDER BY id ASC'); diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_class.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_class.phpt index 4d5db44ea91b4..20259b8d49299 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_class.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_class.phpt @@ -75,8 +75,8 @@ MySQLPDOTest::skip(); } - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); $db->exec(sprintf('CREATE TABLE test_stmt_fetch_class(id INT, myobj BLOB) ENGINE=%s', diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt index 0027d1ea52ff9..421276c570d7f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt @@ -18,8 +18,8 @@ MySQLPDOTest::skip(); try { // Emulated PS first - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn on emulated prepared statements\n"); if (!is_object($stmt = $db->query("DESCRIBE {$table} id"))) @@ -68,8 +68,8 @@ MySQLPDOTest::skip(); printf("[010] Emulated PS, EXPLAIN returned no results\n"); // And now native PS - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[011] Unable to turn off emulated prepared statements\n"); $native_support = 'no'; diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt index 8aaf65f52d9ea..fd2b6cb5e4a77 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize.phpt @@ -75,8 +75,8 @@ MySQLPDOTest::skip(); } - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); $db->exec(sprintf('CREATE TABLE test_stmt_fetch_serialize(id INT, myobj BLOB) ENGINE=%s', diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_fetch_class.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_fetch_class.phpt index f2f6c89ad3897..1d3c7f69fab96 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_fetch_class.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_fetch_class.phpt @@ -75,8 +75,8 @@ MySQLPDOTest::skip(); } - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[002] Unable to turn off emulated prepared statements\n"); $db->exec(sprintf('CREATE TABLE test_stmt_fetchserialize_fetch_class(id INT, myobj BLOB) ENGINE=%s', diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt index 0552a87aa42d9..9b09491e0cbf7 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt @@ -37,8 +37,8 @@ try { $emulated = $stmt->getColumnMeta(0); printf("Testing native PS...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[007] Unable to turn off emulated prepared statements\n"); $stmt = $db->prepare('SELECT id FROM test_stmt_getcolumnmeta ORDER BY id ASC'); diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt index df2d3b402d83d..0415a04fdab6f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_nextrowset.phpt @@ -63,14 +63,14 @@ MySQLPDOTest::skipNotMySQLnd(); printf("Emulated PS...\n"); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, 1); test_proc1($db); test_proc2($db); $db = MySQLPDOTest::factory(); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 0); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, 0); test_proc1($db); test_proc2($db); @@ -78,14 +78,14 @@ MySQLPDOTest::skipNotMySQLnd(); printf("Native PS...\n"); $db = MySQLPDOTest::factory(); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, 1); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); test_proc1($db); test_proc2($db); $db = MySQLPDOTest::factory(); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 0); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, 0); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); test_proc1($db); diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt index aca3e6a084cbd..fcba9e44e694c 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_unbuffered_2050.phpt @@ -18,13 +18,13 @@ if (MYSQLPDOTest::isPDOMySQLnd()) try { printf("Native PS...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + $db->setAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(Pdo\Mysql::ATTR_DIRECT_QUERY)) printf("[004] Unable to turn off emulated prepared statements\n"); printf("Buffered...\n"); MySQLPDOTest::createTestTable($table, $db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true); $stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 1"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); $stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 1"); @@ -32,7 +32,7 @@ if (MYSQLPDOTest::isPDOMySQLnd()) printf("Unbuffered...\n"); MySQLPDOTest::createTestTable($table, $db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, false); $stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 1"); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); /* diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt index fb35381769744..48353f4cbdb3c 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_variable_columncount.phpt @@ -57,7 +57,7 @@ MySQLPDOTest::skip(); // Libmysql cannot handle such a stored procedure. You will see leaks with libmysql $db = MySQLPDOTest::factory(); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, 1); $stmt = $db->prepare("CALL {$procedure}(?)"); $stmt->bindParam(1, $columns); for ($i = 5; $i < 10; $i++) { @@ -88,7 +88,7 @@ MySQLPDOTest::skip(); // Libmysql cannot handle such a stored procedure. You will see leaks with libmysql $db = MySQLPDOTest::factory(); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); + $db->setAttribute(Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, 1); $db->exec('SET @numcols = 1'); $stmt = $db->prepare("CALL {$procedure}()"); $stmt->execute(); diff --git a/ext/pdo_mysql/tests/php_8.5_deprecations.phpt b/ext/pdo_mysql/tests/php_8.5_deprecations.phpt new file mode 100644 index 0000000000000..4d163c2f48cdc --- /dev/null +++ b/ext/pdo_mysql/tests/php_8.5_deprecations.phpt @@ -0,0 +1,81 @@ +--TEST-- +PDO_mysql: PHP 8.5 deprecations +--EXTENSIONS-- +pdo_mysql +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Deprecated: Constant PDO::MYSQL_ATTR_USE_BUFFERED_QUERY is deprecated since 8.5, use Pdo\Mysql::ATTR_USE_BUFFERED_QUERY instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_LOCAL_INFILE is deprecated since 8.5, use Pdo\Mysql::ATTR_LOCAL_INFILE instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY is deprecated since 8.5, use Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_INIT_COMMAND is deprecated since 8.5, use Pdo\Mysql::ATTR_INIT_COMMAND instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_COMPRESS is deprecated since 8.5, use Pdo\Mysql::ATTR_COMPRESS instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_DIRECT_QUERY is deprecated since 8.5, use Pdo\Mysql::ATTR_DIRECT_QUERY instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_FOUND_ROWS is deprecated since 8.5, use Pdo\Mysql::ATTR_FOUND_ROWS instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_IGNORE_SPACE is deprecated since 8.5, use Pdo\Mysql::ATTR_IGNORE_SPACE instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_SSL_KEY is deprecated since 8.5, use Pdo\Mysql::ATTR_SSL_KEY instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_SSL_CERT is deprecated since 8.5, use Pdo\Mysql::ATTR_SSL_CERT instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_SSL_CA is deprecated since 8.5, use Pdo\Mysql::ATTR_SSL_CA instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_SSL_CAPATH is deprecated since 8.5, use Pdo\Mysql::ATTR_SSL_CAPATH instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_SSL_CIPHER is deprecated since 8.5, use Pdo\Mysql::ATTR_SSL_CIPHER instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT is deprecated since 8.5, use Pdo\Mysql::ATTR_SSL_VERIFY_SERVER_CERT instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_SERVER_PUBLIC_KEY is deprecated since 8.5, use Pdo\Mysql::ATTR_SERVER_PUBLIC_KEY instead in %s on line %d + +Deprecated: Constant PDO::MYSQL_ATTR_MULTI_STATEMENTS is deprecated since 8.5, use Pdo\Mysql::ATTR_MULTI_STATEMENTS instead in %s on line %d +int(1000) +int(1001) +int(1014) +int(1002) +int(1003) +int(20) +int(1004) +int(1005) +int(1006) +int(1007) +int(1008) +int(1009) +int(1010) +int(1013) +int(1011) +int(1012) diff --git a/ext/pdo_odbc/pdo_odbc.c b/ext/pdo_odbc/pdo_odbc.c index 1052322fe8cfe..1181e314c4d0d 100644 --- a/ext/pdo_odbc/pdo_odbc.c +++ b/ext/pdo_odbc/pdo_odbc.c @@ -61,6 +61,9 @@ zend_ulong pdo_odbc_pool_on = SQL_CP_OFF; zend_ulong pdo_odbc_pool_mode = SQL_CP_ONE_PER_HENV; #endif +#define REGISTER_PDO_ODBC_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, value) \ + REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, "ODBC_", "Pdo\\Odbc::", value) + /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(pdo_odbc) { @@ -101,11 +104,11 @@ PHP_MINIT_FUNCTION(pdo_odbc) register_pdo_odbc_symbols(module_number); - REGISTER_PDO_CLASS_CONST_LONG("ODBC_ATTR_USE_CURSOR_LIBRARY", PDO_ODBC_ATTR_USE_CURSOR_LIBRARY); - REGISTER_PDO_CLASS_CONST_LONG("ODBC_ATTR_ASSUME_UTF8", PDO_ODBC_ATTR_ASSUME_UTF8); - REGISTER_PDO_CLASS_CONST_LONG("ODBC_SQL_USE_IF_NEEDED", SQL_CUR_USE_IF_NEEDED); - REGISTER_PDO_CLASS_CONST_LONG("ODBC_SQL_USE_DRIVER", SQL_CUR_USE_DRIVER); - REGISTER_PDO_CLASS_CONST_LONG("ODBC_SQL_USE_ODBC", SQL_CUR_USE_ODBC); + REGISTER_PDO_ODBC_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_USE_CURSOR_LIBRARY", PDO_ODBC_ATTR_USE_CURSOR_LIBRARY); + REGISTER_PDO_ODBC_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_ASSUME_UTF8", PDO_ODBC_ATTR_ASSUME_UTF8); + REGISTER_PDO_ODBC_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("SQL_USE_IF_NEEDED", SQL_CUR_USE_IF_NEEDED); + REGISTER_PDO_ODBC_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("SQL_USE_DRIVER", SQL_CUR_USE_DRIVER); + REGISTER_PDO_ODBC_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("SQL_USE_ODBC", SQL_CUR_USE_ODBC); pdo_odbc_ce = register_class_Pdo_Odbc(pdo_dbh_ce); pdo_odbc_ce->create_object = pdo_dbh_new; diff --git a/ext/pdo_odbc/tests/bug80783a.phpt b/ext/pdo_odbc/tests/bug80783a.phpt index ab141588e1b4e..d8987cfd0ac3e 100644 --- a/ext/pdo_odbc/tests/bug80783a.phpt +++ b/ext/pdo_odbc/tests/bug80783a.phpt @@ -22,7 +22,7 @@ $string = str_repeat("0123456789", 50); $db->exec("INSERT INTO bug80783a VALUES('$string')"); $stmt = $db->prepare("SELECT name FROM bug80783a"); -$stmt->setAttribute(PDO::ODBC_ATTR_ASSUME_UTF8, true); +$stmt->setAttribute(Pdo\Odbc::ATTR_ASSUME_UTF8, true); $stmt->bindColumn(1, $data, PDO::PARAM_STR); $stmt->execute(); $stmt->fetch(PDO::FETCH_BOUND); diff --git a/ext/pdo_odbc/tests/php_8.5_deprecations.phpt b/ext/pdo_odbc/tests/php_8.5_deprecations.phpt new file mode 100644 index 0000000000000..54be2339f6cf2 --- /dev/null +++ b/ext/pdo_odbc/tests/php_8.5_deprecations.phpt @@ -0,0 +1,31 @@ +--TEST-- +PDO_odbc: PHP 8.5 deprecations +--EXTENSIONS-- +pdo_odbc +--FILE-- + +--EXPECTF-- +Deprecated: Constant PDO::ODBC_ATTR_USE_CURSOR_LIBRARY is deprecated since 8.5, use Pdo\Odbc::ATTR_USE_CURSOR_LIBRARY instead in %s on line %d + +Deprecated: Constant PDO::ODBC_ATTR_ASSUME_UTF8 is deprecated since 8.5, use Pdo\Odbc::ATTR_ASSUME_UTF8 instead in %s on line %d + +Deprecated: Constant PDO::ODBC_SQL_USE_IF_NEEDED is deprecated since 8.5, use Pdo\Odbc::SQL_USE_IF_NEEDED instead in %s on line %d + +Deprecated: Constant PDO::ODBC_SQL_USE_DRIVER is deprecated since 8.5, use Pdo\Odbc::SQL_USE_DRIVER instead in %s on line %d + +Deprecated: Constant PDO::ODBC_SQL_USE_ODBC is deprecated since 8.5, use Pdo\Odbc::SQL_USE_ODBC instead in %s on line %d +int(1000) +int(1001) +int(0) +int(2) +int(1) diff --git a/ext/pdo_pgsql/pdo_pgsql.c b/ext/pdo_pgsql/pdo_pgsql.c index 49efa0b238484..e6849aed1195e 100644 --- a/ext/pdo_pgsql/pdo_pgsql.c +++ b/ext/pdo_pgsql/pdo_pgsql.c @@ -175,15 +175,18 @@ PHP_METHOD(Pdo_Pgsql, setNoticeCallback) /* true global environment */ +#define REGISTER_PDO_PGSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, value) \ + REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, "PGSQL_", "Pdo\\Pgsql::", value) + /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(pdo_pgsql) { - REGISTER_PDO_CLASS_CONST_LONG("PGSQL_ATTR_DISABLE_PREPARES", PDO_PGSQL_ATTR_DISABLE_PREPARES); - REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_IDLE", (zend_long)PGSQL_TRANSACTION_IDLE); - REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_ACTIVE", (zend_long)PGSQL_TRANSACTION_ACTIVE); - REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INTRANS", (zend_long)PGSQL_TRANSACTION_INTRANS); - REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INERROR", (zend_long)PGSQL_TRANSACTION_INERROR); - REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_UNKNOWN", (zend_long)PGSQL_TRANSACTION_UNKNOWN); + REGISTER_PDO_PGSQL_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_DISABLE_PREPARES", PDO_PGSQL_ATTR_DISABLE_PREPARES); + REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_85("PGSQL_TRANSACTION_IDLE", (zend_long)PGSQL_TRANSACTION_IDLE); + REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_85("PGSQL_TRANSACTION_ACTIVE", (zend_long)PGSQL_TRANSACTION_ACTIVE); + REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_85("PGSQL_TRANSACTION_INTRANS", (zend_long)PGSQL_TRANSACTION_INTRANS); + REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_85("PGSQL_TRANSACTION_INERROR", (zend_long)PGSQL_TRANSACTION_INERROR); + REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_85("PGSQL_TRANSACTION_UNKNOWN", (zend_long)PGSQL_TRANSACTION_UNKNOWN); PdoPgsql_ce = register_class_Pdo_Pgsql(pdo_dbh_ce); PdoPgsql_ce->create_object = pdo_dbh_new; diff --git a/ext/pdo_pgsql/tests/bug68371.phpt b/ext/pdo_pgsql/tests/bug68371.phpt index 6569abf3071fd..13fd1913274d5 100644 --- a/ext/pdo_pgsql/tests/bug68371.phpt +++ b/ext/pdo_pgsql/tests/bug68371.phpt @@ -18,7 +18,7 @@ $pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $attrs = array( // Extensive test: default value and set+get values PDO::ATTR_EMULATE_PREPARES => array(null, true, false), - PDO::PGSQL_ATTR_DISABLE_PREPARES => array(null, true, false), + Pdo\Pgsql::ATTR_DISABLE_PREPARES => array(null, true, false), // Just test the default PDO::ATTR_AUTOCOMMIT => array(null), diff --git a/ext/pdo_pgsql/tests/bug73959.phpt b/ext/pdo_pgsql/tests/bug73959.phpt index 34b68f9825c73..918743ff4383e 100644 --- a/ext/pdo_pgsql/tests/bug73959.phpt +++ b/ext/pdo_pgsql/tests/bug73959.phpt @@ -15,7 +15,7 @@ require __DIR__ . '/config.inc'; $db = PDOTest::test_factory(__DIR__ . '/common.phpt'); $db->setAttribute(PDO::ATTR_PERSISTENT, false); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true); +$db->setAttribute(Pdo\Pgsql::ATTR_DISABLE_PREPARES, true); try { $db->lastInsertId('nonexistent_seq'); diff --git a/ext/pdo_pgsql/tests/disable_prepares.phpt b/ext/pdo_pgsql/tests/disable_prepares.phpt index 58f3a4b00c1fb..b184e9bc6db68 100644 --- a/ext/pdo_pgsql/tests/disable_prepares.phpt +++ b/ext/pdo_pgsql/tests/disable_prepares.phpt @@ -28,7 +28,7 @@ $stmt->execute(); $first = $stmt->fetchAll(); $stmt3 = $db->prepare("SELECT (?)::int4", array( - PDO::PGSQL_ATTR_DISABLE_PREPARES => true)); + Pdo\Pgsql::ATTR_DISABLE_PREPARES => true)); $stmt3->execute(array(3)); var_dump($stmt3->fetch()); $stmt3->execute(array(4)); diff --git a/ext/pdo_pgsql/tests/gh15287.phpt b/ext/pdo_pgsql/tests/gh15287.phpt index 72bcc44b363b4..821c22a8f1c5a 100644 --- a/ext/pdo_pgsql/tests/gh15287.phpt +++ b/ext/pdo_pgsql/tests/gh15287.phpt @@ -75,8 +75,8 @@ for ($i = -1; ++$i < 5;) { while (($re = $stmt->fetch())) { $res[] = $re; // Memory introspection relies on an optionally-compiled constant. - if (defined('PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE')) { - $mem = $stmt->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE); + if (defined('Pdo\Pgsql::ATTR_RESULT_MEMORY_SIZE')) { + $mem = $stmt->getAttribute(Pdo\Pgsql::ATTR_RESULT_MEMORY_SIZE); } else { // If not there emulate a return value which validates our test. $mem = $lazy ? 0 : 1; diff --git a/ext/pdo_pgsql/tests/is_in_transaction.phpt b/ext/pdo_pgsql/tests/is_in_transaction.phpt index 440044f66a578..982357db9210a 100644 --- a/ext/pdo_pgsql/tests/is_in_transaction.phpt +++ b/ext/pdo_pgsql/tests/is_in_transaction.phpt @@ -19,7 +19,7 @@ $db->exec('CREATE TABLE test_is_in_transaction (a integer not null primary key, $db->beginTransaction(); try { -echo "Test PDO::PGSQL_TRANSACTION_INTRANS\n"; +echo "Test Pdo\Pgsql::TRANSACTION_INTRANS\n"; var_dump($db->inTransaction()); $stmt = $db->prepare("INSERT INTO test_is_in_transaction (a, b) values (?, ?)"); @@ -29,7 +29,7 @@ $stmt->execute(); $db->commit(); -echo "Test PDO::PGSQL_TRANSACTION_IDLE\n"; +echo "Test Pdo\Pgsql::TRANSACTION_IDLE\n"; var_dump($db->inTransaction()); $db->beginTransaction(); @@ -40,13 +40,13 @@ $stmt->bindValue(1, "error"); $stmt->bindValue(2, "test insert"); $stmt->execute(); } catch (Exception $e) { - /* We catch the exception because the execute will give error and we must test the PDO::PGSQL_TRANSACTION_ERROR */ - echo "Test PDO::PGSQL_TRANSACTION_INERROR\n"; + /* We catch the exception because the execute will give error and we must test the Pdo\Pgsql::TRANSACTION_ERROR */ + echo "Test Pdo\Pgsql::TRANSACTION_INERROR\n"; var_dump($db->inTransaction()); $db->rollBack(); } -echo "Test PDO::PGSQL_TRANSACTION_IDLE\n"; +echo "Test Pdo\Pgsql::TRANSACTION_IDLE\n"; var_dump($db->inTransaction()); } catch (Exception $e) { @@ -62,11 +62,11 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt'); $db->exec('DROP TABLE test_is_in_transaction'); ?> --EXPECT-- -Test PDO::PGSQL_TRANSACTION_INTRANS +Test Pdo\Pgsql::TRANSACTION_INTRANS bool(true) -Test PDO::PGSQL_TRANSACTION_IDLE +Test Pdo\Pgsql::TRANSACTION_IDLE bool(false) -Test PDO::PGSQL_TRANSACTION_INERROR +Test Pdo\Pgsql::TRANSACTION_INERROR bool(true) -Test PDO::PGSQL_TRANSACTION_IDLE +Test Pdo\Pgsql::TRANSACTION_IDLE bool(false) diff --git a/ext/pdo_pgsql/tests/php_8.5_deprecations.phpt b/ext/pdo_pgsql/tests/php_8.5_deprecations.phpt new file mode 100644 index 0000000000000..816850853e144 --- /dev/null +++ b/ext/pdo_pgsql/tests/php_8.5_deprecations.phpt @@ -0,0 +1,15 @@ +--TEST-- +PDO_pgsql: PHP 8.5 deprecations +--EXTENSIONS-- +pdo_pgsql +--FILE-- + +--EXPECTF-- +Deprecated: Constant PDO::PGSQL_ATTR_DISABLE_PREPARES is deprecated since 8.5, use Pdo\Pgsql::ATTR_DISABLE_PREPARES instead in %s on line %d +int(1000) diff --git a/ext/pdo_sqlite/pdo_sqlite.c b/ext/pdo_sqlite/pdo_sqlite.c index 023e35a2bc33c..667948fea9f1f 100644 --- a/ext/pdo_sqlite/pdo_sqlite.c +++ b/ext/pdo_sqlite/pdo_sqlite.c @@ -404,19 +404,22 @@ PHP_METHOD(Pdo_Sqlite, createCollation) pdo_sqlite_create_collation_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_sqlite_collation_callback); } +#define REGISTER_PDO_SQLITE_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, value) \ + REGISTER_PDO_CLASS_CONST_LONG_DEPRECATED_ALIAS_85(base_name, "SQLITE_", "Pdo\\Sqlite::", value) + /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(pdo_sqlite) { #ifdef SQLITE_DETERMINISTIC - REGISTER_PDO_CLASS_CONST_LONG("SQLITE_DETERMINISTIC", (zend_long)SQLITE_DETERMINISTIC); + REGISTER_PDO_SQLITE_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("DETERMINISTIC", (zend_long)SQLITE_DETERMINISTIC); #endif - REGISTER_PDO_CLASS_CONST_LONG("SQLITE_ATTR_OPEN_FLAGS", (zend_long)PDO_SQLITE_ATTR_OPEN_FLAGS); - REGISTER_PDO_CLASS_CONST_LONG("SQLITE_OPEN_READONLY", (zend_long)SQLITE_OPEN_READONLY); - REGISTER_PDO_CLASS_CONST_LONG("SQLITE_OPEN_READWRITE", (zend_long)SQLITE_OPEN_READWRITE); - REGISTER_PDO_CLASS_CONST_LONG("SQLITE_OPEN_CREATE", (zend_long)SQLITE_OPEN_CREATE); - REGISTER_PDO_CLASS_CONST_LONG("SQLITE_ATTR_READONLY_STATEMENT", (zend_long)PDO_SQLITE_ATTR_READONLY_STATEMENT); - REGISTER_PDO_CLASS_CONST_LONG("SQLITE_ATTR_EXTENDED_RESULT_CODES", (zend_long)PDO_SQLITE_ATTR_EXTENDED_RESULT_CODES); + REGISTER_PDO_SQLITE_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_OPEN_FLAGS", (zend_long)PDO_SQLITE_ATTR_OPEN_FLAGS); + REGISTER_PDO_SQLITE_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("OPEN_READONLY", (zend_long)SQLITE_OPEN_READONLY); + REGISTER_PDO_SQLITE_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("OPEN_READWRITE", (zend_long)SQLITE_OPEN_READWRITE); + REGISTER_PDO_SQLITE_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("OPEN_CREATE", (zend_long)SQLITE_OPEN_CREATE); + REGISTER_PDO_SQLITE_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_READONLY_STATEMENT", (zend_long)PDO_SQLITE_ATTR_READONLY_STATEMENT); + REGISTER_PDO_SQLITE_CLASS_CONST_LONG_DEPRECATED_ALIAS_85("ATTR_EXTENDED_RESULT_CODES", (zend_long)PDO_SQLITE_ATTR_EXTENDED_RESULT_CODES); pdosqlite_ce = register_class_Pdo_Sqlite(pdo_dbh_ce); pdosqlite_ce->create_object = pdo_dbh_new; diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt index f9312bcee69e9..d1d31d6cad632 100644 --- a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt @@ -4,7 +4,7 @@ PDO_sqlite: Testing sqliteCreateFunction() with flags pdo_sqlite --SKIPIF-- --FILE-- query('CREATE TABLE test_pdo_sqlite_createfunction_with_flags (id INT AUTO $db->query('INSERT INTO test_pdo_sqlite_createfunction_with_flags VALUES (NULL, "PHP"), (NULL, "PHP6")'); -$db->sqliteCreateFunction('testing', function($v) { return strtolower($v); }, 1, PDO::SQLITE_DETERMINISTIC); +$db->sqliteCreateFunction('testing', function($v) { return strtolower($v); }, 1, Pdo\Sqlite::DETERMINISTIC); foreach ($db->query('SELECT testing(name) FROM test_pdo_sqlite_createfunction_with_flags') as $row) { diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt index 19f3bc1427bf7..bbdc65275558d 100644 --- a/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO_sqlite: Testing PDO_SQLITE_ATTR_EXTENDED_RESULT_CODES +PDO_sqlite: Testing Pdo\Sqlite::ATTR_EXTENDED_RESULT_CODES --EXTENSIONS-- pdo_sqlite --FILE-- @@ -23,7 +23,7 @@ echo sprintf("Second Error Info: SQLSTATE Error Code: (%s), Driver Specific Erro echo "Creating new PDO with Extended Result Codes turned on" . PHP_EOL; -$db = new PDO('sqlite::memory:', '', '', [PDO::SQLITE_ATTR_EXTENDED_RESULT_CODES => TRUE]); +$db = new PDO('sqlite::memory:', '', '', [Pdo\Sqlite::ATTR_EXTENDED_RESULT_CODES => TRUE]); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $db->exec("CREATE TABLE dog ( id INTEGER PRIMARY KEY, name TEXT, annoying INTEGER )"); diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_open_flags.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_open_flags.phpt index 772b1d9a76b05..00e1153fa91a0 100644 --- a/ext/pdo_sqlite/tests/pdo_sqlite_open_flags.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_open_flags.phpt @@ -12,7 +12,7 @@ $db = new PDO('sqlite:' . $filename, null, null, [PDO::ATTR_ERRMODE => PDO::ERRM var_dump($db->exec('CREATE TABLE test_sqlite_open_flags (id INT);')); -$db = new PDO('sqlite:' . $filename, null, null, [PDO::SQLITE_ATTR_OPEN_FLAGS => PDO::SQLITE_OPEN_READONLY, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); +$db = new PDO('sqlite:' . $filename, null, null, [Pdo\Sqlite::ATTR_OPEN_FLAGS => Pdo\Sqlite::OPEN_READONLY, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); var_dump($db->exec('CREATE TABLE test_sqlite_open_flags_2 (id INT);')); ?> diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_statement_getattribute.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_statement_getattribute.phpt index 21b19654977fe..af6f3ad024b71 100644 --- a/ext/pdo_sqlite/tests/pdo_sqlite_statement_getattribute.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_statement_getattribute.phpt @@ -9,11 +9,11 @@ $db = new PDO('sqlite::memory:'); $st = $db->prepare('SELECT 1;'); -var_dump($st->getAttribute(PDO::SQLITE_ATTR_READONLY_STATEMENT)); +var_dump($st->getAttribute(Pdo\Sqlite::ATTR_READONLY_STATEMENT)); $st = $db->prepare('CREATE TABLE test_sqlite_stmt_getattribute (a TEXT);'); -var_dump($st->getAttribute(PDO::SQLITE_ATTR_READONLY_STATEMENT)); +var_dump($st->getAttribute(Pdo\Sqlite::ATTR_READONLY_STATEMENT)); ?> --EXPECT-- bool(true) diff --git a/ext/pdo_sqlite/tests/php_8.5_deprecations.phpt b/ext/pdo_sqlite/tests/php_8.5_deprecations.phpt new file mode 100644 index 0000000000000..26aaa60894137 --- /dev/null +++ b/ext/pdo_sqlite/tests/php_8.5_deprecations.phpt @@ -0,0 +1,39 @@ +--TEST-- +PDO_sqlite: PHP 8.5 deprecations +--EXTENSIONS-- +pdo_sqlite +--FILE-- + +--EXPECTF-- +Deprecated: Constant PDO::SQLITE_ATTR_EXTENDED_RESULT_CODES is deprecated since 8.5, use Pdo\Sqlite::ATTR_EXTENDED_RESULT_CODES instead in %s on line %d + +Deprecated: Constant PDO::SQLITE_ATTR_OPEN_FLAGS is deprecated since 8.5, use Pdo\Sqlite::ATTR_OPEN_FLAGS instead in %s on line %d + +Deprecated: Constant PDO::SQLITE_ATTR_READONLY_STATEMENT is deprecated since 8.5, use Pdo\Sqlite::ATTR_READONLY_STATEMENT instead in %s on line %d + +Deprecated: Constant PDO::SQLITE_DETERMINISTIC is deprecated since 8.5, use Pdo\Sqlite::DETERMINISTIC instead in %s on line %d + +Deprecated: Constant PDO::SQLITE_OPEN_READONLY is deprecated since 8.5, use Pdo\Sqlite::OPEN_READONLY instead in %s on line %d + +Deprecated: Constant PDO::SQLITE_OPEN_READWRITE is deprecated since 8.5, use Pdo\Sqlite::OPEN_READWRITE instead in %s on line %d + +Deprecated: Constant PDO::SQLITE_OPEN_CREATE is deprecated since 8.5, use Pdo\Sqlite::OPEN_CREATE instead in %s on line %d +int(1002) +int(1000) +int(1001) +int(2048) +int(1) +int(2) +int(4) diff --git a/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createfunction_with_flags.phpt b/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createfunction_with_flags.phpt index 838e2b9bd49b0..c828817d2c3ad 100644 --- a/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createfunction_with_flags.phpt +++ b/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createfunction_with_flags.phpt @@ -4,7 +4,7 @@ PDO_sqlite: Testing createFunction() with flags pdo_sqlite --SKIPIF-- --FILE-- afterLast - range->first; } +static inline bool has_text_range(const UriTextRangeA *range) +{ + return range->first != NULL && range->afterLast != NULL; +} + ZEND_ATTRIBUTE_NONNULL static void copy_uri(UriUriA *new_uriparser_uri, const UriUriA *uriparser_uri) { int result = uriCopyUriMmA(new_uriparser_uri, uriparser_uri, mm); @@ -97,11 +102,9 @@ ZEND_ATTRIBUTE_NONNULL static UriUriA *get_uri_for_reading(php_uri_parser_rfc398 ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_scheme_read(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval) { const UriUriA *uriparser_uri = get_uri_for_reading(internal_uri->uri, read_mode); - ZEND_ASSERT(uriparser_uri != NULL); if (uriparser_uri->scheme.first != NULL && uriparser_uri->scheme.afterLast != NULL) { - zend_string *str = zend_string_init(uriparser_uri->scheme.first, get_text_range_length(&uriparser_uri->scheme), false); - ZVAL_NEW_STR(retval, str); + ZVAL_STRINGL(retval, uriparser_uri->scheme.first, get_text_range_length(&uriparser_uri->scheme)); } else { ZVAL_NULL(retval); } @@ -112,9 +115,8 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_scheme_read(con ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_userinfo_read(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval) { const UriUriA *uriparser_uri = get_uri_for_reading(internal_uri->uri, read_mode); - ZEND_ASSERT(uriparser_uri != NULL); - if (uriparser_uri->userInfo.first != NULL && uriparser_uri->userInfo.afterLast != NULL) { + if (has_text_range(&uriparser_uri->userInfo)) { ZVAL_STRINGL(retval, uriparser_uri->userInfo.first, get_text_range_length(&uriparser_uri->userInfo)); } else { ZVAL_NULL(retval); @@ -126,9 +128,8 @@ ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_userinfo_read(const ur ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_username_read(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval) { const UriUriA *uriparser_uri = get_uri_for_reading(internal_uri->uri, read_mode); - ZEND_ASSERT(uriparser_uri != NULL); - if (uriparser_uri->userInfo.first != NULL && uriparser_uri->userInfo.afterLast != NULL) { + if (has_text_range(&uriparser_uri->userInfo)) { size_t length = get_text_range_length(&uriparser_uri->userInfo); const char *c = memchr(uriparser_uri->userInfo.first, ':', length); @@ -149,9 +150,8 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_username_read(c ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_password_read(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval) { const UriUriA *uriparser_uri = get_uri_for_reading(internal_uri->uri, read_mode); - ZEND_ASSERT(uriparser_uri != NULL); - if (uriparser_uri->userInfo.first != NULL && uriparser_uri->userInfo.afterLast != NULL) { + if (has_text_range(&uriparser_uri->userInfo)) { const char *c = memchr(uriparser_uri->userInfo.first, ':', get_text_range_length(&uriparser_uri->userInfo)); if (c != NULL && uriparser_uri->userInfo.afterLast - c - 1 > 0) { @@ -169,9 +169,8 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_password_read(c ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_host_read(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval) { const UriUriA *uriparser_uri = get_uri_for_reading(internal_uri->uri, read_mode); - ZEND_ASSERT(uriparser_uri != NULL); - if (uriparser_uri->hostText.first != NULL && uriparser_uri->hostText.afterLast != NULL) { + if (has_text_range(&uriparser_uri->hostText)) { if (uriparser_uri->hostData.ip6 != NULL || uriparser_uri->hostData.ipFuture.first != NULL) { /* the textual representation of the host is always accessible in the .hostText field no matter what the host is */ smart_str host_str = {0}; @@ -205,9 +204,8 @@ ZEND_ATTRIBUTE_NONNULL static size_t str_to_int(const char *str, size_t len) ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_port_read(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval) { const UriUriA *uriparser_uri = get_uri_for_reading(internal_uri->uri, read_mode); - ZEND_ASSERT(uriparser_uri != NULL); - if (uriparser_uri->portText.first != NULL && uriparser_uri->portText.afterLast != NULL) { + if (has_text_range(&uriparser_uri->portText)) { ZVAL_LONG(retval, str_to_int(uriparser_uri->portText.first, get_text_range_length(&uriparser_uri->portText))); } else { ZVAL_NULL(retval); @@ -219,7 +217,6 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_port_read(const ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_path_read(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval) { const UriUriA *uriparser_uri = get_uri_for_reading(internal_uri->uri, read_mode); - ZEND_ASSERT(uriparser_uri != NULL); if (uriparser_uri->pathHead != NULL) { smart_str str = {0}; @@ -248,9 +245,8 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_path_read(const ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_query_read(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval) { const UriUriA *uriparser_uri = get_uri_for_reading(internal_uri->uri, read_mode); - ZEND_ASSERT(uriparser_uri != NULL); - if (uriparser_uri->query.first != NULL && uriparser_uri->query.afterLast != NULL) { + if (has_text_range(&uriparser_uri->query)) { ZVAL_STRINGL(retval, uriparser_uri->query.first, get_text_range_length(&uriparser_uri->query)); } else { ZVAL_NULL(retval); @@ -262,9 +258,8 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_query_read(cons ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_fragment_read(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval) { const UriUriA *uriparser_uri = get_uri_for_reading(internal_uri->uri, read_mode); - ZEND_ASSERT(uriparser_uri != NULL); - if (uriparser_uri->fragment.first != NULL && uriparser_uri->fragment.afterLast != NULL) { + if (has_text_range(&uriparser_uri->fragment)) { ZVAL_STRINGL(retval, uriparser_uri->fragment.first, get_text_range_length(&uriparser_uri->fragment)); } else { ZVAL_NULL(retval);