Skip to content

Commit

Permalink
Deprecate ext/mysql.
Browse files Browse the repository at this point in the history
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 b7091aa
Show file tree
Hide file tree
Showing 68 changed files with 202 additions and 17 deletions.
5 changes: 5 additions & 0 deletions NEWS
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions UPGRADING
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions ext/mysql/php_mysql.c
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions ext/mysql/tests/001.phpt
Expand Up @@ -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!
1 change: 1 addition & 0 deletions ext/mysql/tests/002.phpt
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions ext/mysql/tests/003.phpt
Expand Up @@ -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"]=>
Expand Down
3 changes: 2 additions & 1 deletion ext/mysql/tests/bug47438.phpt
Expand Up @@ -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
8 changes: 8 additions & 0 deletions ext/mysql/tests/bug48754.phpt
Expand Up @@ -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)
1 change: 1 addition & 0 deletions ext/mysql/tests/bug51242.phpt
Expand Up @@ -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)
5 changes: 3 additions & 2 deletions ext/mysql/tests/bug53649.phpt
Expand Up @@ -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
11 changes: 10 additions & 1 deletion ext/mysql/tests/bug55473.phpt
Expand Up @@ -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!
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_affected_rows.phpt
Expand Up @@ -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!
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_client_encoding.phpt
Expand Up @@ -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!
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_close.phpt
Expand Up @@ -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!
20 changes: 20 additions & 0 deletions ext/mysql/tests/mysql_connect.phpt
Expand Up @@ -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!
3 changes: 2 additions & 1 deletion ext/mysql/tests/mysql_constants.phpt
Expand Up @@ -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!
3 changes: 3 additions & 0 deletions ext/mysql/tests/mysql_create_db.phpt
Expand Up @@ -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!
2 changes: 2 additions & 0 deletions ext/mysql/tests/mysql_data_seek.phpt
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ext/mysql/tests/mysql_db_name.phpt
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_db_query.phpt
Expand Up @@ -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!
3 changes: 2 additions & 1 deletion ext/mysql/tests/mysql_deprecated_api.phpt
Expand Up @@ -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!
3 changes: 2 additions & 1 deletion ext/mysql/tests/mysql_drop_db.phpt
Expand Up @@ -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!
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_errno.phpt
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions ext/mysql/tests/mysql_error.phpt
Expand Up @@ -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!
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_fetch_array.phpt
Expand Up @@ -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]=>
Expand Down
3 changes: 3 additions & 0 deletions ext/mysql/tests/mysql_fetch_assoc.phpt
Expand Up @@ -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"]=>
Expand All @@ -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"]=>
Expand Down
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_fetch_field.phpt
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_fetch_lengths.phpt
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_fetch_object.phpt
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion ext/mysql/tests/mysql_fetch_row.phpt
Expand Up @@ -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]=>
Expand All @@ -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!
2 changes: 2 additions & 0 deletions ext/mysql/tests/mysql_field_flags.phpt
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ext/mysql/tests/mysql_field_len.phpt
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ext/mysql/tests/mysql_field_name.phpt
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ext/mysql/tests/mysql_field_seek.phpt
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions ext/mysql/tests/mysql_field_table.phpt
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ext/mysql/tests/mysql_field_type.phpt
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_free_result.phpt
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_get_host_info.phpt
Expand Up @@ -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!
1 change: 1 addition & 0 deletions ext/mysql/tests/mysql_get_proto_info.phpt
Expand Up @@ -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.