Skip to content

Commit

Permalink
Signed-off-by: Marc Delisle <[email protected]>
Browse files Browse the repository at this point in the history
Added warning about the mysql extension being deprecated
and removed the extension directive
  • Loading branch information
Marc Delisle committed Dec 14, 2013
1 parent 61feb94 commit 2a8962a
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 118 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ phpMyAdmin - ChangeLog
+ rfe #1473 Transformation to convert Boolean value to text
- bug #4157 Changing users password will delete it
+ rfe #1474 Text transformation combines Append and Prepend
+ Added warning about the mysql extension being deprecated
and removed the extension directive

4.1.1.0 (not yet released)
- bug #4154 Error using UNION query
Expand Down
2 changes: 0 additions & 2 deletions config.sample.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

/*
Expand Down
20 changes: 2 additions & 18 deletions doc/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,10 @@ Server connection settings

Whether to enable SSL for the connection between phpMyAdmin and the MySQL server.

When using :config:option:`$cfg['Servers'][$i]['extension']` = ``'mysql'``,
When using the ``'mysql'`` extension,
none of the remaining ``'ssl...'`` configuration options apply.

We strongly recommend using :config:option:`$cfg['Servers'][$i]['extension']` = ``'mysqli'``
when using this option.
We strongly recommend the ``'mysqli'`` extension when using this option.

.. config:option:: $cfg['Servers'][$i]['ssl_key']
Expand Down Expand Up @@ -286,21 +285,6 @@ Server connection settings
some platforms. To use the socket mode, your MySQL server must be on the
same machine as the Web server.

.. config:option:: $cfg['Servers'][$i]['extension']
:type: string
:default: ``'mysqli'``

What php MySQL extension to use for the connection. Valid options are:

``mysql``
The classic MySQL extension.

``mysqli``
The improved MySQL extension. This extension became available with PHP
5.0.0 and is the recommended way to connect to a server running MySQL
4.1.x or newer.

.. config:option:: $cfg['Servers'][$i]['compress']
:type: boolean
Expand Down
12 changes: 5 additions & 7 deletions doc/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ generally caused by using MySQL version 4.1 or newer. MySQL changed
the authentication hash and your PHP is trying to use the old method.
The proper solution is to use the `mysqli extension
<http://www.php.net/mysqli>`_ with the proper client library to match
your MySQL installation. Your chosen extension is specified in
:config:option:`$cfg['Servers'][$i]['extension']`. More
your MySQL installation. More
information (and several workarounds) are located in the `MySQL
Documentation <http://dev.mysql.com/doc/mysql/en/old-client.html>`_.

Expand All @@ -239,20 +238,19 @@ files to use font faces. Please refers to the `TCPDF manual

.. _faqmysql:

1.20 I receive the error "cannot load MySQL extension, please check PHP Configuration".
---------------------------------------------------------------------------------------
1.20 I receive an error about missing mysqli and mysql extensions.
------------------------------------------------------------------

To connect to a MySQL server, PHP needs a set of MySQL functions
called "MySQL extension". This extension may be part of the PHP
distribution (compiled-in), otherwise it needs to be loaded
dynamically. Its name is probably *mysql.so* or *php\_mysql.dll*.
dynamically. Its name is probably *mysqli.so* or *php\_mysqli.dll*.
phpMyAdmin tried to load the extension but failed. Usually, the
problem is solved by installing a software package called "PHP-MySQL"
or something similar.

There are currently two interfaces PHP provides as MySQL extensions - ``mysql``
and ``mysqli`` and you can change which of then is being used by
:config:option:`$cfg['Servers'][$i]['extension']`.
and ``mysqli``. The ``mysqli`` is tried first, because it's the best one.

.. _faq1_21:

Expand Down
1 change: 0 additions & 1 deletion examples/config.manyhosts.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'pmapass';
Expand Down
18 changes: 9 additions & 9 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,23 +291,23 @@

if ($server > 0) {
$client_version_str = $GLOBALS['dbi']->getClientInfo();
if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)
&& in_array(
$GLOBALS['cfg']['Server']['extension'],
array('mysql', 'mysqli')
)
) {
if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
$client_version_str = 'libmysql - ' . $client_version_str;
}
PMA_printListItem(
__('Database client version:') . ' ' . $client_version_str,
'li_mysql_client_version'
);

$php_ext_string = __('PHP extension:') . ' '
. $GLOBALS['cfg']['Server']['extension'] . ' '
$php_ext_string = __('PHP extension:') . ' ';
if (PMA_DatabaseInterface::checkDbExtension('mysqli')) {
$extension = 'mysqli';
} else {
$extension = 'mysql';
}
$php_ext_string .= $extension . ' '
. PMA_Util::showPHPDocu(
'book.' . $GLOBALS['cfg']['Server']['extension'] . '.php'
'book.' . $extension . '.php'
);
PMA_printListItem(
$php_ext_string,
Expand Down
7 changes: 0 additions & 7 deletions libraries/config.default.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,6 @@
*/
$cfg['Servers'][$i]['connect_type'] = 'tcp';

/**
* The PHP MySQL extension to use ('mysql' or 'mysqli')
*
* @global string $cfg['Servers'][$i]['extension']
*/
$cfg['Servers'][$i]['extension'] = 'mysqli';

/**
* Use compressed protocol for the MySQL connection
*
Expand Down
3 changes: 0 additions & 3 deletions libraries/config.values.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
1 => array(
'port' => 'integer',
'connect_type' => array('tcp', 'socket'),
'extension' => array('mysql', 'mysqli'),
'auth_type' => array('config', 'http', 'signon', 'cookie'),
'AllowDeny' => array(
'order' => array('', 'deny,allow', 'allow,deny', 'explicit')
Expand Down Expand Up @@ -194,8 +193,6 @@
* Use only full paths
*/
$cfg_db['_overrides'] = array();
$cfg_db['_overrides']['Servers/1/extension'] = extension_loaded('mysqli')
? 'mysqli' : 'mysql';

/**
* Basic validator assignments (functions from libraries/config/Validator.class.php
Expand Down
13 changes: 9 additions & 4 deletions libraries/config/Validator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ public static function testPHPErrorMsg($start = true)
/**
* Test database connection
*
* @param string $extension 'drizzle', 'mysql' or 'mysqli'
* @param string $connect_type 'tcp' or 'socket'
* @param string $host host name
* @param string $port tcp port to use
Expand All @@ -206,7 +205,6 @@ public static function testPHPErrorMsg($start = true)
* @return bool|array
*/
public static function testDBConnection(
$extension,
$connect_type,
$host,
$port,
Expand All @@ -219,6 +217,14 @@ public static function testDBConnection(
$socket = empty($socket) || $connect_type == 'tcp' ? null : $socket;
$port = empty($port) || $connect_type == 'socket' ? null : ':' . $port;
$error = null;

if (PMA_DatabaseInterface::checkDbExtension('mysqli')) {
$extension = 'mysqli';
} else {
$extension = 'mysql';
}

// dead code (drizzle extension)
if ($extension == 'drizzle') {
while (1) {
$drizzle = @drizzle_create();
Expand Down Expand Up @@ -315,7 +321,6 @@ public static function validateServer($path, $values)
$password = $values['Servers/1/nopassword'] ? null
: $values['Servers/1/password'];
$test = static::testDBConnection(
$values['Servers/1/extension'],
$values['Servers/1/connect_type'],
$values['Servers/1/host'],
$values['Servers/1/port'],
Expand Down Expand Up @@ -365,7 +370,7 @@ public static function validatePMAStorage($path, $values)
}
if (! $error) {
$test = static::testDBConnection(
$values['Servers/1/extension'], $values['Servers/1/connect_type'],
$values['Servers/1/connect_type'],
$values['Servers/1/host'], $values['Servers/1/port'],
$values['Servers/1/socket'], $values['Servers/1/controluser'],
$values['Servers/1/controlpass'], 'Server_pmadb'
Expand Down
3 changes: 0 additions & 3 deletions libraries/config/messages.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,6 @@
'Leave blank for no Designer support, suggested: [kbd]pma__designer_coords[/kbd]'
);
$strConfigServers_designer_coords_name = __('Designer table');
$strConfigServers_extension_desc
= __('What PHP extension to use; you should use mysqli if supported');
$strConfigServers_extension_name = __('PHP extension to use');
$strConfigServers_hide_db_desc
= __('Hide databases matching regular expression (PCRE)');
$strConfigServers_hide_db_name = __('Hide databases');
Expand Down
1 change: 0 additions & 1 deletion libraries/config/setup.forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
'socket',
'ssl',
'connect_type',
'extension',
'compress',
'nopassword')));
$forms['Servers']['Server_auth'] = array('Servers' => array(1 => array(
Expand Down
52 changes: 19 additions & 33 deletions libraries/database_interface.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

require_once './libraries/DatabaseInterface.class.php';

$extension = null;
if (defined('TESTSUITE')) {
/**
* For testsuite we use dummy driver which can fake some queries.
Expand All @@ -22,53 +21,44 @@
} else {

/**
* check for requested extension
* First check for the mysqli extension, as it's the one recommended
* for the MySQL server's version that we support
*/
$extensionName = $GLOBALS['cfg']['Server']['extension'];
if (! PMA_DatabaseInterface::checkDbExtension($extensionName)) {
$extension = 'mysqli';
if (! PMA_DatabaseInterface::checkDbExtension($extension)) {

// if it fails try alternative extension ...
// and display an error ...
$docurl = PMA_Util::getDocuLink('faq', 'faqmysql');
$doclink = sprintf(
__('See %sour documentation%s for more information.'),
'[a@' . $docurl . '@documentation]',
'[/a]'
);

/**
* @todo add different messages for alternative extension
* and complete fail (no alternative extension too)
*/
PMA_warnMissingExtension(
$extensionName,
false,
$doclink
);

if ($extensionName === 'mysql') {
$alternativ_extension = 'mysqli';
} else {
$alternativ_extension = 'mysql';
}

if (! PMA_DatabaseInterface::checkDbExtension($alternativ_extension)) {
// if alternative fails too ...
$extension = 'mysql';
if (! PMA_DatabaseInterface::checkDbExtension($extension)) {
// warn about both extensions missing and exit
PMA_warnMissingExtension(
$extensionName,
'mysqli|mysql',
true,
$doclink
);
} elseif (empty($_SESSION['mysqlwarning'])) {
trigger_error(
__(
'You are using the mysql extension which is deprecated in '
. 'phpMyAdmin. Please consider installing the mysqli '
. 'extension.') . ' ' . $doclink,
E_USER_WARNING
);
// tell the user just once per session
$_SESSION['mysqlwarning'] = true;
}

$GLOBALS['cfg']['Server']['extension'] = $alternativ_extension;
unset($alternativ_extension);
}

/**
* Including The DBI Plugin
*/
switch($GLOBALS['cfg']['Server']['extension']) {
switch($extension) {
case 'mysql' :
include_once './libraries/dbi/DBIMysql.class.php';
$extension = new PMA_DBI_Mysql();
Expand All @@ -77,10 +67,6 @@
include_once './libraries/dbi/DBIMysqli.class.php';
$extension = new PMA_DBI_Mysqli();
break;
case 'drizzle' :
include_once './libraries/dbi/DBIDrizzle.class.php';
$extension = new PMA_DBI_Drizzle();
break;
}
}
$GLOBALS['dbi'] = new PMA_DatabaseInterface($extension);
Expand Down
2 changes: 1 addition & 1 deletion libraries/rte/rte_routines.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function PMA_RTN_main($type)
/**
* Display a warning for users with PHP's old "mysql" extension.
*/
if ($GLOBALS['cfg']['Server']['extension'] === 'mysql') {
if (! PMA_DatabaseInterface::checkDbExtension('mysqli')) {
trigger_error(
__(
'You are using PHP\'s deprecated \'mysql\' extension, '
Expand Down
1 change: 0 additions & 1 deletion setup/lib/common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
'Servers/1/host',
'Servers/1/port',
'Servers/1/socket',
'Servers/1/extension',
'Servers/1/connect_type',
'Servers/1/auth_type',
'Servers/1/user',
Expand Down
15 changes: 0 additions & 15 deletions setup/lib/index.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,21 +325,6 @@ function PMA_performConfigChecks()
);
}

//
// $cfg['Servers'][$i]['extension']
// warn about using 'mysql'
//
if ($cf->getValue("Servers/$i/extension") == 'mysql') {
$title = PMA_lang(PMA_langName('Servers/1/extension'))
. " ($server_name)";
PMA_messagesSet(
'notice',
"Servers/$i/extension",
$title,
__('You should use mysqli for performance reasons.')
);
}

//
// $cfg['Servers'][$i]['auth_type']
// warn about full user credentials if 'auth_type' is 'config'
Expand Down
10 changes: 0 additions & 10 deletions test/libraries/PMA_ConfigFile_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ public function testNewObjectState()
$this->object->getDefault('fontsize')
);

if (extension_loaded('mysqli')) {
$expect = "mysqli";
} else {
$expect = "mysql";
}

$this->assertEquals(
$expect,
$this->object->getDefault('Servers/1/extension')
);
$this->assertEquals(
array(),
$this->object->getConfig()
Expand Down
1 change: 0 additions & 1 deletion test/libraries/PMA_SetupIndex_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ public function testPMAPerformConfigChecks()
'ForceSSL',
'Servers/1/AllowNoPassword',
'Servers/1/auth_type',
'Servers/1/extension',
'Servers/1/ssl'
);

Expand Down
1 change: 0 additions & 1 deletion test/libraries/core/PMA_getTableCount_test_dis.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public function setUp()

function testTableCount()
{
$GLOBALS['cfg']['Server']['extension'] = 'mysql';
$GLOBALS['cfg']['Server']['host'] = 'localhost';
$GLOBALS['cfg']['Server']['user'] = 'root';

Expand Down
1 change: 0 additions & 1 deletion test/test_data/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';

0 comments on commit 2a8962a

Please sign in to comment.