Merge branch 'QA_4_6' of https://github.com/phpmyadmin/phpmyadmin into QA_4_6
Conflicts: ChangeLog
This commit is contained in:
commit
71cce8e2f5
@ -30,6 +30,9 @@ phpMyAdmin - ChangeLog
|
||||
- issue #12473 Code can throw unhandled exception
|
||||
- issue #12550 Do not try to keep alive session even after expiry
|
||||
- issue #12512 Fixed rendering BBCode links in setup
|
||||
- issue #12518 Fixed copy of table with generated columns
|
||||
- issue #12221 Fixed export of table with generated columns
|
||||
- issue #12320 Copying a user does not copy usergroup
|
||||
- issue #12272 Adding a new row with default enum goes to no selection when you want to add more then 2 rows
|
||||
|
||||
4.6.4 (2016-08-16)
|
||||
|
||||
@ -756,6 +756,7 @@ are always ways to make your installation more secure:
|
||||
|
||||
* Serve phpMyAdmin on HTTPS only. Preferably, you should use HSTS as well, so that
|
||||
you're protected from protocol downgrade attacks.
|
||||
* Remove the ``test`` directory from phpMyAdmin, unless you are developing and need test suite.
|
||||
* Remove the ``setup`` directory from phpMyAdmin, you will probably not
|
||||
use it after the initial setup.
|
||||
* Properly choose an authentication method - :ref:`cookie`
|
||||
|
||||
@ -906,7 +906,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
var remaining = PMA_commonParams.get('LoginCookieValidity') - _idleSecondsCounter;
|
||||
if (remaining > 5) {
|
||||
// max value for setInterval() function
|
||||
var interval = min(remaining * 1000, Math.pow(2, 31) - 1);
|
||||
var interval = Math.min(remaining * 1000, Math.pow(2, 31) - 1);
|
||||
updateTimeout = window.setTimeout(UpdateIdleTime, interval);
|
||||
} else if (remaining > 0) {
|
||||
// We're close to session expiry
|
||||
|
||||
@ -1017,10 +1017,17 @@ class Table
|
||||
$GLOBALS['dbi']->query($sql_set_mode);
|
||||
$GLOBALS['sql_query'] .= "\n\n" . $sql_set_mode . ';';
|
||||
|
||||
$sql_insert_data = 'INSERT INTO ' . $target
|
||||
. ' SELECT * FROM ' . $source;
|
||||
$GLOBALS['dbi']->query($sql_insert_data);
|
||||
$GLOBALS['sql_query'] .= "\n\n" . $sql_insert_data . ';';
|
||||
$_old_table = new Table($source_table, $source_db);
|
||||
$nonGeneratedCols = $_old_table->getNonGeneratedColumns(true);
|
||||
if (count($nonGeneratedCols) > 0) {
|
||||
$sql_insert_data = 'INSERT INTO ' . $target . '('
|
||||
. implode(', ', $nonGeneratedCols)
|
||||
. ') SELECT ' . implode(', ', $nonGeneratedCols)
|
||||
. ' FROM ' . $source;
|
||||
|
||||
$GLOBALS['dbi']->query($sql_insert_data);
|
||||
$GLOBALS['sql_query'] .= "\n\n" . $sql_insert_data . ';';
|
||||
}
|
||||
}
|
||||
|
||||
PMA_getRelationsParam();
|
||||
@ -1484,6 +1491,40 @@ class Table
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get non-generated columns in table
|
||||
*
|
||||
* @param bool $backquoted whether to quote name with backticks ``
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNonGeneratedColumns($backquoted = true)
|
||||
{
|
||||
$columns_meta_query = 'SHOW COLUMNS FROM ' . $this->getFullName(true);
|
||||
$ret = array();
|
||||
|
||||
$columns_meta_query_result = $this->_dbi->fetchResult(
|
||||
$columns_meta_query
|
||||
);
|
||||
|
||||
if ($columns_meta_query_result
|
||||
&& $columns_meta_query_result !== false
|
||||
) {
|
||||
foreach ($columns_meta_query_result as $column) {
|
||||
$value = $column['Field'];
|
||||
if ($backquoted === true) {
|
||||
$value = Util::backquote($value);
|
||||
}
|
||||
|
||||
if (strpos($column['Extra'], 'GENERATED') === false) {
|
||||
array_push($ret, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return UI preferences for this table from phpMyAdmin database.
|
||||
*
|
||||
|
||||
@ -682,8 +682,13 @@ function PMA_exportDatabase(
|
||||
&& in_array($table, $table_data)
|
||||
&& ! ($is_view)
|
||||
) {
|
||||
$local_query = 'SELECT * FROM ' . PMA\libraries\Util::backquote($db)
|
||||
$tableObj = new PMA\libraries\Table($table, $db);
|
||||
$nonGeneratedCols = $tableObj->getNonGeneratedColumns(true);
|
||||
|
||||
$local_query = 'SELECT ' . implode(', ', $nonGeneratedCols)
|
||||
. ' FROM ' . PMA\libraries\Util::backquote($db)
|
||||
. '.' . PMA\libraries\Util::backquote($table);
|
||||
|
||||
if (! $export_plugin->exportData(
|
||||
$db, $table, $crlf, $err_url, $local_query, $aliases
|
||||
)) {
|
||||
@ -862,7 +867,12 @@ function PMA_exportTable(
|
||||
$local_query = $sql_query . $add_query;
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
} else {
|
||||
$local_query = 'SELECT * FROM ' . PMA\libraries\Util::backquote($db)
|
||||
// Data is exported only for Non-generated columns
|
||||
$tableObj = new PMA\libraries\Table($table, $db);
|
||||
$nonGeneratedCols = $tableObj->getNonGeneratedColumns(true);
|
||||
|
||||
$local_query = 'SELECT ' . implode(', ', $nonGeneratedCols)
|
||||
. ' FROM ' . PMA\libraries\Util::backquote($db)
|
||||
. '.' . PMA\libraries\Util::backquote($table) . $add_query;
|
||||
}
|
||||
if (! $export_plugin->exportData(
|
||||
|
||||
@ -2951,6 +2951,33 @@ function PMA_getUserGroupCount()
|
||||
return $user_group_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns name of user group that user is part of
|
||||
*
|
||||
* @param string $username User name
|
||||
*
|
||||
* @return mixed usergroup if found or null if not found
|
||||
*/
|
||||
function PMA_getUserGroupForUser($username)
|
||||
{
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
$user_table = Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['users']);
|
||||
$sql_query = 'SELECT `usergroup` FROM ' . $user_table
|
||||
. ' WHERE `username` = \'' . $username . '\''
|
||||
. ' LIMIT 1';
|
||||
|
||||
$usergroup = $GLOBALS['dbi']->fetchValue(
|
||||
$sql_query, 0, 0, $GLOBALS['controllink']
|
||||
);
|
||||
|
||||
if ($usergroup === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $usergroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function return the extra data array for the ajax behavior
|
||||
*
|
||||
@ -3129,8 +3156,15 @@ function PMA_getChangeLoginInformationHtmlForm($username, $hostname)
|
||||
. '<input type="hidden" name="old_username" '
|
||||
. 'value="' . htmlspecialchars($username) . '" />' . "\n"
|
||||
. '<input type="hidden" name="old_hostname" '
|
||||
. 'value="' . htmlspecialchars($hostname) . '" />' . "\n"
|
||||
. '<fieldset id="fieldset_change_copy_user">' . "\n"
|
||||
. 'value="' . htmlspecialchars($hostname) . '" />' . "\n";
|
||||
|
||||
$usergroup = PMA_getUserGroupForUser($username);
|
||||
if ($usergroup !== null) {
|
||||
$html_output .= '<input type="hidden" name="old_usergroup" '
|
||||
. 'value="' . htmlspecialchars($usergroup) . '" />' . "\n";
|
||||
}
|
||||
|
||||
$html_output .= '<fieldset id="fieldset_change_copy_user">' . "\n"
|
||||
. '<legend data-submenu-label="' . __('Login Information') . '">' . "\n"
|
||||
. __('Change login information / Copy user account')
|
||||
. '</legend>' . "\n"
|
||||
@ -4292,6 +4326,12 @@ function PMA_addUser(
|
||||
);
|
||||
}
|
||||
|
||||
// Copy the user group while copying a user
|
||||
$old_usergroup =
|
||||
$_REQUEST['old_usergroup'] ? $_REQUEST['old_usergroup'] : null;
|
||||
PMA_setUserGroup($_REQUEST['username'], $old_usergroup);
|
||||
|
||||
|
||||
if (isset($create_user_real)) {
|
||||
$queries[] = $create_user_real;
|
||||
}
|
||||
|
||||
@ -180,6 +180,31 @@ class TableTest extends PMATestCase
|
||||
'ALL'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'SHOW COLUMNS FROM `PMA`.`PMA_BookMark`',
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
0,
|
||||
array(
|
||||
array(
|
||||
'Field'=>'COLUMN_NAME1',
|
||||
'Type'=> 'INT(10)',
|
||||
'Null'=> 'NO',
|
||||
'Key'=> '',
|
||||
'Default'=> NULL,
|
||||
'Extra'=>''
|
||||
),
|
||||
array(
|
||||
'Field'=>'COLUMN_NAME2',
|
||||
'Type'=> 'INT(10)',
|
||||
'Null'=> 'YES',
|
||||
'Key'=> '',
|
||||
'Default'=> NULL,
|
||||
'Extra'=>'STORED GENERATED'
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
@ -1047,7 +1072,8 @@ class TableTest extends PMATestCase
|
||||
$expect,
|
||||
$return
|
||||
);
|
||||
$sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new` SELECT * FROM "
|
||||
$sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new`(`COLUMN_NAME1`)"
|
||||
. " SELECT `COLUMN_NAME1` FROM "
|
||||
. "`PMA`.`PMA_BookMark`";
|
||||
$this->assertContains(
|
||||
$sql_query,
|
||||
@ -1070,8 +1096,9 @@ class TableTest extends PMATestCase
|
||||
$expect,
|
||||
$return
|
||||
);
|
||||
$sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new` SELECT * FROM "
|
||||
. "`PMA`.`PMA_BookMark`;";
|
||||
$sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new`(`COLUMN_NAME1`)"
|
||||
. " SELECT `COLUMN_NAME1` FROM "
|
||||
. "`PMA`.`PMA_BookMark`";
|
||||
$this->assertContains(
|
||||
$sql_query,
|
||||
$GLOBALS['sql_query']
|
||||
|
||||
@ -1638,6 +1638,7 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$username = "pma_username";
|
||||
$hostname = "pma_hostname";
|
||||
$GLOBALS['cfgRelation']['menuswork'] = true;
|
||||
|
||||
$dbi_old = $GLOBALS['dbi'];
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
@ -1650,6 +1651,11 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase
|
||||
$dbi->expects($this->any())->method('fetchResult')
|
||||
->will($this->returnValue($fields_info));
|
||||
|
||||
$expected_userGroup = "pma_usergroup";
|
||||
|
||||
$dbi->expects($this->any())->method('fetchValue')
|
||||
->will($this->returnValue($expected_userGroup));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
//PMA_getChangeLoginInformationHtmlForm
|
||||
@ -1677,6 +1683,12 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase
|
||||
$html
|
||||
);
|
||||
|
||||
$this->assertContains(
|
||||
'<input type="hidden" name="old_usergroup" value="'
|
||||
. $expected_userGroup . '" />',
|
||||
$html
|
||||
);
|
||||
|
||||
//Create a new user with the same privileges
|
||||
$this->assertContains(
|
||||
"Create a new user account with the same privileges",
|
||||
@ -1686,6 +1698,38 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase
|
||||
$GLOBALS['dbi'] = $dbi_old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getUserGroupForUser
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMAGetUserGroupForUser()
|
||||
{
|
||||
$username = "pma_username";
|
||||
$hostname = "pma_hostname";
|
||||
$GLOBALS['cfgRelation']['menuswork'] = true;
|
||||
|
||||
$dbi_old = $GLOBALS['dbi'];
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$expected_userGroup = "pma_usergroup";
|
||||
|
||||
$dbi->expects($this->any())->method('fetchValue')
|
||||
->will($this->returnValue($expected_userGroup));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
$returned_userGroup = PMA_getUserGroupForUser($username);
|
||||
|
||||
$this->assertEquals(
|
||||
$expected_userGroup,
|
||||
$returned_userGroup
|
||||
);
|
||||
|
||||
$GLOBALS['dbi'] = $dbi_old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getLinkToDbAndTable
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user