Merge pull request #15260 from Tithugues/feature/cleaning

Feature/cleaning
This commit is contained in:
Maurício Meneghini Fauth 2019-05-14 23:26:02 -03:00 committed by GitHub
commit 3b1e868fb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 37 additions and 106 deletions

View File

@ -557,7 +557,7 @@ class Validator
* @param array $values config values
* @param string $regex regular expression to match
*
* @return array
* @return array|string
*/
public static function validateByRegex($path, array $values, $regex)
{

View File

@ -477,8 +477,6 @@ class SearchController extends AbstractController
/**
* Add this to ensure following procedures included running correctly.
*/
$db = $this->db;
$sql = new Sql();
$sql->executeQueryAndSendQueryResponse(
null, // analyzed_sql_results
@ -696,7 +694,7 @@ class SearchController extends AbstractController
* @param string $replaceWith string to replace with
* @param string $charSet character set of the connection
*
* @return array Array containing original values, replaced values and count
* @return array|bool Array containing original values, replaced values and count
*/
private function _getRegexReplaceRows(
$columnIndex,

View File

@ -114,7 +114,6 @@ class MultiTableQuery
list(
$analyzedSqlResults,
$db,
$tableFromSql
) = ParseAnalyze::sqlQuery($sqlQuery, $db);
extract($analyzedSqlResults);

View File

@ -2162,7 +2162,7 @@ class DatabaseInterface
* @param string $table table name
* @param string $delimiter the delimiter to use (may be empty)
*
* @return mixed information about triggers (may be empty)
* @return array information about triggers (may be empty)
*/
public function getTriggers(string $db, string $table = '', $delimiter = '//')
{

View File

@ -135,7 +135,7 @@ class DbiDummy implements DbiExtension
*
* @param object $result MySQL result
*
* @return array
* @return array|bool
*/
public function fetchAny($result)
{

View File

@ -1691,8 +1691,7 @@ class Results
$sort_tbl,
$name_to_use_in_sort,
$sort_direction,
$fields_meta,
$column_index
$fields_meta
);
if (preg_match(
@ -1760,7 +1759,6 @@ class Results
* consideration
* @param array $sort_direction sort direction
* @param stdClass $fields_meta set of field properties
* @param integer $column_index The index number to current column
*
* @return array 3 element array - $single_sort_order, $sort_order, $order_img
*
@ -1774,8 +1772,7 @@ class Results
$sort_tbl,
$name_to_use_in_sort,
array $sort_direction,
$fields_meta,
$column_index
$fields_meta
) {
$sort_order = "";
// Check if the current column is in the order by clause
@ -1877,8 +1874,6 @@ class Results
}
// Separate columns by a comma
$sort_order .= ", ";
unset($name_to_use_in_sort);
}
// remove the comma from the last column name in the newly
// constructed clause

View File

@ -506,7 +506,7 @@ class GisPolygon extends GisGeometry
*
* @param array $ring array of points forming the ring
*
* @return array|void a point on the surface of the ring
* @return array|bool a point on the surface of the ring
* @access public
* @static
*/

View File

@ -134,7 +134,6 @@ class Header
$db = strlen($GLOBALS['db']) ? $GLOBALS['db'] : '';
$table = strlen($GLOBALS['table']) ? $GLOBALS['table'] : '';
$this->_menu = new Menu(
$GLOBALS['server'],
$db,
$table
);
@ -202,14 +201,6 @@ class Header
// the user preferences have not been merged at this point
$this->_scripts->addFile('messages.php', ['l' => $GLOBALS['lang']]);
// Append the theme id to this url to invalidate
// the cache on a theme change. Though this might be
// unavailable for fatal errors.
if (isset($GLOBALS['PMA_Theme'])) {
$theme_id = urlencode($GLOBALS['PMA_Theme']->getId());
} else {
$theme_id = 'default';
}
$this->_scripts->addFile('config.js');
$this->_scripts->addFile('doclinks.js');
$this->_scripts->addFile('functions.js');

View File

@ -95,8 +95,7 @@ class Import
*/
public function executeQuery(string $sql, string $full, array &$sql_data): void
{
global $go_sql,
$sql_query, $my_die, $error, $reload,
global $sql_query, $my_die, $error, $reload,
$result, $msg,
$cfg, $sql_query_disabled, $db;
@ -365,7 +364,7 @@ class Import
*/
public function getNextChunk(int $size = 32768)
{
global $compression, $import_handle, $charset_conversion, $charset_of_file,
global $import_handle, $charset_conversion, $charset_of_file,
$read_multiply;
// Add some progression while reading large amount of data
@ -1330,8 +1329,6 @@ class Import
global $import_notice;
$import_notice = $message;
unset($tables);
}

View File

@ -2310,7 +2310,6 @@ class InsertEdit
. ' (' . implode(', ', $query_fields) . ') VALUES ('
. implode('), (', $value_sets) . ')'
];
unset($insert_command, $query_fields);
return $query;
}
@ -2571,7 +2570,7 @@ class InsertEdit
* @param array $func_no_param array of set of string
* @param string $key an md5 of the column name
*
* @return array
* @return string
*/
public function getCurrentValueAsAnArrayForMultipleEdit(
$multi_edit_funcs,
@ -3519,19 +3518,4 @@ class InsertEdit
return $html_output;
}
/**
* Returns whether the user has necessary insert/update privileges for the column
*
* @param array $table_column array of column details
* @param bool $insert_mode whether on insert mode
*
* @return boolean whether user has necessary privileges
*/
private function userHasColumnPrivileges(array $table_column, $insert_mode)
{
$privileges = $table_column['Privileges'];
return ($insert_mode && false !== strpos($privileges, 'insert'))
|| (! $insert_mode && false !== strpos($privileges, 'update'));
}
}

View File

@ -16,13 +16,6 @@ namespace PhpMyAdmin;
*/
class Menu
{
/**
* Server id
*
* @access private
* @var int
*/
private $_server;
/**
* Database name
*
@ -46,13 +39,11 @@ class Menu
/**
* Creates a new instance of Menu
*
* @param int $server Server id
* @param string $db Database name
* @param string $table Table name
* @param string $db Database name
* @param string $table Table name
*/
public function __construct($server, $db, $table)
public function __construct($db, $table)
{
$this->_server = $server;
$this->_db = $db;
$this->_table = $table;
$this->relation = new Relation($GLOBALS['dbi']);

View File

@ -234,7 +234,7 @@ class Normalization
* @param string $db current database
* @param string $table current table
*
* @return string HTML contents for step 1.2
* @return string[] HTML contents for step 1.2
*/
public function getHtmlContentsFor1NFStep2($db, $table)
{
@ -284,7 +284,7 @@ class Normalization
* @param string $db current database
* @param string $table current table
*
* @return string HTML contents for step 1.4
* @return string[] HTML contents for step 1.4
*/
public function getHtmlContentsFor1NFStep4($db, $table)
{
@ -320,7 +320,7 @@ class Normalization
* @param string $db current database
* @param string $table current table
*
* @return string HTML contents for step 1.3
* @return string[] HTML contents for step 1.3
*/
public function getHtmlContentsFor1NFStep3($db, $table)
{
@ -365,7 +365,7 @@ class Normalization
* @param string $db current database
* @param string $table current table
*
* @return string HTML contents for 2NF step 2.1
* @return string[] HTML contents for 2NF step 2.1
*/
public function getHtmlFor2NFstep1($db, $table)
{
@ -798,7 +798,7 @@ class Normalization
* @param string $db current database
* @param array $tables tables formed after 2NF and need to process for 3NF
*
* @return string
* @return string[]
*/
public function getHtmlFor3NFstep1($db, array $tables)
{

View File

@ -931,7 +931,7 @@ class Operations
*
* @param Table $pma_table Table object
* @param string $comment Comment
* @param array $tbl_collation table collation
* @param string $tbl_collation table collation
* @param string $tbl_storage_engine table storage engine
* @param string $pack_keys pack keys
* @param string $auto_increment value of auto increment
@ -1083,7 +1083,7 @@ class Operations
*
* @param Table $pma_table Table object
* @param string $comment Comment
* @param array $tbl_collation table collation
* @param string $tbl_collation table collation
* @param string $tbl_storage_engine table storage engine
* @param string $pack_keys pack keys
* @param string $delay_key_write delay key write

View File

@ -351,13 +351,8 @@ class Pdf extends PdfLib
*/
public function getTriggers($db, $table)
{
$i = 0;
$triggers = $GLOBALS['dbi']->getTriggers($db, $table);
foreach ($triggers as $trigger) {
$i++;
break;
}
if ($i == 0) {
if ([] === $triggers) {
return; //prevents printing blank trigger list for any table
}
@ -407,8 +402,6 @@ class Pdf extends PdfLib
$maxpage = $this->page;
$data = [];
$triggers = $GLOBALS['dbi']->getTriggers($db, $table);
foreach ($triggers as $trigger) {
$data[] = $trigger['name'];
$data[] = $trigger['action_timing'];

View File

@ -402,9 +402,6 @@ class ImportMediawiki extends ImportPlugin
// Create and execute necessary SQL statements from data
$this->import->buildSql($db_name, $tables, $analyses, $create, $options, $sql_data);
unset($tables);
unset($analyses);
}
/**

View File

@ -21,7 +21,7 @@ class OptionsPropertySubgroup extends OptionsPropertyGroup
/**
* Subgroup Header
*
* @var string
* @var \PhpMyAdmin\Properties\PropertyItem
*/
private $_subgroupHeader;
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */

View File

@ -1141,7 +1141,7 @@ class Relation
*
* @param string $username the username
*
* @return array list of history items
* @return array|bool list of history items
*
* @access public
*/

View File

@ -344,7 +344,7 @@ class Events
*
* @param string $name The name of the event.
*
* @return array Data necessary to create the editor.
* @return array|bool Data necessary to create the editor.
*/
public function getDataFromName($name)
{

View File

@ -642,7 +642,7 @@ class Routines
* @param string $type Type of routine (ROUTINE|PROCEDURE)
* @param bool $all Whether to return all data or just the info about parameters.
*
* @return array Data necessary to create the routine editor.
* @return array|bool Data necessary to create the routine editor.
*/
public function getDataFromName($name, $type, $all = true)
{

View File

@ -311,7 +311,7 @@ class Triggers
*
* @param string $name The name of the trigger.
*
* @return array Data necessary to create the editor.
* @return array|bool Data necessary to create the editor.
*/
public function getDataFromName($name)
{

View File

@ -418,12 +418,12 @@ class Sanitize
/**
* Removes all variables from request except whitelisted ones.
*
* @param string $whitelist list of variables to allow
* @param string[] $whitelist list of variables to allow
*
* @return void
* @access public
*/
public static function removeRequestVars(&$whitelist)
public static function removeRequestVars(&$whitelist): void
{
// do not check only $_REQUEST because it could have been overwritten
// and use type casting because the variables could have become

View File

@ -1618,7 +1618,6 @@ class Sql
}
$GLOBALS['dbi']->freeResult($result);
unset($result);
} while ($GLOBALS['dbi']->moreResults() && $GLOBALS['dbi']->nextResult());
} else {
$fields_meta = [];

View File

@ -89,9 +89,9 @@ class Template
* @param string $templateName Template path name
*
* @return \Twig_TemplateWrapper
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
*/
public function load(string $templateName): \Twig_TemplateWrapper
{

View File

@ -258,7 +258,7 @@ class Transformations
*
* @access public
*
* @return array [field_name][field_key] = field_value
* @return array|bool [field_name][field_key] = field_value
*/
public function getMime($db, $table, $strict = false, $fullName = false)
{
@ -300,8 +300,6 @@ class Transformations
foreach ($result as $column => $values) {
// convert mimetype to new format (f.e. Text_Plain, etc)
$delimiter_space = '- ';
$delimiter = "_";
$values['mimetype'] = $this->fixUpMime($values['mimetype']);
// For transformation of form

View File

@ -40,10 +40,6 @@ class Url
) {
if (is_array($db)) {
$params =& $db;
$_indent = empty($table) ? $indent : $table;
$_skip = empty($indent) ? $skip : $indent;
$indent =& $_indent;
$skip =& $_skip;
} else {
$params = [];
if (strlen((string) $db) > 0) {

View File

@ -121,13 +121,6 @@ class Util
{
$alternate = htmlspecialchars($alternate);
// Set $url accordingly
if (isset($GLOBALS['pmaThemeImage'])) {
$url = $GLOBALS['pmaThemeImage'] . $image;
} else {
$url = './themes/pmahomme/' . $image;
}
if (isset($attributes['class'])) {
$attributes['class'] = "icon ic_$image " . $attributes['class'];
} else {

View File

@ -47,7 +47,7 @@ class MenuTest extends PmaTestCase
*/
public function testServer()
{
$menu = new Menu('server', '', '');
$menu = new Menu('', '');
$this->assertStringContainsString(
'floating_menubar',
$menu->getDisplay()
@ -61,7 +61,7 @@ class MenuTest extends PmaTestCase
*/
public function testDatabase()
{
$menu = new Menu('server', 'pma_test', '');
$menu = new Menu('pma_test', '');
$this->assertStringContainsString(
'floating_menubar',
$menu->getDisplay()
@ -75,7 +75,7 @@ class MenuTest extends PmaTestCase
*/
public function testTable()
{
$menu = new Menu('server', 'pma_test', 'table1');
$menu = new Menu('pma_test', 'table1');
$this->assertStringContainsString(
'floating_menubar',
$menu->getDisplay()
@ -89,7 +89,7 @@ class MenuTest extends PmaTestCase
*/
public function testTableDisplay()
{
$menu = new Menu('server', 'pma_test', '');
$menu = new Menu('pma_test', '');
$this->expectOutputString(
$menu->getDisplay()
);
@ -104,7 +104,7 @@ class MenuTest extends PmaTestCase
*/
public function testSetTable()
{
$menu = new Menu('server', 'pma_test', '');
$menu = new Menu('pma_test', '');
$menu->setTable('table1');
$this->assertStringContainsString(
'table1',