diff options
Diffstat (limited to 'ext/mysql')
| -rw-r--r-- | ext/mysql/config.m4 | 28 | ||||
| -rw-r--r-- | ext/mysql/php_mysql.c | 54 | ||||
| -rw-r--r-- | ext/mysql/php_mysql.h | 2 | ||||
| -rw-r--r-- | ext/mysql/php_mysql_structs.h | 2 | ||||
| -rw-r--r-- | ext/mysql/tests/bug55473.phpt | 10 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_pconn_kill.phpt | 2 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_phpinfo.phpt | 2 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_query_load_data_openbasedir.phpt | 10 |
8 files changed, 69 insertions, 41 deletions
diff --git a/ext/mysql/config.m4 b/ext/mysql/config.m4 index e7d598fe05..5968c43346 100644 --- a/ext/mysql/config.m4 +++ b/ext/mysql/config.m4 @@ -41,8 +41,8 @@ AC_DEFUN([PHP_MYSQL_SOCKET_SEARCH], [ PHP_ARG_WITH(mysql, for MySQL support, [ --with-mysql[=DIR] Include MySQL support. DIR is the MySQL base - directory. If mysqlnd is passed as DIR, - the MySQL native driver will be used [/usr/local]]) + directory, if no DIR is passed or the value is + mysqlnd the MySQL native driver will be used]) PHP_ARG_WITH(mysql-sock, for specified location of the MySQL UNIX socket, [ --with-mysql-sock[=DIR] MySQL/MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer. @@ -53,7 +53,7 @@ if test -z "$PHP_ZLIB_DIR"; then [ --with-zlib-dir[=DIR] MySQL: Set the path to libz install prefix], no, no) fi -if test "$PHP_MYSQL" = "mysqlnd"; then +if test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL" = "mysqlnd"; then dnl enables build of mysqnd library PHP_MYSQLND_ENABLED=yes @@ -61,17 +61,15 @@ elif test "$PHP_MYSQL" != "no"; then MYSQL_DIR= MYSQL_INC_DIR= - for i in $PHP_MYSQL /usr/local /usr; do - if test -r $i/include/mysql/mysql.h; then - MYSQL_DIR=$i - MYSQL_INC_DIR=$i/include/mysql - break - elif test -r $i/include/mysql.h; then - MYSQL_DIR=$i - MYSQL_INC_DIR=$i/include - break - fi - done + if test -r $PHP_MYSQL/include/mysql/mysql.h; then + MYSQL_DIR=$PHP_MYSQL + MYSQL_INC_DIR=$PHP_MYSQL/include/mysql + break + elif test -r $PHP_MYSQL/include/mysql.h; then + MYSQL_DIR=$PHP_MYSQL + MYSQL_INC_DIR=$PHP_MYSQL/include + break + fi if test -z "$MYSQL_DIR"; then AC_MSG_ERROR([Cannot find MySQL header files under $PHP_MYSQL. @@ -162,7 +160,7 @@ if test "$PHP_MYSQL" != "no"; then PHP_NEW_EXTENSION(mysql, php_mysql.c, $ext_shared) PHP_SUBST(MYSQL_SHARED_LIBADD) - if test "$PHP_MYSQL" = "mysqlnd"; then + if test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL" = "mysqlnd"; then PHP_ADD_EXTENSION_DEP(mysql, mysqlnd) AC_DEFINE([MYSQL_USE_MYSQLND], 1, [Whether mysqlnd is enabled]) fi diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 51a060c897..d6a0c94677 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -252,7 +252,7 @@ static const zend_function_entry mysql_functions[] = { PHP_FE(mysql_query, arginfo_mysql_query) PHP_FE(mysql_unbuffered_query, arginfo_mysql_query) PHP_DEP_FE(mysql_db_query, arginfo_mysql_db_query) - PHP_FE(mysql_list_dbs, arginfo__optional_mysql_link) + PHP_DEP_FE(mysql_list_dbs, arginfo__optional_mysql_link) PHP_DEP_FE(mysql_list_tables, arginfo_mysql_select_db) PHP_FE(mysql_list_fields, arginfo_mysql_list_fields) PHP_FE(mysql_list_processes, arginfo__optional_mysql_link) @@ -529,6 +529,32 @@ static PHP_GINIT_FUNCTION(mysql) } /* }}} */ +#ifdef MYSQL_USE_MYSQLND +#include "ext/mysqlnd/mysqlnd_reverse_api.h" +static MYSQLND * mysql_convert_zv_to_mysqlnd(zval * zv TSRMLS_DC) +{ + php_mysql_conn *mysql; + + if (Z_TYPE_P(zv) != IS_RESOURCE) { + /* Might be nicer to check resource type, too, but ext/mysql is the only one using resources so emitting an error is not to bad, while usually this hook should be silent */ + return NULL; + } + + mysql = (php_mysql_conn *)zend_fetch_resource(&zv TSRMLS_CC, -1, "MySQL-Link", NULL, 2, le_link, le_plink); + + if (!mysql) { + return NULL; + } + + return mysql->conn; +} + +static MYSQLND_REVERSE_API mysql_reverse_api = { + &mysql_module_entry, + mysql_convert_zv_to_mysqlnd +}; +#endif + /* {{{ PHP_MINIT_FUNCTION */ ZEND_MODULE_STARTUP_D(mysql) @@ -557,6 +583,10 @@ ZEND_MODULE_STARTUP_D(mysql) #endif #endif +#ifdef MYSQL_USE_MYSQLND + mysqlnd_reverse_api_register_api(&mysql_reverse_api TSRMLS_CC); +#endif + return SUCCESS; } /* }}} */ @@ -735,7 +765,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) php_error_docref(NULL TSRMLS_CC, E_NOTICE, "SQL safe mode in effect - ignoring host/user/password information"); } host_and_port=passwd=NULL; - user=php_get_current_user(); + user=php_get_current_user(TSRMLS_C); hashed_details_length = spprintf(&hashed_details, 0, "mysql__%s_", user); client_flags = CLIENT_INTERACTIVE; } else { @@ -1579,11 +1609,13 @@ PHP_FUNCTION(mysql_list_dbs) id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU); CHECK_LINK(id); } + php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "This function is deprecated; use mysql_query() with SHOW DATABASES instead"); ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, &mysql_link, id, "MySQL-Link", le_link, le_plink); PHPMY_UNBUFFERED_QUERY_CHECK(); + if ((mysql_result=mysql_list_dbs(mysql->conn, NULL))==NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to save MySQL query result"); RETURN_FALSE; @@ -1811,9 +1843,7 @@ PHP_FUNCTION(mysql_escape_string) Z_STRLEN_P(return_value) = mysql_escape_string(Z_STRVAL_P(return_value), str, str_len); Z_TYPE_P(return_value) = IS_STRING; - if (MySG(trace_mode)){ - php_error_docref("function.mysql-real-escape-string" TSRMLS_CC, E_DEPRECATED, "This function is deprecated; use mysql_real_escape_string() instead."); - } + php_error_docref("function.mysql-real-escape-string" TSRMLS_CC, E_DEPRECATED, "This function is deprecated; use mysql_real_escape_string() instead."); } /* }}} */ @@ -1959,12 +1989,16 @@ Q: String or long first? if (sql_row[field_offset]) { Z_TYPE_P(return_value) = IS_STRING; +#if PHP_API_VERSION < 20100412 if (PG(magic_quotes_runtime)) { Z_STRVAL_P(return_value) = php_addslashes(sql_row[field_offset], sql_row_lengths[field_offset],&Z_STRLEN_P(return_value), 0 TSRMLS_CC); } else { +#endif Z_STRLEN_P(return_value) = sql_row_lengths[field_offset]; Z_STRVAL_P(return_value) = (char *) safe_estrndup(sql_row[field_offset], Z_STRLEN_P(return_value)); +#if PHP_API_VERSION < 20100412 } +#endif } else { Z_TYPE_P(return_value) = IS_NULL; } @@ -2082,12 +2116,16 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, MAKE_STD_ZVAL(data); +#if PHP_API_VERSION < 20100412 if (PG(magic_quotes_runtime)) { Z_TYPE_P(data) = IS_STRING; Z_STRVAL_P(data) = php_addslashes(mysql_row[i], mysql_row_lengths[i], &Z_STRLEN_P(data), 0 TSRMLS_CC); } else { +#endif ZVAL_STRINGL(data, mysql_row[i], mysql_row_lengths[i], 1); +#if PHP_API_VERSION < 20100412 } +#endif if (result_type & MYSQL_NUM) { add_index_zval(return_value, i, data); @@ -2378,8 +2416,8 @@ PHP_FUNCTION(mysql_fetch_field) } object_init(return_value); - add_property_string(return_value, "name", (char *) (mysql_field->name?mysql_field->name:""), 1); - add_property_string(return_value, "table",(char *) (mysql_field->table?mysql_field->table:""), 1); + add_property_string(return_value, "name",(mysql_field->name?mysql_field->name:""), 1); + add_property_string(return_value, "table",(mysql_field->table?mysql_field->table:""), 1); add_property_string(return_value, "def",(mysql_field->def?mysql_field->def:""), 1); add_property_long(return_value, "max_length", mysql_field->max_length); add_property_long(return_value, "not_null", IS_NOT_NULL(mysql_field->flags)?1:0); diff --git a/ext/mysql/php_mysql.h b/ext/mysql/php_mysql.h index 7b9ab8d6fb..899d5d53e2 100644 --- a/ext/mysql/php_mysql.h +++ b/ext/mysql/php_mysql.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysql/php_mysql_structs.h b/ext/mysql/php_mysql_structs.h index bf09b24b0c..003ed04872 100644 --- a/ext/mysql/php_mysql_structs.h +++ b/ext/mysql/php_mysql_structs.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mysql/tests/bug55473.phpt b/ext/mysql/tests/bug55473.phpt index df584bdef9..befecef192 100644 --- a/ext/mysql/tests/bug55473.phpt +++ b/ext/mysql/tests/bug55473.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #5547 (mysql_pconnect leaks file descriptors on reconnect) +Bug #55473 (mysql_pconnect leaks file descriptors on reconnect) --SKIPIF-- <?php require_once('skipif.inc'); @@ -8,7 +8,7 @@ if (defined('PHP_WINDOWS_VERSION_MAJOR')) { die("skip Test doesn't work on Windows"); } -if (!($output = @exec("lsof -np " . getmypid()))) +if (!($output = @exec("lsof -nwp " . getmypid()))) die("skip Test can't find command line tool lsof"); ?> --INI-- @@ -56,9 +56,9 @@ mysql.allow_persistent=1 if ($opened_files == -1) { - $opened_files = trim(exec("lsof -np " . getmypid() . " | wc -l")); + $opened_files = trim(exec("lsof -nwp " . getmypid() . " | wc -l")); printf("[005] Setting openened files...\n"); - } else if (($tmp = trim(exec("lsof -np " . getmypid() . " | wc -l"))) != $opened_files) { + } else if (($tmp = trim(exec("lsof -nwp " . getmypid() . " | wc -l"))) != $opened_files) { printf("[006] [%d] different number of opened_files : expected %d, got %d", $i, $opened_files, $tmp); } else { printf("[007] Opened files as expected\n"); @@ -76,4 +76,4 @@ mysql.allow_persistent=1 [007] Opened files as expected [003] reconnect 3 [007] Opened files as expected -done!
\ No newline at end of file +done! diff --git a/ext/mysql/tests/mysql_pconn_kill.phpt b/ext/mysql/tests/mysql_pconn_kill.phpt index 20dfbe9a15..efef421604 100644 --- a/ext/mysql/tests/mysql_pconn_kill.phpt +++ b/ext/mysql/tests/mysql_pconn_kill.phpt @@ -64,8 +64,6 @@ mysql.max_persistent=2 mysql_close($plink); - /* mysql_pconnect cound generate a warning when linked against mysqlnd - PHP Warning: mysql_pconnect(): MySQL server has gone away */ if (!($plink = @mysql_pconnect($myhost, $user, $passwd))) printf("[009] Cannot create new persistent connection, [%d] %s\n", mysql_errno(), mysql_error()); mysql_select_db($db, $plink); diff --git a/ext/mysql/tests/mysql_phpinfo.phpt b/ext/mysql/tests/mysql_phpinfo.phpt index 46600ab2d2..79de939167 100644 --- a/ext/mysql/tests/mysql_phpinfo.phpt +++ b/ext/mysql/tests/mysql_phpinfo.phpt @@ -51,7 +51,7 @@ if (!stristr($phpinfo, "mysql.allow_persistent")) if ($IS_MYSQLND) { $expected = array( - 'client statistics', + 'mysqlnd statistics', 'bytes_sent', 'bytes_received', 'packets_sent', 'packets_received', 'protocol_overhead_in', 'protocol_overhead_out', 'result_set_queries', 'non_result_set_queries', 'no_index_used', 'bad_index_used', diff --git a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt index 474065faf1..aa15f5ca12 100644 --- a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt +++ b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt @@ -3,11 +3,6 @@ LOAD DATA INFILE - open_basedir --SKIPIF-- <?php include_once('skipif.inc'); - -if (!isset($db)) { - die("skip open_basedir setting prevents inclusing of required files"); -} - include_once('skipifconnectfailure.inc'); @@ -30,12 +25,11 @@ if ($socket == "" && $host != NULL && $host != 'localhost' && $host != '.') { } } ?> ---INI-- -open_basedir="." --FILE-- <?php @include_once("connect.inc"); - +ini_set("open_basedir", __DIR__); +chdir(__DIR__); if (!isset($db)) { // run-tests, I love you for not allowing me to set ini settings dynamically print "[006] [1148] The used command is not allowed with this MySQL version |
