From adb2e43f7d20ba42d2258d6b8151196f7bfe64bf Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Thu, 2 May 2013 21:36:05 +0530 Subject: [PATCH] Implement feature request #1414 - Allow specifying crontrolport Set the value of controlport based on the value of controlhost --- ChangeLog | 1 + config.sample.inc.php | 1 + doc/config.rst | 9 +++++++++ libraries/common.inc.php | 23 +++++++++++++++++++++-- libraries/config.default.php | 9 +++++++++ libraries/config/messages.inc.php | 2 ++ libraries/config/setup.forms.php | 1 + 7 files changed, 44 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f0c834a06d..e518c6d877 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ phpMyAdmin - ChangeLog + Break server_status.php functions into smaller functions + PMA_DBI functions in database_interface.lib.php renamed to be compliant with PEAR standards + [interface] Make warning about existing config directory clearer ++ rfe #1414 Allow specifying crontrolport 4.0.1.0 (not yet released) - bug #3879 Import broken for CSV using LOAD DATA diff --git a/config.sample.inc.php b/config.sample.inc.php index 10db2b508e..37a2f099b5 100644 --- a/config.sample.inc.php +++ b/config.sample.inc.php @@ -41,6 +41,7 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false; /* User used to manipulate with storage */ // $cfg['Servers'][$i]['controlhost'] = ''; +// $cfg['Servers'][$i]['controlport'] = ''; // $cfg['Servers'][$i]['controluser'] = 'pma'; // $cfg['Servers'][$i]['controlpass'] = 'pmapass'; diff --git a/doc/config.rst b/doc/config.rst index 7087ecf243..d9087ca87d 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -237,6 +237,15 @@ Server connection settings Permits to use an alternate host to hold the configuration storage data. +.. _controlport: +.. config:option:: $cfg['Servers'][$i]['controlport'] + + :type: string + :default: ``''`` + + Permits to use an alternate port to connect to the host that + holds the configuration storage. + .. _controluser: .. config:option:: $cfg['Servers'][$i]['controluser'] diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 35bc44d7da..f8da9816ca 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -931,12 +931,31 @@ if (! defined('PMA_MINIMUM_COMMON')) { // scripts) $controllink = false; if ($cfg['Server']['controluser'] != '') { - if (! empty($cfg['Server']['controlhost'])) { + if (! empty($cfg['Server']['controlhost']) + || ! empty($cfg['Server']['controlport']) + ) { + $server_details = array(); + if (! empty($cfg['Server']['controlhost'])) { + $server_details['host'] = $cfg['Server']['controlhost']; + } else { + $server_details['host'] = $cfg['Server']['host']; + } + if (! empty($cfg['Server']['controlport'])) { + $server_details['port'] = $cfg['Server']['controlport']; + } elseif ($server_details['host'] == $cfg['Server']['host']) { + // Evaluates to true when controlhost == host + // or controlhost is not defined (hence it defaults to host) + // In such case we can use the value of port. + $server_details['port'] = $cfg['Server']['port']; + } + // otherwise we leave the $server_details['port'] unset, + // allowing it to take default mysql port + $controllink = PMA_DBI_connect( $cfg['Server']['controluser'], $cfg['Server']['controlpass'], true, - array('host' => $cfg['Server']['controlhost']) + $server_details ); } else { $controllink = PMA_DBI_connect( diff --git a/libraries/config.default.php b/libraries/config.default.php index 2d4c89baf0..23c20e22c2 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -167,6 +167,15 @@ $cfg['Servers'][$i]['compress'] = false; */ $cfg['Servers'][$i]['controlhost'] = ''; +/** + * MySQL control port. This permits to use a port different than the + * main port, for the phpMyAdmin configuration storage. If left empty, + * $cfg['Servers'][$i]['port'] is used instead. + * + * @global string $cfg['Servers'][$i]['controlport'] + */ +$cfg['Servers'][$i]['controlport'] = ''; + /** * MySQL control user settings (this user must have read-only * access to the "mysql/user" and "mysql/db" tables). The controluser is also diff --git a/libraries/config/messages.inc.php b/libraries/config/messages.inc.php index 2b8204e3ff..fe6ccaf659 100644 --- a/libraries/config/messages.inc.php +++ b/libraries/config/messages.inc.php @@ -386,6 +386,8 @@ $strConfigServers_controluser_desc = __('A special MySQL user configured with li $strConfigServers_controluser_name = __('Control user'); $strConfigServers_controlhost_desc = __('An alternate host to hold the configuration storage; leave blank to use the already defined host'); $strConfigServers_controlhost_name = __('Control host'); +$strConfigServers_controlport_desc = __('An alternate port to connect to the host that holds the configuration storage; leave blank to use the already defined port'); +$strConfigServers_controlport_name = __('Control port'); $strConfigServers_CountTables_desc = __('Count tables when showing database list'); $strConfigServers_CountTables_name = __('Count tables'); $strConfigServers_designer_coords_desc = __('Leave blank for no Designer support, suggested: [kbd]pma__designer_coords[/kbd]'); diff --git a/libraries/config/setup.forms.php b/libraries/config/setup.forms.php index 5f42688808..17378b0b92 100644 --- a/libraries/config/setup.forms.php +++ b/libraries/config/setup.forms.php @@ -65,6 +65,7 @@ $forms['Servers']['Server_config'] = array('Servers' => array(1 => array( $forms['Servers']['Server_pmadb'] = array('Servers' => array(1 => array( 'pmadb' => 'phpmyadmin', 'controlhost', + 'controlport', 'controluser', 'controlpass', 'bookmarktable' => 'pma__bookmark',