Merge pull request #13847 from nijel/collation

Move collation connection setting to user preferences
This commit is contained in:
Michal Čihař 2017-11-29 15:07:39 +01:00 committed by GitHub
commit 6a0345b10e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 121 additions and 217 deletions

View File

@ -569,10 +569,8 @@ if ($file_to_unlink != '') {
// Reset charset back, if we did some changes
if ($reset_charset) {
$GLOBALS['dbi']->query('SET CHARACTER SET utf8');
$GLOBALS['dbi']->query(
'SET SESSION collation_connection =\'' . $collation_connection . '\''
);
$GLOBALS['dbi']->query('SET CHARACTER SET ' . $GLOBALS['charset_connection']);
$GLOBALS['dbi']->setCollationConnection($collation_connection);
}
// Show correct message

View File

@ -85,6 +85,17 @@ if (isset($_POST['set_theme'])) {
header('Location: index.php' . Url::getCommonRaw());
exit();
}
// Change collation connection
if (isset($_POST['collation_connection'])) {
$GLOBALS['PMA_Config']->setUserValue(
null,
'DefaultConnectionCollation',
$_POST['collation_connection'],
'utf8mb4_unicode_ci'
);
header('Location: index.php' . Url::getCommonRaw());
exit();
}
// See FAQ 1.34
@ -235,7 +246,7 @@ if ($server > 0 || count($cfg['Servers']) > 1
}
} // end if
echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
echo ' <form method="post" action="index.php">' , "\n"
echo ' <form class="disableAjax" method="post" action="index.php">' , "\n"
. Url::getHiddenInputs(null, null, 4, 'collation_connection')
. ' <label for="select_collation_connection">' . "\n"
. ' ' . Util::getImage('s_asci')

View File

@ -757,8 +757,6 @@ class Config
}
if (! $this->checkConfigSource()) {
// even if no config file, set collation_connection
$this->checkCollationConnection();
return false;
}
@ -834,51 +832,21 @@ class Config
$this->checkServers();
// Handling of the collation must be done after merging of $cfg
// (from config.inc.php) so that $cfg['DefaultConnectionCollation']
// can have an effect.
$this->checkCollationConnection();
return true;
}
/**
* Saves the connection collation
*
* @param array $config_data configuration data from user preferences
* Sets the connection collation
*
* @return void
*/
private function _saveConnectionCollation(array $config_data)
private function _setConnectionCollation()
{
// just to shorten the lines
$collation = 'collation_connection';
if (isset($GLOBALS[$collation])
&& (isset($_COOKIE['pma_collation_connection'])
|| isset($_POST[$collation]))
$collation_connection = $this->get('DefaultConnectionCollation');
if (! empty($collation_connection)
&& $collation_connection != $GLOBALS['collation_connection']
) {
if ((! isset($config_data[$collation])
&& $GLOBALS[$collation] != 'utf8_general_ci')
|| isset($config_data[$collation])
&& $GLOBALS[$collation] != $config_data[$collation]
) {
$this->setUserValue(
null,
$collation,
$GLOBALS[$collation],
'utf8_general_ci'
);
}
} else {
// read collation from settings
if (isset($config_data[$collation])) {
$GLOBALS[$collation]
= $config_data[$collation];
$this->setCookie(
'pma_collation_connection',
$GLOBALS[$collation]
);
}
$GLOBALS['dbi']->setCollation($collation_connection);
}
}
@ -988,8 +956,8 @@ class Config
}
}
// save connection collation
$this->_saveConnectionCollation($config_data);
// set connection collation
$this->_setConnectionCollation();
}
/**
@ -1234,33 +1202,6 @@ class Config
$GLOBALS['PMA_Theme']->filesize_info);
}
/**
* Sets collation_connection based on user preference. First is checked
* value from request, then cookies with fallback to default.
*
* After setting it here, cookie is set in common.inc.php to persist
* the selection.
*
* @todo check validity of collation string
*
* @return void
*/
public function checkCollationConnection()
{
if (! empty($_REQUEST['collation_connection'])) {
$collation = htmlspecialchars(
strip_tags($_REQUEST['collation_connection'])
);
} elseif (! empty($_COOKIE['pma_collation_connection'])) {
$collation = htmlspecialchars(
strip_tags($_COOKIE['pma_collation_connection'])
);
} else {
$collation = $this->get('DefaultConnectionCollation');
}
$this->set('collation_connection', $collation);
}
/**
* checks if upload is enabled
*
@ -1403,7 +1344,6 @@ class Config
$GLOBALS['cfg'] = $this->settings;
$GLOBALS['default_server'] = $this->default_server;
unset($this->default_server);
$GLOBALS['collation_connection'] = $this->get('collation_connection');
$GLOBALS['is_upload'] = $this->get('enable_upload');
$GLOBALS['max_upload_size'] = $this->get('max_upload_size');
$GLOBALS['is_https'] = $this->get('is_https');

View File

@ -1484,6 +1484,8 @@ class Descriptions
return __('Order by');
case 'FontSize_name':
return __('Font size');
case 'DefaultConnectionCollation_name':
return __('Server connection collation');
}
return null;
}

View File

@ -31,6 +31,7 @@ class FeaturesForm extends BaseForm
'Servers/1/hide_db', // saves to Server/hide_db
'MaxDbList',
'MaxTableList',
'DefaultConnectionCollation',
),
'Text_fields' => array(
'CharEditing',

View File

@ -1435,46 +1435,13 @@ class DatabaseInterface
$default_charset = 'utf8';
$default_collation = 'utf8_general_ci';
}
$collation_connection = $GLOBALS['PMA_Config']->get('collation_connection');
if (! empty($collation_connection)) {
$this->query(
"SET CHARACTER SET '$default_charset';",
DatabaseInterface::CONNECT_USER,
self::QUERY_STORE
);
/* Automatically adjust collation if not supported by server */
if ($default_charset == 'utf8'
&& strncmp('utf8mb4_', $collation_connection, 8) == 0
) {
$collation_connection = 'utf8_' . substr($collation_connection, 8);
}
$result = $this->tryQuery(
"SET collation_connection = '"
. $this->escapeString($collation_connection, DatabaseInterface::CONNECT_USER)
. "';",
DatabaseInterface::CONNECT_USER,
self::QUERY_STORE
);
if ($result === false) {
trigger_error(
__('Failed to set configured collation connection!'),
E_USER_WARNING
);
$this->query(
"SET collation_connection = '"
. $this->escapeString($collation_connection, DatabaseInterface::CONNECT_USER)
. "';",
DatabaseInterface::CONNECT_USER,
self::QUERY_STORE
);
}
} else {
$this->query(
"SET NAMES '$default_charset' COLLATE '$default_collation';",
DatabaseInterface::CONNECT_USER,
self::QUERY_STORE
);
}
$GLOBALS['collation_connection'] = $default_collation;
$GLOBALS['charset_connection'] = $default_charset;
$this->query(
"SET NAMES '$default_charset' COLLATE '$default_collation';",
DatabaseInterface::CONNECT_USER,
self::QUERY_STORE
);
/* Locale for messages */
$locale = LanguageManager::getInstance()->getCurrentLanguage()->getMySQLLocale();
@ -1522,6 +1489,35 @@ class DatabaseInterface
$GLOBALS['dblist'] = new DatabaseList();
}
/**
* Sets collation connection for user link
*
* @param string $collation collation to set
*/
public function setCollation($collation)
{
$charset = $GLOBALS['charset_connection'];
/* Automatically adjust collation if not supported by server */
if ($charset == 'utf8' && strncmp('utf8mb4_', $collation, 8) == 0) {
$collation = 'utf8_' . substr($collation, 8);
}
$result = $this->tryQuery(
"SET collation_connection = '"
. $this->escapeString($collation, DatabaseInterface::CONNECT_USER)
. "';",
DatabaseInterface::CONNECT_USER,
self::QUERY_STORE
);
if ($result === false) {
trigger_error(
__('Failed to set configured collation connection!'),
E_USER_WARNING
);
} else {
$GLOBALS['collation_connection'] = $collation;
}
}
/**
* Function called just after a connection to the MySQL database server has
* been established. It sets the connection collation, and determines the

View File

@ -219,17 +219,11 @@ class Header
$pftext = isset($_SESSION['tmpval']['pftext'])
? $_SESSION['tmpval']['pftext'] : '';
// not sure when this happens, but it happens
if (! isset($GLOBALS['collation_connection'])) {
$GLOBALS['collation_connection'] = 'utf8_general_ci';
}
$params = array(
'common_query' => Url::getCommonRaw(),
'opendb_url' => Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabDatabase'], 'database'
),
'collation_connection' => $GLOBALS['collation_connection'],
'lang' => $GLOBALS['lang'],
'server' => $GLOBALS['server'],
'table' => $table,

View File

@ -57,11 +57,6 @@ class Url
if (empty($_COOKIE['pma_lang']) && ! empty($GLOBALS['lang'])) {
$params['lang'] = $GLOBALS['lang'];
}
if (empty($_COOKIE['pma_collation_connection'])
&& ! empty($GLOBALS['collation_connection'])
) {
$params['collation_connection'] = $GLOBALS['collation_connection'];
}
if (! is_array($skip)) {
if (isset($params[$skip])) {
@ -217,11 +212,6 @@ class Url
if (empty($_COOKIE['pma_lang']) && ! empty($GLOBALS['lang'])) {
$params['lang'] = $GLOBALS['lang'];
}
if (empty($_COOKIE['pma_collation_connection'])
&& ! empty($GLOBALS['collation_connection'])
) {
$params['collation_connection'] = $GLOBALS['collation_connection'];
}
$query = http_build_query($params, null, $separator);

View File

@ -169,7 +169,6 @@ class UserPreferences
// whitelist some additional fields which are custom handled
$whitelist['ThemeDefault'] = true;
$whitelist['lang'] = true;
$whitelist['collation_connection'] = true;
$whitelist['Server/hide_db'] = true;
$whitelist['Server/only_db'] = true;
$whitelist['2fa'] = true;

View File

@ -176,7 +176,7 @@ if (Core::checkPageValidity($_REQUEST['back'])) {
* mis-match does not make sense
*
* @todo variables should be handled by their respective owners (objects)
* f.e. lang, server, collation_connection in PhpMyAdmin\Config
* f.e. lang, server in PhpMyAdmin\Config
*/
$token_mismatch = true;
@ -291,12 +291,6 @@ if (! defined('PMA_MINIMUM_COMMON')) {
* @todo should be done in PhpMyAdmin\Config
*/
$GLOBALS['PMA_Config']->setCookie('pma_lang', $GLOBALS['lang']);
if (isset($GLOBALS['collation_connection'])) {
$GLOBALS['PMA_Config']->setCookie(
'pma_collation_connection',
$GLOBALS['collation_connection']
);
}
ThemeManager::getInstance()->setThemeCookie();

View File

@ -160,11 +160,6 @@ if (isset($_POST['submit_export'])
) {
$params['lang'] = $config['lang'];
}
if (isset($config['collation_connection'])
&& $config['collation_connection'] != $GLOBALS['collation_connection']
) {
$params['collation_connection'] = $config['collation_connection'];
}
// save settings
$result = UserPreferences::save($cf->getConfigArray());

View File

@ -545,22 +545,6 @@ class ConfigTest extends PmaTestCase
);
}
/**
* test for CheckCollationConnection
*
* @return void
*/
public function testCheckCollationConnection()
{
$_REQUEST['collation_connection'] = 'utf-8';
$this->object->checkCollationConnection();
$this->assertEquals(
$_REQUEST['collation_connection'],
$this->object->get('collation_connection')
);
}
/**
* test for IsHttp
*

View File

@ -35,7 +35,6 @@ class SearchTest extends PmaTestCase
$this->object = new Search('pma_test');
$GLOBALS['server'] = 0;
$GLOBALS['db'] = 'pma';
$GLOBALS['collation_connection'] = 'utf-8';
//mock DBI
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
@ -216,14 +215,13 @@ class SearchTest extends PmaTestCase
. '</td><td><a name="browse_search" class="ajax browse_results" '
. 'href="sql.php?db=pma&amp;table'
. '=table1&amp;goto=db_sql.php&amp;pos=0&amp;is_js_confirmed=0&amp;'
. 'server=0&amp;lang=en&amp;'
. 'collation_connection=utf-8" '
. 'server=0&amp;lang=en" '
. 'data-browse-sql="column1" data-table-name="table1" '
. '>Browse</a></td><td>'
. '<a name="delete_search" class="ajax delete_results" href'
. '="sql.php?db=pma&amp;table=table1&amp;goto=db_sql.php&amp;pos=0'
. '&amp;is_js_confirmed=0&amp;server=0&amp;'
. 'lang=en&amp;collation_connection=utf-8" '
. 'lang=en" '
. 'data-delete-sql="column2" '
. 'data-table-name="table1" '
. '>Delete</a></td></tr>'

View File

@ -442,6 +442,45 @@ class DatabaseInterfaceTest extends PmaTestCase
array('10.1.22-MariaDB-', 100122, 10, false),
);
}
/**
* Tests for DBI::setCollationl() method.
*
* @return void
* @test
*/
public function testSetCollation()
{
$extension = $this->getMockBuilder('PhpMyAdmin\Dbi\DbiDummy')
->disableOriginalConstructor()
->getMock();
$extension->expects($this->any())->method('escapeString')
->will($this->returnArgument(1));
$extension->expects($this->exactly(4))
->method('realQuery')
->withConsecutive(
array("SET collation_connection = 'utf8_czech_ci';"),
array("SET collation_connection = 'utf8mb4_bin_ci';"),
array("SET collation_connection = 'utf8_czech_ci';"),
array("SET collation_connection = 'utf8_bin_ci';")
)
->willReturnOnConsecutiveCalls(
true,
true,
true,
true
);
$dbi = new DatabaseInterface($extension);
$GLOBALS['charset_connection'] = 'utf8mb4';
$dbi->setCollation('utf8_czech_ci');
$dbi->setCollation('utf8mb4_bin_ci');
$GLOBALS['charset_connection'] = 'utf8';
$dbi->setCollation('utf8_czech_ci');
$dbi->setCollation('utf8mb4_bin_ci');
}
}
/**

View File

@ -43,7 +43,6 @@ class ResultsTest extends PmaTestCase
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['collation_connection'] = 'utf-8';
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
->disableOriginalConstructor()
@ -965,7 +964,6 @@ class ResultsTest extends PmaTestCase
'routine_name',
'db_routines.php?item_name=circumference&db=data'
. '&item_type=FUNCTION&server=0&lang=en'
. '&collation_connection=utf-8'
),
array(
'information_schema',
@ -979,7 +977,6 @@ class ResultsTest extends PmaTestCase
'routine_name',
'db_routines.php?item_name=area&db=data'
. '&item_type=PROCEDURE&server=0&lang=en'
. '&collation_connection=utf-8'
),
array(
'information_schema',
@ -993,7 +990,6 @@ class ResultsTest extends PmaTestCase
'index.php?sql_query=SELECT+%60CHARACTER_SET_NAME%60+FROM+%60info'
. 'rmation_schema%60.%60CHARACTER_SETS%60&db=information_schema'
. '&test_name=value&server=0&lang=en'
. '&collation_connection=utf-8'
)
);
}
@ -1160,7 +1156,6 @@ class ResultsTest extends PmaTestCase
. '<input type="hidden" name="db" value="mysql" />'
. '<input type="hidden" name="table" value="user" />'
. '<input type="hidden" name="lang" value="en" />'
. '<input type="hidden" name="collation_connection" value="utf-8" />'
. '<input type="hidden" name="token" value="token" />'
. '<input type="hidden" name="sql_query" value="SELECT * FROM `user`" />'
. '<input type="hidden" name="pos" value="0" />'
@ -1340,7 +1335,7 @@ class ResultsTest extends PmaTestCase
$url_params,
null,
'<a href="tbl_get_field.php?db=foo&amp;table=bar&amp;server=0'
. '&amp;lang=en&amp;collation_connection=utf-8'
. '&amp;lang=en'
. '" class="disableAjax">1001</a>'
),
array(
@ -1355,7 +1350,7 @@ class ResultsTest extends PmaTestCase
$url_params,
null,
'<a href="tbl_get_field.php?db=foo&amp;table=bar&amp;server=0'
. '&amp;lang=en&amp;collation_connection=utf-8'
. '&amp;lang=en'
. '" class="disableAjax">0x123456</a>'
),
array(
@ -1370,7 +1365,7 @@ class ResultsTest extends PmaTestCase
$url_params,
null,
'<a href="tbl_get_field.php?db=foo&amp;table=bar&amp;server=0'
. '&amp;lang=en&amp;collation_connection=utf-8'
. '&amp;lang=en'
. '" class="disableAjax">[BLOB - 4 B]</a>'
),
array(
@ -1494,7 +1489,6 @@ class ResultsTest extends PmaTestCase
'<td class="left hex">' . PHP_EOL
. ' <a href="tbl_get_field.php?'
. 'db=foo&amp;table=tbl&amp;server=0&amp;lang=en'
. '&amp;collation_connection=utf-8'
. '" '
. 'class="disableAjax">[BLOB - 4 B]</a>' . PHP_EOL
. '</td>' . PHP_EOL

View File

@ -47,7 +47,6 @@ class FooterTest extends PmaTestCase
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['collation_connection'] = 'utf8_general_ci';
$GLOBALS['cfg']['Server']['verbose'] = 'verbose host';
$GLOBALS['server'] = '1';
$_GET['reload_left_frame'] = '1';
@ -155,8 +154,8 @@ class FooterTest extends PmaTestCase
$this->assertEquals(
'<div id="selflink" class="print_ignore"><a href="index.php?db=&amp;'
. 'table=&amp;server=1&amp;target=&amp;lang=en&amp;collation_connection='
. 'utf8_general_ci" title="Open new phpMyAdmin window" '
. 'table=&amp;server=1&amp;target=&amp;lang=en'
. '" title="Open new phpMyAdmin window" '
. 'target="_blank" rel="noopener noreferrer">Open new phpMyAdmin window</a></div>',
$this->_callPrivateFunction(
'_getSelfLink',
@ -180,8 +179,8 @@ class FooterTest extends PmaTestCase
$this->assertEquals(
'<div id="selflink" class="print_ignore"><a href="index.php?db=&amp;'
. 'table=&amp;server=1&amp;target=&amp;lang=en&amp;collation_connection='
. 'utf8_general_ci" title="Open new phpMyAdmin window" '
. 'table=&amp;server=1&amp;target=&amp;lang=en'
. '" title="Open new phpMyAdmin window" '
. 'target="_blank" rel="noopener noreferrer"><img src="themes/dot.gif" title="Open new '
. 'phpMyAdmin window" alt="Open new phpMyAdmin window" '
. 'class="icon ic_window-new" /></a></div>',

View File

@ -280,7 +280,6 @@ class InsertEditTest extends TestCase
*/
public function testShowTypeOrFunction()
{
unset($GLOBALS['collation_connection']);
$GLOBALS['cfg']['ShowFieldTypesInDataEditView'] = true;
$GLOBALS['cfg']['ServerDefault'] = 1;
$url_params = array('ShowFunctionFields' => 2);

View File

@ -425,7 +425,6 @@ class MessageTest extends PmaTestCase
public function testDecodeBB($actual, $expected)
{
unset($GLOBALS['server']);
unset($GLOBALS['collation_connection']);
$this->assertEquals($expected, Message::decodeBB($actual));
}

View File

@ -97,7 +97,6 @@ class AuthenticationConfigTest extends PmaTestCase
$GLOBALS['error_handler'] = new ErrorHandler;
$GLOBALS['cfg']['Servers'] = array(1);
$GLOBALS['allowDeny_forbidden'] = false;
$GLOBALS['collation_connection'] = 'utf-8';
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
->disableOriginalConstructor()
@ -129,8 +128,7 @@ class AuthenticationConfigTest extends PmaTestCase
);
$this->assertContains(
'<a href="index.php?server=0&amp;lang=en'
. '&amp;collation_connection=utf-8" '
'<a href="index.php?server=0&amp;lang=en" '
. 'class="button disableAjax">Retry to connect</a>',
$html
);

View File

@ -371,11 +371,10 @@ class AuthenticationCookieTest extends PmaTestCase
$GLOBALS['cfg']['Servers'] = array(1, 2, 3);
$GLOBALS['cfg']['Server']['LogoutURL'] = 'https://example.com/logout';
$GLOBALS['cfg']['Server']['auth_type'] = 'cookie';
$GLOBALS['collation_connection'] = 'utf-8';
$_COOKIE['pmaAuth-2'] = '';
$this->mockResponse('Location: /phpmyadmin/index.php?server=2&lang=en&collation_connection=utf-8');
$this->mockResponse('Location: /phpmyadmin/index.php?server=2&lang=en');
$this->object->logOut();
}
@ -727,10 +726,9 @@ class AuthenticationCookieTest extends PmaTestCase
$GLOBALS['server'] = 2;
$GLOBALS['cfg']['LoginCookieStore'] = true;
$GLOBALS['from_cookie'] = false;
$GLOBALS['collation_connection'] = 'utf-8';
$this->mockResponse(
$this->stringContains('&server=2&lang=en&collation_connection=utf-8')
$this->stringContains('&server=2&lang=en')
);
$this->object->storeCredentials();

View File

@ -50,7 +50,6 @@ class SanitizeTest extends TestCase
unset($GLOBALS['server']);
unset($GLOBALS['lang']);
unset($GLOBALS['collation_connection']);
$this->assertEquals(
'<a href="./url.php?url=https%3A%2F%2Fwww.phpmyadmin.net%2F" target="target">link</a>',
Sanitize::sanitize('[a@https://www.phpmyadmin.net/@target]link[/a]')

View File

@ -70,7 +70,6 @@ class PrivilegesTest extends TestCase
$GLOBALS['server'] = 1;
$GLOBALS['hostname'] = "hostname";
$GLOBALS['username'] = "username";
$GLOBALS['collation_connection'] = "collation_connection";
$GLOBALS['text_dir'] = "text_dir";
$GLOBALS['is_reload_priv'] = true;
@ -2406,14 +2405,12 @@ class PrivilegesTest extends TestCase
$this->assertContains('<td>Z</td>', $actual);
$this->assertContains(
'<a class="ajax" href="server_privileges.php?initial=-&amp;'
. 'server=1&amp;lang=en&amp;collation_connection='
. 'collation_connection">-</a>',
. 'server=1&amp;lang=en">-</a>',
$actual
);
$this->assertContains(
'<a class="ajax" href="server_privileges.php?initial=%22&amp;'
. 'server=1&amp;lang=en&amp;collation_connection='
. 'collation_connection">"</a>',
. 'server=1&amp;lang=en">"</a>',
$actual
);
$this->assertContains('Show all', $actual);

View File

@ -30,7 +30,6 @@ class ThemeManagerTest extends PmaTestCase
$GLOBALS['cfg']['ServerDefault'] = 0;
$GLOBALS['server'] = 99;
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['collation_connection'] = 'utf8_general_ci';
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
->disableOriginalConstructor()

View File

@ -44,7 +44,6 @@ class ThemeTest extends PmaTestCase
$GLOBALS['text_dir'] = 'ltr';
include 'themes/pmahomme/layout.inc.php';
$GLOBALS['server'] = '99';
$GLOBALS['collation_connection'] = 'utf-8';
}
/**
@ -294,7 +293,6 @@ class ThemeTest extends PmaTestCase
$this->object->getPrintPreview(),
'<div class="theme_preview"><h2> (0.0.0.0) </h2><p><a class="take_'
. 'theme" name="" href="index.php?set_theme=&amp;server=99&amp;lang=en'
. '&amp;collation_connection=utf-8'
. '">No preview available.[ <strong>take it</strong> ]'
. '</a></p></div>'
);

View File

@ -26,7 +26,7 @@ class UrlTest extends TestCase
*/
public function setUp()
{
unset($_COOKIE['pma_lang'], $_COOKIE['pma_collation_connection']);
unset($_COOKIE['pma_lang']);
}
/**
@ -37,14 +37,10 @@ class UrlTest extends TestCase
public function testDbOnly()
{
$GLOBALS['server'] = 'x';
$GLOBALS['collation_connection'] = 'x';
$GLOBALS['cfg']['ServerDefault'] = 'y';
$separator = Url::getArgSeparator();
$expected = 'server=x' . htmlentities($separator)
. 'lang=en' . htmlentities($separator)
. 'collation_connection=x'
;
$expected = 'server=x' . htmlentities($separator) . 'lang=en' ;
$expected = '?db=db'
. htmlentities($separator) . $expected;
@ -60,14 +56,10 @@ class UrlTest extends TestCase
public function testNewStyle()
{
$GLOBALS['server'] = 'x';
$GLOBALS['collation_connection'] = 'x';
$GLOBALS['cfg']['ServerDefault'] = 'y';
$separator = Url::getArgSeparator();
$expected = 'server=x' . htmlentities($separator)
. 'lang=en' . htmlentities($separator)
. 'collation_connection=x'
;
$expected = 'server=x' . htmlentities($separator) . 'lang=en' ;
$expected = '?db=db'
. htmlentities($separator) . 'table=table'
@ -84,14 +76,10 @@ class UrlTest extends TestCase
public function testWithAlternateDivider()
{
$GLOBALS['server'] = 'x';
$GLOBALS['collation_connection'] = 'x';
$GLOBALS['cfg']['ServerDefault'] = 'y';
$separator = Url::getArgSeparator();
$expected = 'server=x' . $separator
. 'lang=en' . $separator
. 'collation_connection=x'
;
$expected = 'server=x' . $separator . 'lang=en' ;
$expected = '#ABC#db=db' . $separator . 'table=table' . $separator
. $expected;
@ -111,14 +99,10 @@ class UrlTest extends TestCase
public function testDefault()
{
$GLOBALS['server'] = 'x';
$GLOBALS['collation_connection'] = 'x';
$GLOBALS['cfg']['ServerDefault'] = 'y';
$separator = Url::getArgSeparator();
$expected = '?server=x' . htmlentities($separator)
. 'lang=en' . htmlentities($separator)
. 'collation_connection=x'
;
$expected = '?server=x' . htmlentities($separator) . 'lang=en' ;
$this->assertEquals($expected, Url::getCommon());
}
}

View File

@ -30,7 +30,6 @@ class UserPreferencesTest extends PmaTestCase
include 'libraries/config.default.php';
$GLOBALS['server'] = 0;
$GLOBALS['PMA_PHP_SELF'] = '/phpmyadmin/';
$GLOBALS['collation_connection'] = 'utf8_general_ci';
}
/**
@ -355,7 +354,7 @@ class UserPreferencesTest extends PmaTestCase
{
$GLOBALS['lang'] = '';
$this->mockResponse('Location: /phpmyadmin/file.html?a=b&saved=1&server=0&collation_connection=utf8_general_ci#h+ash');
$this->mockResponse('Location: /phpmyadmin/file.html?a=b&saved=1&server=0#h+ash');
$GLOBALS['PMA_Config']->set('PmaAbsoluteUri', '');
$GLOBALS['PMA_Config']->set('PMA_IS_IIS', false);