Skip to content
Permalink
Browse files

Deprecate ext/mysql.

Per https://wiki.php.net/rfc/mysql_deprecation, connecting to a MySQL database
via ext/mysql now generates an E_DEPRECATED error. This commit includes the
minimal EXPECTF updates required for the test suite to pass: it may be
preferable to refactor some of the tests to suppress deprecation errors in
situations where no other error is expected from mysql_[p]connect(), but I'm
not enough of a MySQL expert to want to get my hands that dirty in a long
standing test suite.
  • Loading branch information...
LawnGnome committed Dec 10, 2012
1 parent c007ba4 commit b7091aaf0137d97cf4aa4a402ec50b3946d369c0
Showing with 202 additions and 17 deletions.
  1. +5 −0 NEWS
  2. +4 −0 UPGRADING
  3. +4 −0 ext/mysql/php_mysql.c
  4. +3 −0 ext/mysql/tests/001.phpt
  5. +1 −0 ext/mysql/tests/002.phpt
  6. +1 −0 ext/mysql/tests/003.phpt
  7. +2 −1 ext/mysql/tests/bug47438.phpt
  8. +8 −0 ext/mysql/tests/bug48754.phpt
  9. +1 −0 ext/mysql/tests/bug51242.phpt
  10. +3 −2 ext/mysql/tests/bug53649.phpt
  11. +10 −1 ext/mysql/tests/bug55473.phpt
  12. +1 −0 ext/mysql/tests/mysql_affected_rows.phpt
  13. +1 −0 ext/mysql/tests/mysql_client_encoding.phpt
  14. +1 −0 ext/mysql/tests/mysql_close.phpt
  15. +20 −0 ext/mysql/tests/mysql_connect.phpt
  16. +2 −1 ext/mysql/tests/mysql_constants.phpt
  17. +3 −0 ext/mysql/tests/mysql_create_db.phpt
  18. +2 −0 ext/mysql/tests/mysql_data_seek.phpt
  19. +2 −0 ext/mysql/tests/mysql_db_name.phpt
  20. +1 −0 ext/mysql/tests/mysql_db_query.phpt
  21. +2 −1 ext/mysql/tests/mysql_deprecated_api.phpt
  22. +2 −1 ext/mysql/tests/mysql_drop_db.phpt
  23. +1 −0 ext/mysql/tests/mysql_errno.phpt
  24. +2 −0 ext/mysql/tests/mysql_error.phpt
  25. +1 −0 ext/mysql/tests/mysql_fetch_array.phpt
  26. +3 −0 ext/mysql/tests/mysql_fetch_assoc.phpt
  27. +1 −0 ext/mysql/tests/mysql_fetch_field.phpt
  28. +1 −0 ext/mysql/tests/mysql_fetch_lengths.phpt
  29. +1 −0 ext/mysql/tests/mysql_fetch_object.phpt
  30. +2 −1 ext/mysql/tests/mysql_fetch_row.phpt
  31. +2 −0 ext/mysql/tests/mysql_field_flags.phpt
  32. +2 −0 ext/mysql/tests/mysql_field_len.phpt
  33. +2 −0 ext/mysql/tests/mysql_field_name.phpt
  34. +2 −0 ext/mysql/tests/mysql_field_seek.phpt
  35. +2 −0 ext/mysql/tests/mysql_field_table.phpt
  36. +2 −0 ext/mysql/tests/mysql_field_type.phpt
  37. +1 −0 ext/mysql/tests/mysql_free_result.phpt
  38. +1 −0 ext/mysql/tests/mysql_get_host_info.phpt
  39. +1 −0 ext/mysql/tests/mysql_get_proto_info.phpt
  40. +1 −0 ext/mysql/tests/mysql_get_server_info.phpt
  41. +2 −1 ext/mysql/tests/mysql_info.phpt
  42. +2 −0 ext/mysql/tests/mysql_insert_id.phpt
  43. +2 −1 ext/mysql/tests/mysql_list_dbs.phpt
  44. +1 −0 ext/mysql/tests/mysql_list_fields.phpt
  45. +2 −1 ext/mysql/tests/mysql_list_processes.phpt
  46. +1 −0 ext/mysql/tests/mysql_list_tables.phpt
  47. +11 −1 ext/mysql/tests/mysql_max_links.phpt
  48. +7 −1 ext/mysql/tests/mysql_max_persistent.phpt
  49. +2 −1 ext/mysql/tests/mysql_mysqlnd_read_timeout_long.phpt
  50. +2 −0 ext/mysql/tests/mysql_num_fields.phpt
  51. +2 −0 ext/mysql/tests/mysql_num_rows.phpt
  52. +8 −1 ext/mysql/tests/mysql_pconn_disable.phpt
  53. +7 −0 ext/mysql/tests/mysql_pconn_kill.phpt
  54. +5 −0 ext/mysql/tests/mysql_pconn_max_links.phpt
  55. +10 −1 ext/mysql/tests/mysql_pconn_reuse.phpt
  56. +12 −0 ext/mysql/tests/mysql_pconnect.phpt
  57. +1 −0 ext/mysql/tests/mysql_ping.phpt
  58. +1 −0 ext/mysql/tests/mysql_query.phpt
  59. +3 −0 ext/mysql/tests/mysql_query_load_data_openbasedir.phpt
  60. +1 −0 ext/mysql/tests/mysql_real_escape_string.phpt
  61. +2 −0 ext/mysql/tests/mysql_result.phpt
  62. +1 −0 ext/mysql/tests/mysql_select_db.phpt
  63. +1 −0 ext/mysql/tests/mysql_set_charset.phpt
  64. +2 −0 ext/mysql/tests/mysql_stat.phpt
  65. +2 −0 ext/mysql/tests/mysql_tablename.phpt
  66. +3 −1 ext/mysql/tests/mysql_thread_id.phpt
  67. +1 −0 ext/mysql/tests/mysql_trace_mode.phpt
  68. +1 −0 ext/mysql/tests/mysql_unbuffered_query.phpt
5 NEWS
@@ -163,6 +163,11 @@ PHP NEWS
. mcrypt_ecb(), mcrypt_cbc(), mcrypt_cfb() and mcrypt_ofb() now throw
E_DEPRECATED. (GoogleGuy)

- MySQL
. This extension is now deprecated, and deprecation warnings will be generated
when connections are established to databases via mysql_connect(),
mysql_pconnect(), or through implicit connection. (Adam)

- MySQLi
. Dropped support for LOAD DATA LOCAL INFILE handlers when using libmysql.
Known for stability problems. (Andrey)
@@ -85,6 +85,10 @@ PHP 5.5 UPGRADE NOTES
3. Deprecated Functionality
========================================

- The original MySQL extension is now deprecated, and will generate deprecation
warnings when connecting to a database through mysql_connect(),
mysql_pconnect() or by establishing an implicit connection. Use MySQLi or PDO
instead.
- The preg_replace /e modifier is now deprecated. Use
preg_replace_callback instead.
(https://wiki.php.net/rfc/remove_preg_replace_eval_modifier)
@@ -731,6 +731,10 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
zend_bool free_host=0, new_link=0;
long connect_timeout;

php_error_docref(NULL TSRMLS_CC,
E_DEPRECATED,
"The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead");

#if !defined(MYSQL_USE_MYSQLND)
if ((MYSQL_VERSION_ID / 100) != (mysql_get_client_version() / 100)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
@@ -29,5 +29,8 @@ var_dump($test);
print "done!";
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
%unicode|string%(2) "11"
done!
@@ -37,6 +37,7 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
resource(%d) of type (mysql link)
bool(true)
bool(true)
@@ -57,6 +57,7 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
==stdClass==
object(stdClass)#%d (1) {
[%u|b%"a"]=>
@@ -46,7 +46,8 @@ if (!mysql_select_db($db, $link) ||
mysql_close($link);
?>
--EXPECT--
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
0.a
1.b
2.c
@@ -68,25 +68,33 @@ var_dump($link);
?>
--EXPECTF--
Explicit connection on close

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
Expect same thread id for $link and default conn: bool(true)
resource(%d) of type (mysql link)
resource(%d) of type (Unknown)

Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d

Closing default link

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
Expect same thread id for $link and default conn but not the previous: bool(true)
resource(%d) of type (mysql link)
resource(%d) of type (mysql link)
resource(%d) of type (Unknown)

Explicit resource and pconnect

Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
resource(%d) of type (mysql link persistent)
resource(%d) of type (Unknown)

Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d

Default link and pconnect

Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
resource(%d) of type (mysql link persistent)
resource(%d) of type (mysql link persistent)
resource(%d) of type (Unknown)
@@ -35,4 +35,5 @@ if ($link = my_mysql_connect($host, $user, $passwd, $db, null, $socket)) {
}
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
resource(%d) of type (mysql link)
@@ -67,5 +67,6 @@ mysql_close($link);
unlink('bug53649.data');
?>
--EXPECT--
done
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done
@@ -68,12 +68,21 @@ mysql.allow_persistent=1
print "done!";
?>
--EXPECTF--
Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
[003] reconnect 0

Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
[005] Setting openened files...
[003] reconnect 1

Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
[007] Opened files as expected
[003] reconnect 2

Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
[007] Opened files as expected
[003] reconnect 3

Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
[007] Opened files as expected
done!
done!
@@ -122,4 +122,5 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!
@@ -67,4 +67,5 @@ if (false !== ($tmp = @mysql_client_encoding($link)))
print "done!";
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!
@@ -36,4 +36,5 @@ if (false !== ($tmp = @mysql_query("SELECT 1", $link)))
print "done!\n";
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!
@@ -104,5 +104,25 @@ if (!ini_get('sql.safe_mode')) {
print "done!";
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Warning: mysql_connect(): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!
@@ -62,4 +62,5 @@ if (!empty($expected_constants)) {
print "done!";
?>
--EXPECTF--
done!
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!
@@ -53,4 +53,7 @@ if (!mysql_query("DROP DATABASE IF EXISTS mysqlcreatedb", $link))
mysql_close($link);
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!
@@ -67,6 +67,8 @@ print "done!\n";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Warning: mysql_data_seek(): Offset 4 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d

Warning: mysql_data_seek(): Offset -1 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d
@@ -58,6 +58,8 @@ mysql_close($link);
print "done!\n";
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Warning: mysql_db_name(): Unable to jump to row -1 on MySQL result index %d in %s on line %d

Warning: mysql_db_name(): Unable to jump to row %d on MySQL result index %d in %s on line %d
@@ -62,4 +62,5 @@ print "done!\n";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!
@@ -75,4 +75,5 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
done!
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!
@@ -52,4 +52,5 @@ if (!mysql_query("DROP DATABASE IF EXISTS mysqldropdb", $link))
mysql_close($link);
?>
--EXPECTF--
done!
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!
@@ -55,6 +55,7 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
int(0)
int(%d)

@@ -62,6 +62,8 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Warning: mysql_error(): %d is not a valid MySQL-Link resource in %s on line %d
bool(false)
done!
@@ -281,6 +281,7 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
[005]
array(4) {
[0]=>
@@ -63,6 +63,7 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
[005]
array(2) {
[%u|b%"id"]=>
@@ -87,6 +88,8 @@ array(5) {
}

Warning: mysql_fetch_assoc(): %d is not a valid MySQL result resource in %s on line %d

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
[010]
array(5) {
[%u|b%"id"]=>
@@ -156,6 +156,7 @@ require_once('skipifconnectfailure.inc');
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(2) "ID"
@@ -39,6 +39,7 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
array(2) {
[0]=>
int(1)
@@ -82,6 +82,7 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
object(stdClass)#%d (2) {
[%u|b%"ID"]=>
%unicode|string%(1) "1"
@@ -41,6 +41,7 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
[004]
array(2) {
[0]=>
@@ -53,4 +54,4 @@ bool(false)

Warning: mysql_fetch_row(): %d is not a valid MySQL result resource in %s on line %d
bool(false)
done!
done!
@@ -144,6 +144,8 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Warning: mysql_field_flags() expects exactly 2 parameters, 1 given in %s on line %d

Warning: mysql_field_flags(): Field -1 is invalid for MySQL result index %d in %s on line %d
@@ -47,6 +47,8 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Warning: mysql_field_len() expects exactly 2 parameters, 1 given in %s on line %d

Warning: mysql_field_len(): Field -1 is invalid for MySQL result index %d in %s on line %d
@@ -46,6 +46,8 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Warning: mysql_field_name() expects exactly 2 parameters, 1 given in %s on line %d

Warning: mysql_field_name(): Field -1 is invalid for MySQL result index %d in %s on line %d
@@ -44,6 +44,8 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Warning: mysql_field_seek(): Field -1 is invalid for MySQL result index %d in %s on line %d
bool(false)
object(stdClass)#%d (13) {
@@ -46,6 +46,8 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Warning: mysql_field_table() expects exactly 2 parameters, 1 given in %s on line %d

Warning: mysql_field_table(): Field -1 is invalid for MySQL result index %d in %s on line %d
@@ -46,6 +46,8 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Warning: mysql_field_type() expects exactly 2 parameters, 1 given in %s on line %d

Warning: mysql_field_type(): Field -1 is invalid for MySQL result index %d in %s on line %d
@@ -44,6 +44,7 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
bool(true)

Warning: mysql_free_result(): %d is not a valid MySQL result resource in %s on line %d
@@ -41,4 +41,5 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!
@@ -31,4 +31,5 @@ print "done!";
require_once("clean_table.inc");
?>
--EXPECTF--
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
done!

0 comments on commit b7091aa

Please sign in to comment.
You can’t perform that action at this time.