Merge remote-tracking branch 'origin/QA_4_7' into QA_4_7

This commit is contained in:
Weblate 2017-03-13 09:19:01 +01:00
commit a31c41dbcd
3 changed files with 70 additions and 32 deletions

View File

@ -97,6 +97,7 @@ phpMyAdmin - ChangeLog
- issue #12846 Fix new version check for sites with wrongly configured curl
- issue #12951 When exporting to Excel, the default is now to include column names in the first row
- issue #13059 Removed debugging code
- issue #13029 Fixed table tracking for nested table groups
4.6.6 (2017-01-23)
- issue #12759 Fix Notice regarding 'Undefined index: old_usergroup'

View File

@ -1523,6 +1523,33 @@ function PMA_displayOneUntrackedTable($db, $tablename, $url_query)
}
}
/**
* Helper function: Recursive function for getting table names from $table_list
*
* @param string $db current database
*
* @return array $untracked_tables
*/
function PMA_extractTableNames($table_list, $db, $testing=false) {
$untracked_tables = array();
$sep = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
foreach ($table_list as $key => $value) {
if (is_array($value) && array_key_exists(('is' . $sep . 'group'), $value)
&& $value['is' . $sep . 'group']
) {
$untracked_tables = array_merge(PMA_extractTableNames($value, $db), $untracked_tables); //Recursion step
}
else {
if (is_array($value) && ($testing || Tracker::getVersion($db, $value['Name']) == -1)) {
$untracked_tables[] = $value['Name'];
}
}
}
return $untracked_tables;
}
/**
* Get untracked tables
*
@ -1532,39 +1559,8 @@ function PMA_displayOneUntrackedTable($db, $tablename, $url_query)
*/
function PMA_getUntrackedTables($db)
{
$untracked_tables = array();
$sep = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
// Get list of tables
$table_list = PMA\libraries\Util::getTableList($db);
// For each table try to get the tracking version
foreach ($table_list as $key => $value) {
// If $value is a table group.
if (array_key_exists(('is' . $sep . 'group'), $value)
&& $value['is' . $sep . 'group']
) {
foreach ($value as $temp_table) {
// If $temp_table is a table with the value for 'Name' is set,
// rather than a property of the table group.
if (is_array($temp_table)
&& array_key_exists('Name', $temp_table)
) {
$tracking_version = Tracker::getVersion(
$db,
$temp_table['Name']
);
if ($tracking_version == -1) {
$untracked_tables[] = $temp_table['Name'];
}
}
}
} else { // If $value is a table.
if (Tracker::getVersion($db, $value['Name']) == -1) {
$untracked_tables[] = $value['Name'];
}
}
}
$untracked_tables = PMA_extractTableNames($table_list, $db); //Use helper function to get table list recursively.
return $untracked_tables;
}

View File

@ -47,6 +47,7 @@ class PMA_TblTrackingTest extends PHPUnit_Framework_TestCase
$GLOBALS['cfg']['ServerDefault'] = "server";
$GLOBALS['cfg']['ActionLinksMode'] = 'both';
$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000;
$GLOBALS['cfg']['NavigationTreeTableSeparator'] = "_";
$_SESSION['relation'][$GLOBALS['server']] = array(
'PMA_VERSION' => PMA_VERSION,
@ -113,6 +114,46 @@ class PMA_TblTrackingTest extends PHPUnit_Framework_TestCase
);
}
/**
* Tests for PMA_extractTableNames() method from nested table_list.
*
* @return void
* @test
*/
public function testPMAextractTableNames()
{
$table_list = array(
"hello_"=>array(
"is_group"=>1,
"lovely_"=>array(
"is_group"=>1,
"hello_lovely_world"=>array(
"Name"=>"hello_lovely_world"
),
"hello_lovely_world2"=>array(
"Name"=>"hello_lovely_world2"
)
),
"hello_world"=>array(
"Name"=>"hello_world"
)
)
);
$untracked_tables = PMA_extractTableNames($table_list, 'db', true);
$this->assertContains(
"hello_world",
$untracked_tables
);
$this->assertContains(
"hello_lovely_world",
$untracked_tables
);
$this->assertContains(
"hello_lovely_world2",
$untracked_tables
);
}
/**
* Tests for PMA_getHtmlForDataDefinitionAndManipulationStatements() method.
*