Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
6d02869fe5
2506
libraries/controllers/server/ServerVariablesController.php
Normal file
2506
libraries/controllers/server/ServerVariablesController.php
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,97 +1,32 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Server variables
|
||||
* Handles server variables page.
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
use PMA\libraries\Message;
|
||||
use PMA\libraries\Util;
|
||||
namespace PMA;
|
||||
|
||||
use PMA\libraries\controllers\server\ServerVariablesController;
|
||||
use PMA\libraries\Response;
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/server_variables.lib.php';
|
||||
|
||||
$response = PMA\libraries\Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('server_variables.js');
|
||||
$container = libraries\di\Container::getDefaultContainer();
|
||||
$container->factory(
|
||||
'PMA\libraries\controllers\server\ServerVariablesController'
|
||||
);
|
||||
$container->alias(
|
||||
'ServerVariablesController',
|
||||
'PMA\libraries\controllers\server\ServerVariablesController'
|
||||
);
|
||||
$container->set('PMA\libraries\Response', Response::getInstance());
|
||||
$container->alias('response', 'PMA\libraries\Response');
|
||||
|
||||
/**
|
||||
* Does the common work
|
||||
*/
|
||||
require 'libraries/server_common.inc.php';
|
||||
|
||||
/**
|
||||
* Array of documentation links
|
||||
*/
|
||||
$variable_doc_links = PMA_getArrayForDocumentLinks();
|
||||
|
||||
/**
|
||||
* Ajax request
|
||||
*/
|
||||
|
||||
if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
if (isset($_REQUEST['type'])) {
|
||||
if ($_REQUEST['type'] === 'getval') {
|
||||
PMA_getAjaxReturnForGetVal($variable_doc_links);
|
||||
} else if ($_REQUEST['type'] === 'setval') {
|
||||
PMA_getAjaxReturnForSetVal($variable_doc_links);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the sub-page heading
|
||||
*/
|
||||
$doc_link = PMA\libraries\Util::showMySQLDocu('server_system_variables');
|
||||
$response->addHtml(PMA_getHtmlForSubPageHeader('variables', $doc_link));
|
||||
|
||||
/**
|
||||
* Sends the queries and buffers the results
|
||||
*/
|
||||
$serverVarsResult = $GLOBALS['dbi']->tryQuery('SHOW SESSION VARIABLES;');
|
||||
|
||||
if ($serverVarsResult !== false) {
|
||||
|
||||
$serverVarsSession = array();
|
||||
while ($arr = $GLOBALS['dbi']->fetchRow($serverVarsResult)) {
|
||||
$serverVarsSession[$arr[0]] = $arr[1];
|
||||
}
|
||||
$GLOBALS['dbi']->freeResult($serverVarsResult);
|
||||
|
||||
$serverVars = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES;', 0, 1);
|
||||
|
||||
/**
|
||||
* Link templates
|
||||
*/
|
||||
$response->addHtml(PMA_getHtmlForLinkTemplates());
|
||||
|
||||
/**
|
||||
* Displays the page
|
||||
*/
|
||||
$response->addHtml(
|
||||
PMA_getHtmlForServerVariables(
|
||||
$variable_doc_links, $serverVars, $serverVarsSession
|
||||
)
|
||||
);
|
||||
} else {
|
||||
/**
|
||||
* Display the error message
|
||||
*/
|
||||
$response->addHTML(
|
||||
Message::error(
|
||||
sprintf(
|
||||
__('Not enough privilege to view server variables and settings. %s'),
|
||||
Util::showMySQLDocu(
|
||||
'server-system-variables',
|
||||
false,
|
||||
'sysvar_show_compatibility_56'
|
||||
)
|
||||
)
|
||||
)->getDisplay()
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
/** @var ServerVariablesController $controller */
|
||||
$controller = $container->get(
|
||||
'ServerVariablesController', array()
|
||||
);
|
||||
$controller->indexAction();
|
||||
|
||||
13
templates/server/variables/link_template.phtml
Normal file
13
templates/server/variables/link_template.phtml
Normal file
@ -0,0 +1,13 @@
|
||||
<a style="display: none;" href="<?php echo $url; ?>" class="ajax saveLink">
|
||||
<?php echo \PMA\libraries\Util::getIcon('b_save.png', __('Save')); ?>
|
||||
</a>
|
||||
<a style="display: none;" href="#" class="cancelLink">
|
||||
<?php echo \PMA\libraries\Util::getIcon('b_close.png', __('Cancel')); ?>
|
||||
</a>
|
||||
<?php
|
||||
echo \PMA\libraries\Util::getImage(
|
||||
'b_help.png',
|
||||
__('Documentation'),
|
||||
array('style' => 'display:none', 'id' => 'docImage')
|
||||
);
|
||||
?>
|
||||
5
templates/server/variables/session_variable_row.phtml
Normal file
5
templates/server/variables/session_variable_row.phtml
Normal file
@ -0,0 +1,5 @@
|
||||
<tr class="var-row <?php echo $rowClass; ?>">
|
||||
<td class="var-action"></td>
|
||||
<td class="var-name session">(<?php echo __('Session value'); ?> )</td>
|
||||
<td class="var-value value"> <?php echo htmlspecialchars($value); ?></td>
|
||||
</tr>
|
||||
9
templates/server/variables/variable_filter.phtml
Normal file
9
templates/server/variables/variable_filter.phtml
Normal file
@ -0,0 +1,9 @@
|
||||
<fieldset id="tableFilter">
|
||||
<legend><?php echo __('Filters'); ?></legend>
|
||||
<div class="formelement">
|
||||
<label for="filterText"><?php echo __('Containing the word:'); ?></label>
|
||||
<input name="filterText" type="text" id="filterText"
|
||||
style="vertical-align: baseline;"
|
||||
value="<?php echo htmlspecialchars($filterValue); ?>" />
|
||||
</div>
|
||||
</fieldset>
|
||||
25
templates/server/variables/variable_row.phtml
Normal file
25
templates/server/variables/variable_row.phtml
Normal file
@ -0,0 +1,25 @@
|
||||
<tr class="var-row <?php echo $rowClass; ?>">
|
||||
<td class="var-action">
|
||||
<?php if ($editable): ?>
|
||||
<a href="#" class="editLink"><?php echo \PMA\libraries\Util::getIcon('b_edit.png', __('Edit')) ?></a>
|
||||
<?php else: ?>
|
||||
<span title="<?php echo __('This is a read-only variable and can not be edited') ?>" class="read_only_var">
|
||||
<?php echo \PMA\libraries\Util::getIcon('bd_edit.png', __('Edit')) ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="var-name">
|
||||
<?php if ($docLink != null): ?>
|
||||
<span title="<?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?>">
|
||||
<?php
|
||||
echo \PMA\libraries\Util::showMySQLDocu($docLink[1], false, $docLink[2] . '_' . $docLink[0], true);
|
||||
echo htmlspecialchars(str_replace('_', ' ', $name));
|
||||
echo '</a>';
|
||||
?>
|
||||
</span>
|
||||
<?php else: ?>
|
||||
<?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="var-value value <?php echo ($isSuperuser ? ' editable' : '') ?>"> <?php echo htmlspecialchars($value); ?></td>
|
||||
</tr>
|
||||
7
templates/server/variables/variable_table_head.phtml
Normal file
7
templates/server/variables/variable_table_head.phtml
Normal file
@ -0,0 +1,7 @@
|
||||
<thead>
|
||||
<tr class="var-header var-row">
|
||||
<td class="var-action"><?php echo __('Action'); ?></td>
|
||||
<td class="var-name"><?php echo __('Variable'); ?></td>
|
||||
<td class="var-value"><?php echo __('Session value'); ?> / <?php echo __('Global value'); ?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -1,35 +1,35 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* tests for server_variables.lib.php
|
||||
* Holds ServerVariablesControllerTest class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
use PMA\libraries\di\Container;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/url_generating.lib.php';
|
||||
require_once 'libraries/server_variables.lib.php';
|
||||
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
require_once 'test/libraries/stubs/ResponseStub.php';
|
||||
|
||||
require_once 'libraries/sanitizing.lib.php';
|
||||
require_once 'libraries/js_escape.lib.php';
|
||||
|
||||
/**
|
||||
* class PMA_ServerVariables_Test
|
||||
*
|
||||
* this class is for testing server_variables.lib.php functions
|
||||
* Tests for ServerVariablesController class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class PMA_ServerVariables_Test extends PHPUnit_Framework_TestCase
|
||||
class ServerVariablesControllerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var \PMA\Test\Stubs\Response
|
||||
*/
|
||||
private $response;
|
||||
|
||||
/**
|
||||
* Test for setUp
|
||||
*
|
||||
@ -104,50 +104,76 @@ class PMA_ServerVariables_Test extends PHPUnit_Framework_TestCase
|
||||
->will($this->returnValueMap($fetchResult));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
$container = Container::getDefaultContainer();
|
||||
$container->set('dbi', $GLOBALS['dbi']);
|
||||
$this->response = new \PMA\Test\Stubs\Response();
|
||||
$container->set('PMA\libraries\Response', $this->response);
|
||||
$container->alias('response', 'PMA\libraries\Response');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_formatVariable
|
||||
* Test for _formatVariable()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMAFormatVariable()
|
||||
public function testFormatVariable()
|
||||
{
|
||||
$class = new ReflectionClass('\PMA\libraries\controllers\server\ServerVariablesController');
|
||||
$method = $class->getMethod('_formatVariable');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$container = Container::getDefaultContainer();
|
||||
$container->factory('PMA\libraries\controllers\server\ServerVariablesController');
|
||||
$container->alias(
|
||||
'ServerVariablesController', 'PMA\libraries\controllers\server\ServerVariablesController'
|
||||
);
|
||||
$ctrl = $container->get('ServerVariablesController');
|
||||
|
||||
//Call the test function
|
||||
$name_for_value_byte = "binlog_cache_size";
|
||||
$name_for_value_not_byte = "auto_increment_increment";
|
||||
$name_for_value_not_num = "PMA_key";
|
||||
|
||||
$variable_doc_links = PMA_getArrayForDocumentLinks();
|
||||
|
||||
//name is_numeric and the value type is byte
|
||||
$this->assertEquals(
|
||||
'<abbr title="3">3 B</abbr>',
|
||||
PMA_formatVariable($name_for_value_byte, "3", $variable_doc_links)
|
||||
$method->invoke($ctrl, $name_for_value_byte, "3")
|
||||
);
|
||||
|
||||
//name is_numeric and the value type is not byte
|
||||
$this->assertEquals(
|
||||
'3',
|
||||
PMA_formatVariable($name_for_value_not_byte, "3", $variable_doc_links)
|
||||
$method->invoke($ctrl, $name_for_value_not_byte, "3")
|
||||
);
|
||||
|
||||
//value is not a number
|
||||
$this->assertEquals(
|
||||
'value',
|
||||
PMA_formatVariable($name_for_value_not_num, "value", $variable_doc_links)
|
||||
$method->invoke($ctrl, $name_for_value_not_num, "value")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getHtmlForLinkTemplates
|
||||
* Test for _getHtmlForLinkTemplates()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMAGetHtmlForLinkTemplates()
|
||||
public function testGetHtmlForLinkTemplates()
|
||||
{
|
||||
$class = new ReflectionClass('\PMA\libraries\controllers\server\ServerVariablesController');
|
||||
$method = $class->getMethod('_getHtmlForLinkTemplates');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$container = Container::getDefaultContainer();
|
||||
$container->factory('PMA\libraries\controllers\server\ServerVariablesController');
|
||||
$container->alias(
|
||||
'ServerVariablesController', 'PMA\libraries\controllers\server\ServerVariablesController'
|
||||
);
|
||||
$ctrl = $container->get('ServerVariablesController');
|
||||
|
||||
//Call the test function
|
||||
$html = PMA_getHtmlForLinkTemplates();
|
||||
$html = $method->invoke($ctrl);
|
||||
$url = 'server_variables.php' . PMA_URL_getCommon(array());
|
||||
|
||||
//validate 1: URL
|
||||
@ -167,22 +193,30 @@ class PMA_ServerVariables_Test extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getHtmlForServerVariables
|
||||
* Test for PMA_getHtmlForServerVariables()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMAGetHtmlForServerVariables()
|
||||
{
|
||||
//Call the test function
|
||||
$_REQUEST['filter'] = "auto-commit";
|
||||
$variable_doc_links = PMA_getArrayForDocumentLinks();
|
||||
|
||||
$class = new ReflectionClass('\PMA\libraries\controllers\server\ServerVariablesController');
|
||||
$method = $class->getMethod('_getHtmlForLinkTemplates');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$container = Container::getDefaultContainer();
|
||||
$container->factory('PMA\libraries\controllers\server\ServerVariablesController');
|
||||
$container->alias(
|
||||
'ServerVariablesController', 'PMA\libraries\controllers\server\ServerVariablesController'
|
||||
);
|
||||
$ctrl = $container->get('ServerVariablesController');
|
||||
|
||||
$_REQUEST['filter'] = "auto-commit";
|
||||
$serverVarsSession
|
||||
= $GLOBALS['dbi']->fetchResult('SHOW SESSION VARIABLES;', 0, 1);
|
||||
$serverVars = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES;', 0, 1);
|
||||
$html = PMA_getHtmlForServerVariables(
|
||||
$variable_doc_links, $serverVars, $serverVarsSession
|
||||
);
|
||||
|
||||
$html = $method->invoke($ctrl, $serverVars, $serverVarsSession);
|
||||
|
||||
//validate 1: Filters
|
||||
$this->assertContains(
|
||||
@ -214,21 +248,28 @@ class PMA_ServerVariables_Test extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getHtmlForServerVariablesItems
|
||||
* Test for _getHtmlForServerVariablesItems()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMAGetHtmlForServerVariablesItems()
|
||||
public function testGetHtmlForServerVariablesItems()
|
||||
{
|
||||
//Call the test function
|
||||
$variable_doc_links = PMA_getArrayForDocumentLinks();
|
||||
$class = new ReflectionClass('\PMA\libraries\controllers\server\ServerVariablesController');
|
||||
$method = $class->getMethod('_getHtmlForServerVariablesItems');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$container = Container::getDefaultContainer();
|
||||
$container->factory('PMA\libraries\controllers\server\ServerVariablesController');
|
||||
$container->alias(
|
||||
'ServerVariablesController', 'PMA\libraries\controllers\server\ServerVariablesController'
|
||||
);
|
||||
$ctrl = $container->get('ServerVariablesController');
|
||||
|
||||
$serverVarsSession
|
||||
= $GLOBALS['dbi']->fetchResult('SHOW SESSION VARIABLES;', 0, 1);
|
||||
$serverVars = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES;', 0, 1);
|
||||
$html = PMA_getHtmlForServerVariablesItems(
|
||||
$variable_doc_links, $serverVars, $serverVarsSession
|
||||
);
|
||||
|
||||
$html = $method->invoke($ctrl, $serverVars, $serverVarsSession);
|
||||
|
||||
//validate 1: variable: auto_increment_increment
|
||||
$name = "auto_increment_increment";
|
||||
Loading…
Reference in New Issue
Block a user