diff options
author | MaurĂcio Meneghini Fauth <mauriciofauth@gmail.com> | 2018-11-26 21:30:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-26 21:30:30 +0300 |
commit | 416bf940736efa918241c31554d14a4bcd9bf1ed (patch) | |
tree | 80b04b4e99fdd340251185565ea080fca64c01e7 | |
parent | a7279c10f84955fd97b05e5d3f171e0da5ab9acb (diff) | |
parent | 38301a6a9f818262747f104d8ca44420d71827ce (diff) |
Merge pull request #14741 from TomasVotruba/clean-code
[cs] remove unused brackets, clean unused property assign, remove unused imports + sort them
40 files changed, 194 insertions, 400 deletions
diff --git a/libraries/classes/BrowseForeigners.php b/libraries/classes/BrowseForeigners.php index c2ffd444bd..b38115e70a 100644 --- a/libraries/classes/BrowseForeigners.php +++ b/libraries/classes/BrowseForeigners.php @@ -9,10 +9,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Template; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; - /** * PhpMyAdmin\BrowseForeigners class * diff --git a/libraries/classes/CentralColumns.php b/libraries/classes/CentralColumns.php index e4f38273fa..ba2f9ddac9 100644 --- a/libraries/classes/CentralColumns.php +++ b/libraries/classes/CentralColumns.php @@ -9,14 +9,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Charsets; -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Message; -use PhpMyAdmin\Relation; -use PhpMyAdmin\Template; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; - /** * PhpMyAdmin\CentralColumns class * @@ -279,12 +271,12 @@ class CentralColumns } if (isset($def['Attribute'])) { $attribute = $def['Attribute']; - }; + } $collation = isset($def['Collation']) ? $def['Collation'] : ""; - $isNull = ($def['Null'] == "NO") ? '0' : '1'; + $isNull = $def['Null'] == "NO" ? '0' : '1'; $extra = isset($def['Extra']) ? $def['Extra'] : ""; $default = isset($def['Default']) ? $def['Default'] : ""; - $insQuery = 'INSERT INTO ' + return 'INSERT INTO ' . Util::backquote($central_list_table) . ' ' . 'VALUES ( \'' . $this->dbi->escapeString($db) . '\' ,' . '\'' . $this->dbi->escapeString($column) . '\',\'' @@ -294,7 +286,6 @@ class CentralColumns . '\'' . $this->dbi->escapeString($isNull) . '\',' . '\'' . implode(',', [$extra, $attribute]) . '\',\'' . $this->dbi->escapeString($default) . '\');'; - return $insQuery; } /** @@ -962,11 +953,10 @@ class CentralColumns */ private function getEditTableFooter(): string { - $html_output = '<fieldset class="tblFooters">' + return '<fieldset class="tblFooters">' . '<input type="submit" ' . 'name="save_multi_central_column_edit" value="' . __('Save') . '" />' . '</fieldset>'; - return $html_output; } /** @@ -1129,12 +1119,12 @@ class CentralColumns $tn_pageNow = ($pos / $this->maxRows) + 1; $tn_nbTotalPage = ceil($total_rows / $this->maxRows); - $tn_page_selector = ($tn_nbTotalPage > 1) ? (Util::pageselector( + $tn_page_selector = $tn_nbTotalPage > 1 ? Util::pageselector( 'pos', $this->maxRows, $tn_pageNow, $tn_nbTotalPage - )) : ''; + ) : ''; $this->dbi->selectDb($db); $tables = $this->dbi->getTables($db); $rows_list = $this->getColumnsList($db, $pos, $max_rows); diff --git a/libraries/classes/Config/FormDisplay.php b/libraries/classes/Config/FormDisplay.php index 1161ba2586..8ec444ca84 100644 --- a/libraries/classes/Config/FormDisplay.php +++ b/libraries/classes/Config/FormDisplay.php @@ -16,12 +16,7 @@ declare(strict_types=1); namespace PhpMyAdmin\Config; -use PhpMyAdmin\Config\ConfigFile; -use PhpMyAdmin\Config\Descriptions; -use PhpMyAdmin\Config\Form; -use PhpMyAdmin\Config\FormDisplayTemplate; use PhpMyAdmin\Config\Forms\User\UserFormList; -use PhpMyAdmin\Config\Validator; use PhpMyAdmin\Sanitize; use PhpMyAdmin\Util; diff --git a/libraries/classes/Controllers/Database/DatabaseStructureController.php b/libraries/classes/Controllers/Database/DatabaseStructureController.php index 6c2bcba050..49e09ba3a2 100644 --- a/libraries/classes/Controllers/Database/DatabaseStructureController.php +++ b/libraries/classes/Controllers/Database/DatabaseStructureController.php @@ -23,8 +23,8 @@ use PhpMyAdmin\Response; use PhpMyAdmin\Sanitize; use PhpMyAdmin\Template; use PhpMyAdmin\Tracker; -use PhpMyAdmin\Util; use PhpMyAdmin\Url; +use PhpMyAdmin\Util; /** * Handles database structure logic @@ -520,8 +520,8 @@ class DatabaseStructureController extends DatabaseController } } - $truename = (!empty($tooltip_truename) - && isset($tooltip_truename[$current_table['TABLE_NAME']])) + $truename = !empty($tooltip_truename) + && isset($tooltip_truename[$current_table['TABLE_NAME']]) ? $tooltip_truename[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']; @@ -549,14 +549,14 @@ class DatabaseStructureController extends DatabaseController if (!$this->_db_is_system_schema) { $drop_query = sprintf( 'DROP %s %s', - ($table_is_view || $current_table['ENGINE'] == null) ? 'VIEW' + $table_is_view || $current_table['ENGINE'] == null ? 'VIEW' : 'TABLE', Util::backquote( $current_table['TABLE_NAME'] ) ); $drop_message = sprintf( - (($table_is_view || $current_table['ENGINE'] == null) + ($table_is_view || $current_table['ENGINE'] == null ? __('View %s has been dropped.') : __('Table %s has been dropped.')), str_replace( @@ -1056,7 +1056,7 @@ class DatabaseStructureController extends DatabaseController list($formatted_size, $unit) = Util::formatByteDown( $tblsize, 3, - ($tblsize > 0) ? 1 : 0 + $tblsize > 0 ? 1 : 0 ); if (isset($current_table['Data_free']) && $current_table['Data_free'] > 0 @@ -1065,7 +1065,7 @@ class DatabaseStructureController extends DatabaseController = Util::formatByteDown( $current_table['Data_free'], 3, - (($current_table['Data_free'] > 0) ? 1 : 0) + ($current_table['Data_free'] > 0 ? 1 : 0) ); $overhead_size += $current_table['Data_free']; } @@ -1108,7 +1108,7 @@ class DatabaseStructureController extends DatabaseController list($formatted_size, $unit) = Util::formatByteDown( $tblsize, 3, - (($tblsize > 0) ? 1 : 0) + ($tblsize > 0 ? 1 : 0) ); } diff --git a/libraries/classes/Controllers/Server/ServerDatabasesController.php b/libraries/classes/Controllers/Server/ServerDatabasesController.php index f5c22bcc31..62aa2d9717 100644 --- a/libraries/classes/Controllers/Server/ServerDatabasesController.php +++ b/libraries/classes/Controllers/Server/ServerDatabasesController.php @@ -10,13 +10,11 @@ declare(strict_types=1); namespace PhpMyAdmin\Controllers\Server; -use PhpMyAdmin\Controllers\Controller; use PhpMyAdmin\Charsets; +use PhpMyAdmin\Controllers\Controller; use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\Message; use PhpMyAdmin\Response; -use PhpMyAdmin\Server\Common; -use PhpMyAdmin\Template; use PhpMyAdmin\Url; use PhpMyAdmin\Util; diff --git a/libraries/classes/Controllers/Table/TableChartController.php b/libraries/classes/Controllers/Table/TableChartController.php index f063c2e007..e3bea24f7b 100644 --- a/libraries/classes/Controllers/Table/TableChartController.php +++ b/libraries/classes/Controllers/Table/TableChartController.php @@ -16,7 +16,6 @@ use PhpMyAdmin\SqlParser\Components\Limit; use PhpMyAdmin\SqlParser\Statements\SelectStatement; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\Table; -use PhpMyAdmin\Template; use PhpMyAdmin\Util; /** diff --git a/libraries/classes/Controllers/Table/TableGisVisualizationController.php b/libraries/classes/Controllers/Table/TableGisVisualizationController.php index 5110ccdf69..3221ec0d18 100644 --- a/libraries/classes/Controllers/Table/TableGisVisualizationController.php +++ b/libraries/classes/Controllers/Table/TableGisVisualizationController.php @@ -13,7 +13,6 @@ use PhpMyAdmin\Controllers\TableController; use PhpMyAdmin\Core; use PhpMyAdmin\Gis\GisVisualization; use PhpMyAdmin\Message; -use PhpMyAdmin\Template; use PhpMyAdmin\Url; /** diff --git a/libraries/classes/Controllers/Table/TableIndexesController.php b/libraries/classes/Controllers/Table/TableIndexesController.php index e20932826b..9552943f34 100644 --- a/libraries/classes/Controllers/Table/TableIndexesController.php +++ b/libraries/classes/Controllers/Table/TableIndexesController.php @@ -13,7 +13,6 @@ use PhpMyAdmin\Controllers\TableController; use PhpMyAdmin\Index; use PhpMyAdmin\Message; use PhpMyAdmin\Response; -use PhpMyAdmin\Template; use PhpMyAdmin\Util; /** @@ -90,7 +89,7 @@ class TableIndexesController extends TableController if (isset($_REQUEST['create_edit_table'])) { $fields = json_decode($_REQUEST['columns'], true); $index_params = [ - 'Non_unique' => ($_REQUEST['index']['Index_choice'] == 'UNIQUE') + 'Non_unique' => $_REQUEST['index']['Index_choice'] == 'UNIQUE' ? '0' : '1', ]; $this->index->set($index_params); diff --git a/libraries/classes/Controllers/Table/TableRelationController.php b/libraries/classes/Controllers/Table/TableRelationController.php index facd2a22bf..2982f91f95 100644 --- a/libraries/classes/Controllers/Table/TableRelationController.php +++ b/libraries/classes/Controllers/Table/TableRelationController.php @@ -15,7 +15,6 @@ use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\Index; use PhpMyAdmin\Relation; use PhpMyAdmin\Table; -use PhpMyAdmin\Template; use PhpMyAdmin\Util; /** diff --git a/libraries/classes/Controllers/Table/TableSearchController.php b/libraries/classes/Controllers/Table/TableSearchController.php index 2f6eae6767..a0ef7bd31d 100644 --- a/libraries/classes/Controllers/Table/TableSearchController.php +++ b/libraries/classes/Controllers/Table/TableSearchController.php @@ -13,7 +13,6 @@ use PhpMyAdmin\Controllers\TableController; use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\Relation; use PhpMyAdmin\Sql; -use PhpMyAdmin\Template; use PhpMyAdmin\Util; /** @@ -364,7 +363,7 @@ class TableSearchController extends TableController $row[$_POST['criteriaColumnNames'][1]], 'where_clause' => $uniqueCondition[0] ]; - $tmpData[$dataLabel] = ($dataLabel) ? $row[$dataLabel] : ''; + $tmpData[$dataLabel] = $dataLabel ? $row[$dataLabel] : ''; $data[] = $tmpData; } unset($tmpData); @@ -418,7 +417,7 @@ class TableSearchController extends TableController } $key = array_search($field, $this->_columnNames); $search_index - = ((isset($_REQUEST['it']) && is_numeric($_REQUEST['it'])) + = (isset($_REQUEST['it']) && is_numeric($_REQUEST['it']) ? intval($_REQUEST['it']) : 0); $properties = $this->getColumnProperties($search_index, $key); @@ -571,7 +570,7 @@ class TableSearchController extends TableController 'criteria_column_types' => isset($_POST['criteriaColumnTypes']) ? $_POST['criteriaColumnTypes'] : null, 'sql_types' => $this->dbi->types, 'max_rows' => intval($GLOBALS['cfg']['MaxRows']), - 'max_plot_limit' => ((! empty($_POST['maxPlotLimit'])) + 'max_plot_limit' => (! empty($_POST['maxPlotLimit']) ? intval($_POST['maxPlotLimit']) : intval($GLOBALS['cfg']['maxRowPlotLimit'])), ]) @@ -825,9 +824,7 @@ class TableSearchController extends TableController . 'FROM ' . Util::backquote($this->db) . '.' . Util::backquote($this->table); - $result = $this->dbi->fetchSingleRow($sql_query); - - return $result; + return $this->dbi->fetchSingleRow($sql_query); } /** @@ -869,7 +866,7 @@ class TableSearchController extends TableController $sql_query = 'SELECT '; // If only distinct values are needed - $is_distinct = (isset($_POST['distinct'])) ? 'true' : 'false'; + $is_distinct = isset($_POST['distinct']) ? 'true' : 'false'; if ($is_distinct == 'true') { $sql_query .= 'DISTINCT '; } @@ -1084,14 +1081,12 @@ class TableSearchController extends TableController // If the function takes multiple parameters if (strpos($func_type, "IS NULL") !== false || strpos($func_type, "IS NOT NULL") !== false) { - $where = Util::backquote($names) . " " . $func_type; - return $where; + return Util::backquote($names) . " " . $func_type; } elseif ($geom_funcs[$geom_func]['params'] > 1) { // create gis data from the criteria input $gis_data = Util::createGISData($criteriaValues); - $where = $geom_func . '(' . Util::backquote($names) + return $geom_func . '(' . Util::backquote($names) . ', ' . $gis_data . ')'; - return $where; } // New output type is the output type of the function being applied diff --git a/libraries/classes/Core.php b/libraries/classes/Core.php index 6fac03c3bd..2ab8144f4c 100644 --- a/libraries/classes/Core.php +++ b/libraries/classes/Core.php @@ -11,14 +11,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Message; -use PhpMyAdmin\Response; -use PhpMyAdmin\Sanitize; -use PhpMyAdmin\Template; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; - /** * Core class * @@ -253,9 +245,7 @@ class Core public static function securePath(string $path): string { // change .. to . - $path = preg_replace('@\.\.*@', '.', $path); - - return $path; + return preg_replace('@\.\.*@', '.', $path); } // end function /** @@ -833,9 +823,7 @@ class Core { $buffer = htmlspecialchars($buffer); $buffer = str_replace(' ', ' ', $buffer); - $buffer = preg_replace("@((\015\012)|(\015)|(\012))@", '<br />' . "\n", $buffer); - - return $buffer; + return preg_replace("@((\015\012)|(\015)|(\012))@", '<br />' . "\n", $buffer); } /** diff --git a/libraries/classes/CreateAddField.php b/libraries/classes/CreateAddField.php index 1ec0b31977..86a7baf96d 100644 --- a/libraries/classes/CreateAddField.php +++ b/libraries/classes/CreateAddField.php @@ -9,12 +9,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Core; -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Index; -use PhpMyAdmin\Table; -use PhpMyAdmin\Util; - /** * Set of functions for tbl_create.php and tbl_addfield.php * @@ -348,9 +342,7 @@ class CreateAddField if (count($definitions)) { $sqlStatement = implode(', ', $definitions); } - $sqlStatement = preg_replace('@, $@', '', $sqlStatement); - - return $sqlStatement; + return preg_replace('@, $@', '', $sqlStatement); } /** @@ -545,7 +537,7 @@ class CreateAddField // To allow replication, we first select the db to use and then run queries // on this db. - if (!($this->dbi->selectDb($db))) { + if (!$this->dbi->selectDb($db)) { Util::mysqlDie( $this->dbi->getError(), 'USE ' . Util::backquote($db), diff --git a/libraries/classes/Database/Designer/Common.php b/libraries/classes/Database/Designer/Common.php index 326b4ed03d..224110f4e1 100644 --- a/libraries/classes/Database/Designer/Common.php +++ b/libraries/classes/Database/Designer/Common.php @@ -301,14 +301,13 @@ class Common . "." . Util::backquote($cfgRelation['table_coords']) . " WHERE pdf_page_number = " . intval($pg); - $tab_pos = $this->dbi->fetchResult( + return $this->dbi->fetchResult( $query, 'name', null, DatabaseInterface::CONNECT_CONTROL, DatabaseInterface::QUERY_STORE ); - return $tab_pos; } /** @@ -463,12 +462,11 @@ class Common { $cfgRelation = $this->relation->getRelationsParam(); if ($cfgRelation['pdfwork']) { - $pageNumber = $this->relation->createPage( + return $this->relation->createPage( $pageName, $cfgRelation, $db ); - return $pageNumber; } return null; } diff --git a/libraries/classes/Database/Qbe.php b/libraries/classes/Database/Qbe.php index 36d36f076c..1b0b5006d5 100644 --- a/libraries/classes/Database/Qbe.php +++ b/libraries/classes/Database/Qbe.php @@ -13,7 +13,6 @@ use PhpMyAdmin\Core; use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\Message; use PhpMyAdmin\Relation; -use PhpMyAdmin\SavedSearches; use PhpMyAdmin\Table; use PhpMyAdmin\Template; use PhpMyAdmin\Url; @@ -825,12 +824,12 @@ class Qbe $numTableListOptions = 0; foreach ($this->_criteriaTables as $key => $val) { $options .= '<option value="' . htmlspecialchars($key) . '"' . $val . '>' - . (str_replace(' ', ' ', htmlspecialchars($key))) . '</option>'; + . str_replace(' ', ' ', htmlspecialchars($key)) . '</option>'; $numTableListOptions++; } $html_output .= '<select name="TableList[]"' . ' multiple="multiple" id="listTable"' - . ' size="' . (($numTableListOptions > 30) ? '15' : '7') . '">'; + . ' size="' . ($numTableListOptions > 30 ? '15' : '7') . '">'; $html_output .= $options; $html_output .= '</select>'; $html_output .= '</fieldset>'; @@ -1394,8 +1393,7 @@ class Qbe if (count($where_clause_tables) == 1) { // If there is exactly one column that has a decent where-clause // we will just use this - $master = key($where_clause_tables); - return $master; + return key($where_clause_tables); } // Now let's find out which of the tables has an index @@ -1840,7 +1838,7 @@ class Qbe $html_output .= '</legend>'; $text_dir = 'ltr'; $html_output .= '<textarea cols="80" name="sql_query" id="textSqlquery"' - . ' rows="' . ((count($this->_criteriaTables) > 30) ? '15' : '7') . '"' + . ' rows="' . (count($this->_criteriaTables) > 30 ? '15' : '7') . '"' . ' dir="' . $text_dir . '">'; if (empty($this->_formColumns)) { diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php index 91400158e5..41305971a2 100644 --- a/libraries/classes/DatabaseInterface.php +++ b/libraries/classes/DatabaseInterface.php @@ -9,22 +9,11 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Core; use PhpMyAdmin\Database\DatabaseList; -use PhpMyAdmin\Dbi\DbiExtension; use PhpMyAdmin\Dbi\DbiDummy; +use PhpMyAdmin\Dbi\DbiExtension; use PhpMyAdmin\Dbi\DbiMysqli; use PhpMyAdmin\Di\Container; -use PhpMyAdmin\Error; -use PhpMyAdmin\Index; -use PhpMyAdmin\LanguageManager; -use PhpMyAdmin\Relation; -use PhpMyAdmin\SystemDatabase; -use PhpMyAdmin\Table; -use PhpMyAdmin\Types; -use PhpMyAdmin\Tracker; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; /** * Main interface for database interactions @@ -171,7 +160,8 @@ class DatabaseInterface bool $cache_affected_rows = true ) { $res = $this->tryQuery($query, $link, $options, $cache_affected_rows) - or Util::mysqlDie($this->getError($link), $query); + or Util::mysqlDie($this->getError($link), $query); + return $res; } @@ -259,7 +249,7 @@ class DatabaseInterface unset($this->_table_cache[$one_database][$table]); } $this->_table_cache[$one_database] - = $this->_table_cache[$one_database] + $tables[$one_database]; + += $tables[$one_database]; } else { $this->_table_cache[$one_database] = $tables[$one_database]; } @@ -462,7 +452,7 @@ class DatabaseInterface */ private function _getSqlForTablesFull($this_databases, string $sql_where_table): string { - $sql = ' + return ' SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`, @@ -489,8 +479,6 @@ class DatabaseInterface WHERE `TABLE_SCHEMA` ' . Util::getCollateForIS() . ' IN (\'' . implode("', '", $this_databases) . '\') ' . $sql_where_table; - - return $sql; } /** @@ -597,9 +585,9 @@ class DatabaseInterface function ($a, $b) { $aLength = $a['Data_length'] + $a['Index_length']; $bLength = $b['Data_length'] + $b['Index_length']; - return ($aLength == $bLength) + return $aLength == $bLength ? 0 - : ($aLength < $bLength) ? -1 : 1; + : $aLength < $bLength ? -1 : 1; } ); @@ -1266,7 +1254,7 @@ class DatabaseInterface ): string { $sql = 'SHOW ' . ($full ? 'FULL' : '') . ' COLUMNS FROM ' . Util::backquote($database) . '.' . Util::backquote($table) - . (($column !== null) ? "LIKE '" + . ($column !== null ? "LIKE '" . $GLOBALS['dbi']->escapeString($column) . "'" : ''); return $sql; @@ -1320,7 +1308,7 @@ class DatabaseInterface } } - return ($column != null) ? array_shift($fields) : $fields; + return $column != null ? array_shift($fields) : $fields; } /** @@ -1929,7 +1917,7 @@ class DatabaseInterface $result[] = $one_show['Name']; } } - return($result); + return $result; } /** @@ -1957,7 +1945,7 @@ class DatabaseInterface $query = 'SHOW CREATE ' . $which . ' ' . Util::backquote($db) . '.' . Util::backquote($name); - return($this->fetchValue($query, 0, $returned_field[$which], $link)); + return $this->fetchValue($query, 0, $returned_field[$which], $link); } /** @@ -2050,7 +2038,7 @@ class DatabaseInterface } array_multisort($name, SORT_ASC, $ret); - return($ret); + return $ret; } /** @@ -2191,7 +2179,7 @@ class DatabaseInterface } array_multisort($name, SORT_ASC, $result); - return($result); + return $result; } /** diff --git a/libraries/classes/Dbi/DbiDummy.php b/libraries/classes/Dbi/DbiDummy.php index 8f2cf319fa..b36c680dc1 100644 --- a/libraries/classes/Dbi/DbiDummy.php +++ b/libraries/classes/Dbi/DbiDummy.php @@ -205,9 +205,7 @@ class DbiDummy implements DbiExtension */ public function fetchRow($result) { - $data = $this->fetchAny($result); - - return $data; + return $this->fetchAny($result); } /** diff --git a/libraries/classes/Dbi/DbiMysqli.php b/libraries/classes/Dbi/DbiMysqli.php index b5e6e7a5b1..87335aea14 100644 --- a/libraries/classes/Dbi/DbiMysqli.php +++ b/libraries/classes/Dbi/DbiMysqli.php @@ -51,7 +51,7 @@ class DbiMysqli implements DbiExtension public function connect($user, $password, array $server) { if ($server) { - $server['host'] = (empty($server['host'])) + $server['host'] = empty($server['host']) ? 'localhost' : $server['host']; } diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 5b02a0a657..88080c71d5 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -19,7 +19,6 @@ use PhpMyAdmin\Relation; use PhpMyAdmin\Response; use PhpMyAdmin\Table; use PhpMyAdmin\Template; -use PhpMyAdmin\Url; use PhpMyAdmin\Util; /** diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index b6d80bbc28..98a60c8ddf 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -673,8 +673,8 @@ class Results // 3. Gets the total number of rows if it is unknown if (isset($unlim_num_rows) && $unlim_num_rows != '') { $the_total = $unlim_num_rows; - } elseif ((($displayParts['nav_bar'] == '1') - || ($displayParts['sort_lnk'] == '1')) + } elseif (($displayParts['nav_bar'] == '1') + || ($displayParts['sort_lnk'] == '1') && (strlen($db) > 0 && strlen($table) > 0) ) { $the_total = $GLOBALS['dbi']->getTable($db, $table)->countRecords(); @@ -974,7 +974,7 @@ class Results . str_replace('\'', '\\\'', __('%d is not valid row number.')) . '\', ' . '0' - . (($this->__get('unlim_num_rows') > 0) + . ($this->__get('unlim_num_rows') > 0 ? ', ' . ($this->__get('unlim_num_rows') - 1) : '' ) @@ -1115,10 +1115,10 @@ class Results $maxRows = $_SESSION['tmpval']['max_rows']; $onsubmit = 'onsubmit="return ' - . (($_SESSION['tmpval']['pos'] + . ($_SESSION['tmpval']['pos'] + $maxRows < $this->__get('unlim_num_rows') - && $this->__get('num_rows') >= $maxRows) + && $this->__get('num_rows') >= $maxRows ? 'true' : 'false') . '"'; @@ -1239,8 +1239,8 @@ class Results // See if this column should get highlight because it's used in the // where-query. $name = $fields_meta[$i]->name; - $condition_field = (isset($highlight_columns[$name]) - || isset($highlight_columns[Util::backquote($name)])) + $condition_field = isset($highlight_columns[$name]) + || isset($highlight_columns[Util::backquote($name)]) ? true : false; @@ -1569,42 +1569,42 @@ class Results // 1. Displays the full/partial text button (part 1)... $button_html .= '<thead><tr>' . "\n"; - $colspan = (($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) - && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE)) + $colspan = ($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) + && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE) ? ' colspan="4"' : ''; // ... before the result table - if ((($displayParts['edit_lnk'] == self::NO_EDIT_OR_DELETE) - && ($displayParts['del_lnk'] == self::NO_EDIT_OR_DELETE)) + if (($displayParts['edit_lnk'] == self::NO_EDIT_OR_DELETE) + && ($displayParts['del_lnk'] == self::NO_EDIT_OR_DELETE) && ($displayParts['text_btn'] == '1') ) { $display_params['emptypre'] - = (($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) - && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE)) ? 4 : 0; - } elseif ((($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_LEFT) - || ($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_BOTH)) + = ($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) + && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE) ? 4 : 0; + } elseif (($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_LEFT) + || ($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_BOTH) && ($displayParts['text_btn'] == '1') ) { // ... at the left column of the result table header if possible // and required $display_params['emptypre'] - = (($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) - && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE)) ? 4 : 0; + = ($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) + && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE) ? 4 : 0; $button_html .= '<th class="column_action print_ignore" ' . $colspan . '>' . $full_or_partial_text_link . '</th>'; - } elseif ((($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_LEFT) - || ($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_BOTH)) + } elseif (($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_LEFT) + || ($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_BOTH) && (($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) || ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE)) ) { // ... elseif no button, displays empty(ies) col(s) if required $display_params['emptypre'] - = (($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) - && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE)) ? 4 : 0; + = ($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) + && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE) ? 4 : 0; $button_html .= '<td ' . $colspan . '></td>'; } elseif (($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_NONE)) { @@ -1632,7 +1632,7 @@ class Results */ private function _getTableCommentsArray(array $analyzed_sql_results) { - if ((!$GLOBALS['cfg']['ShowBrowseComments']) + if (!$GLOBALS['cfg']['ShowBrowseComments'] || (empty($analyzed_sql_results['statement']->from)) ) { return []; @@ -1889,9 +1889,9 @@ class Results // SELECT `1`.`master_field` , `2`.`master_field` // FROM `PMA_relation` AS `1` , `PMA_relation` AS `2` - $sort_tbl = (isset($fields_meta->table) + $sort_tbl = isset($fields_meta->table) && strlen($fields_meta->table) > 0 - && $fields_meta->orgname == $fields_meta->name) + && $fields_meta->orgname == $fields_meta->name ? Util::backquote( $fields_meta->table ) . '.' @@ -2008,10 +2008,10 @@ class Results = Util::backquote( $current_name ); - $sort_direction[$special_index] = (preg_match( + $sort_direction[$special_index] = preg_match( '@time|date@i', $fields_meta->type - )) ? self::DESCENDING_SORT_DIR : self::ASCENDING_SORT_DIR; + ) ? self::DESCENDING_SORT_DIR : self::ASCENDING_SORT_DIR; } $sort_expression_nodirection = array_filter($sort_expression_nodirection); @@ -2412,22 +2412,22 @@ class Results // Displays the needed checkboxes at the right // column of the result table header if possible and required... - if ((($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_RIGHT) - || ($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_BOTH)) + if (($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_RIGHT) + || ($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_BOTH) && (($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) || ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE)) && ($displayParts['text_btn'] == '1') ) { $display_params['emptyafter'] - = (($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) - && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE)) ? 4 : 1; + = ($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) + && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE) ? 4 : 1; $right_column_html .= "\n" . '<th class="column_action print_ignore" ' . $colspan . '>' . $full_or_partial_text_link . '</th>'; - } elseif ((($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_LEFT) - || ($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_BOTH)) + } elseif (($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_LEFT) + || ($GLOBALS['cfg']['RowActionLinks'] == self::POSITION_BOTH) && (($displayParts['edit_lnk'] == self::NO_EDIT_OR_DELETE) && ($displayParts['del_lnk'] == self::NO_EDIT_OR_DELETE)) && (! isset($GLOBALS['is_header_sent']) || ! $GLOBALS['is_header_sent']) @@ -2436,8 +2436,8 @@ class Results // (unless coming from Browse mode print view) $display_params['emptyafter'] - = (($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) - && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE)) ? 4 : 1; + = ($displayParts['edit_lnk'] != self::NO_EDIT_OR_DELETE) + && ($displayParts['del_lnk'] != self::NO_EDIT_OR_DELETE) ? 4 : 1; $right_column_html .= "\n" . '<td class="print_ignore" ' . $colspan . '></td>'; @@ -2692,7 +2692,7 @@ class Results $whereClauseMap = $this->__get('whereClauseMap'); while ($row = $GLOBALS['dbi']->fetchRow($dt_result)) { // add repeating headers - if ((($row_no != 0) && ($_SESSION['tmpval']['repeat_cells'] != 0)) + if (($row_no != 0) && ($_SESSION['tmpval']['repeat_cells'] != 0) && !($row_no % $_SESSION['tmpval']['repeat_cells']) ) { $table_body_html .= $this->_getRepeatingHeaders( @@ -2990,7 +2990,7 @@ class Results $not_null_class = $meta->not_null ? 'not_null' : ''; $relation_class = isset($map[$meta->name]) ? 'relation' : ''; - $hide_class = ($col_visib && ! $col_visib[$currentColumn]) + $hide_class = $col_visib && ! $col_visib[$currentColumn] ? 'hide' : ''; $grid_edit = $meta->orgtable != '' ? $grid_edit_class : ''; @@ -3011,9 +3011,9 @@ class Results // See if this column should get highlight because it's used in the // where-query. - $condition_field = (isset($highlight_columns) + $condition_field = isset($highlight_columns) && (isset($highlight_columns[$meta->name]) - || isset($highlight_columns[Util::backquote($meta->name)]))) + || isset($highlight_columns[Util::backquote($meta->name)])) ? true : false; @@ -3696,10 +3696,8 @@ class Results $hide_class, $field_type_class ) { - $class = 'data ' . $grid_edit_class . ' ' . $not_null_class . ' ' + return 'data ' . $grid_edit_class . ' ' . $not_null_class . ' ' . $relation_class . ' ' . $hide_class . ' ' . $field_type_class; - - return $class; } // end of the '_getClassesForColumn()' function @@ -4107,14 +4105,14 @@ class Results // transform functions may enable no-wrapping: $function_nowrap = 'applyTransformationNoWrap'; - $bool_nowrap = (($default_function != $transformation_plugin) - && function_exists((string) $transformation_plugin->$function_nowrap())) + $bool_nowrap = ($default_function != $transformation_plugin) + && function_exists((string) $transformation_plugin->$function_nowrap()) ? $transformation_plugin->$function_nowrap($transform_options) : false; // do not wrap if date field type - $nowrap = (preg_match('@DATE|TIME@i', $meta->type) - || $bool_nowrap) ? ' nowrap' : ''; + $nowrap = preg_match('@DATE|TIME@i', $meta->type) + || $bool_nowrap ? ' nowrap' : ''; $where_comparison = ' = \'' . $GLOBALS['dbi']->escapeString($column) @@ -4912,7 +4910,7 @@ class Results $links_html = '<div class="print_ignore" >'; $url_query = $this->__get('url_query'); - $delete_text = ($del_link == self::DELETE_ROW) ? __('Delete') : __('Kill'); + $delete_text = $del_link == self::DELETE_ROW ? __('Delete') : __('Kill'); $links_html .= $this->template->render('select_all', [ 'pma_theme_image' => $this->__get('pma_theme_image'), @@ -5107,7 +5105,7 @@ class Results */ private function _getCopytoclipboardLinks() { - $html = Util::linkOrButton( + return Util::linkOrButton( '#', Util::getIcon( 'b_insrow', @@ -5116,8 +5114,6 @@ class Results ), ['id' => 'copyToClipBoard'] ); - - return $html; } /** @@ -5129,7 +5125,7 @@ class Results */ private function _getPrintviewLinks() { - $html = Util::linkOrButton( + return Util::linkOrButton( '#', Util::getIcon( 'b_print', @@ -5139,8 +5135,6 @@ class Results ['id' => 'printView'], 'print_view' ); - - return $html; } /** @@ -5378,7 +5372,7 @@ class Results } if ($size <= 0) { - return($result); + return $result; } if ($default_function != $transformation_plugin) { @@ -5387,7 +5381,7 @@ class Results $transform_options, $meta ); - return($result); + return $result; } $result = $default_function($result, [], $meta); @@ -5425,7 +5419,7 @@ class Results . $result . '</a>'; } - return($result); + return $result; } // end of the '_handleNonPrintableContents()' function @@ -5541,7 +5535,7 @@ class Results if (!empty($analyzed_sql_results['statement']->expr)) { foreach ($analyzed_sql_results['statement']->expr as $expr) { - if ((empty($expr->alias)) || (empty($expr->column))) { + if (empty($expr->alias) || (empty($expr->column))) { continue; } if (strcasecmp($meta->name, $expr->alias) == 0) { @@ -5578,7 +5572,7 @@ class Results if ($relational_display == self::RELATIONAL_KEY) { // user chose "relational key" in the display options, so // the title contains the display field - $title = (! empty($dispval)) + $title = ! empty($dispval) ? htmlspecialchars($dispval) : ''; } else { diff --git a/libraries/classes/ErrorReport.php b/libraries/classes/ErrorReport.php index 20a8b80b45..3dfd72270d 100644 --- a/libraries/classes/ErrorReport.php +++ b/libraries/classes/ErrorReport.php @@ -9,9 +9,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Relation; -use PhpMyAdmin\Template; -use PhpMyAdmin\Url; use PhpMyAdmin\Utils\HttpRequest; /** @@ -218,14 +215,13 @@ class ErrorReport */ public function send(array $report): string { - $response = $this->httpRequest->create( + return $this->httpRequest->create( $this->submissionUrl, "POST", false, json_encode($report), "Content-Type: application/json" ); - return $response; } /** diff --git a/libraries/classes/Export.php b/libraries/classes/Export.php index 735d0cfb13..62c93361d4 100644 --- a/libraries/classes/Export.php +++ b/libraries/classes/Export.php @@ -9,16 +9,7 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Core; -use PhpMyAdmin\Encoding; -use PhpMyAdmin\Message; -use PhpMyAdmin\Plugins; use PhpMyAdmin\Plugins\ExportPlugin; -use PhpMyAdmin\Sanitize; -use PhpMyAdmin\Table; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; -use PhpMyAdmin\ZipExtension; /** * PhpMyAdmin\Export class @@ -205,7 +196,7 @@ class Export /** * Close the html tags and add the footers for on-screen export */ - $html = '</textarea>' + return '</textarea>' . ' </form>' . '<br />' // bottom back button @@ -220,7 +211,6 @@ class Export . '.height($body.height() - 100);' . "\n" . '//]]>' . "\n" . '</script>' . "\n"; - return $html; } /** @@ -753,7 +743,7 @@ class Export // if this is a view or a merge table, don't export data if (($whatStrucOrData == 'data' || $whatStrucOrData == 'structure_and_data') && in_array($table, $table_data) - && ! ($is_view) + && ! $is_view ) { $tableObj = new Table($table, $db); $nonGeneratedCols = $tableObj->getNonGeneratedColumns(true); @@ -919,7 +909,7 @@ class Export && $limit_from >= 0 ) { $add_query = ' LIMIT ' - . (($limit_from > 0) ? $limit_from . ', ' : '') + . ($limit_from > 0 ? $limit_from . ', ' : '') . $limit_to; } else { $add_query = ''; @@ -1106,8 +1096,8 @@ class Export $aliases[$db_name]['tables'][$tbl_name]['columns'][$col] = empty($val2) ? $val1 : $val2; } - }; - }; + } + } } return $aliases; } diff --git a/libraries/classes/Footer.php b/libraries/classes/Footer.php index 358a05e625..aba11c80a4 100644 --- a/libraries/classes/Footer.php +++ b/libraries/classes/Footer.php @@ -9,15 +9,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Config; -use PhpMyAdmin\Core; -use PhpMyAdmin\Message; -use PhpMyAdmin\Relation; -use PhpMyAdmin\Response; -use PhpMyAdmin\Sanitize; -use PhpMyAdmin\Scripts; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; use Traversable; /** diff --git a/libraries/classes/Header.php b/libraries/classes/Header.php index 13260a44c8..725399d3ce 100644 --- a/libraries/classes/Header.php +++ b/libraries/classes/Header.php @@ -9,18 +9,7 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Config; -use PhpMyAdmin\Console; -use PhpMyAdmin\Core; -use PhpMyAdmin\Menu; -use PhpMyAdmin\Message; use PhpMyAdmin\Navigation\Navigation; -use PhpMyAdmin\RecentFavoriteTable; -use PhpMyAdmin\Sanitize; -use PhpMyAdmin\Scripts; -use PhpMyAdmin\Url; -use PhpMyAdmin\UserPreferences; -use PhpMyAdmin\Util; /** * Class used to output the HTTP and HTML headers @@ -269,7 +258,7 @@ class Header 'logged_in' => (isset($GLOBALS['dbi']) ? $GLOBALS['dbi']->isUserType('logged') : false), 'is_https' => $GLOBALS['PMA_Config']->isHttps(), 'rootPath' => $GLOBALS['PMA_Config']->getRootPath(), - 'arg_separator' => URL::getArgSeparator(), + 'arg_separator' => Url::getArgSeparator(), 'PMA_VERSION' => PMA_VERSION ]; if (isset($GLOBALS['cfg']['Server']) diff --git a/libraries/classes/Index.php b/libraries/classes/Index.php index f08efb3d01..2d5765d51b 100644 --- a/libraries/classes/Index.php +++ b/libraries/classes/Index.php @@ -9,12 +9,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\IndexColumn; -use PhpMyAdmin\Message; -use PhpMyAdmin\Sanitize; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; - /** * Index manipulation class * @@ -520,7 +514,7 @@ class Index continue; } $html_options .= '<option value="' . $each_index_choice . '"' - . (($this->_choice == $each_index_choice) + . ($this->_choice == $each_index_choice ? ' selected="selected"' : '') . '>' . $each_index_choice . '</option>' . "\n"; diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php index fea3d5cc56..53478c73fa 100644 --- a/libraries/classes/InsertEdit.php +++ b/libraries/classes/InsertEdit.php @@ -9,17 +9,7 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\FileListing; -use PhpMyAdmin\Message; use PhpMyAdmin\Plugins\TransformationsPlugin; -use PhpMyAdmin\Relation; -use PhpMyAdmin\Response; -use PhpMyAdmin\Sanitize; -use PhpMyAdmin\Template; -use PhpMyAdmin\Transformations; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; /** * PhpMyAdmin\InsertEdit class @@ -559,7 +549,7 @@ class InsertEdit if ($real_null_value) { $html_output .= ' checked="checked"'; } - $html_output .= ' id="field_' . ($idindex) . '_2" />'; + $html_output .= ' id="field_' . $idindex . '_2" />'; // nullify_code is needed by the js nullify() function $nullify_code = $this->getNullifyCodeForNullColumn( @@ -867,7 +857,7 @@ class InsertEdit . $onChangeClause . ' ' . ($readOnly ? 'readonly="readonly" ' : '') . 'tabindex="' . ($tabindex + $tabindex_for_value) . '" ' - . 'id="field_' . ($idindex) . '_3" ' + . 'id="field_' . $idindex . '_3" ' . 'value="' . htmlspecialchars($data) . '" />'; $html_output .= '<a class="ajax browse_foreign" href="browse_foreigners.php' @@ -1007,7 +997,7 @@ class InsertEdit . ' rows="' . $textAreaRows . '"' . ' cols="' . $textareaCols . '"' . ' dir="' . $text_dir . '"' - . ' id="field_' . ($idindex) . '_3"' + . ' id="field_' . $idindex . '_3"' . (! empty($onChangeClause) ? ' ' . $onChangeClause : '') . ' tabindex="' . ($tabindex + $tabindex_for_value) . '"' . ' data-type="' . $data_type . '">' @@ -1139,7 +1129,7 @@ class InsertEdit . ' class="textfield"' . ' tabindex="' . ($tabindex + $tabindex_for_value) . '"' . ($readOnly ? ' disabled' : '') - . ' id="field_' . ($idindex) . '_3">'; + . ' id="field_' . $idindex . '_3">'; $html_output .= '<option value=""> </option>' . "\n"; $selected_html = ''; @@ -1199,7 +1189,7 @@ class InsertEdit . '<input type="radio" name="fields' . $column_name_appendix . '"' . ' class="textfield"' . ' value="' . $enum_value['html'] . '"' - . ' id="field_' . ($idindex) . '_3_' . $j . '"' + . ' id="field_' . $idindex . '_3_' . $j . '"' . ' ' . $onChangeClause; if ($data == $enum_value['plain'] || ($data == '' @@ -1264,7 +1254,7 @@ class InsertEdit . ' multiple="multiple"' . ' ' . $onChangeClause . ' tabindex="' . ($tabindex + $tabindex_for_value) . '"' - . ' id="field_' . ($idindex) . '_3">'; + . ' id="field_' . $idindex . '_3">'; $selected_html = ''; foreach ($column_set_values as $column_set_value) { @@ -1494,7 +1484,7 @@ class InsertEdit return '<input type="' . $input_type . '"' . ' name="fields' . $column_name_appendix . '"' . ' value="' . $special_chars . '" size="' . $fieldsize . '"' - . ((isset($column['is_char']) && $column['is_char']) + . (isset($column['is_char']) && $column['is_char'] ? ' data-maxlength="' . $fieldsize . '"' : '') . ($readOnly ? ' readonly="readonly"' : '') @@ -1503,7 +1493,7 @@ class InsertEdit . ($input_type === 'time' ? ' step="1"' : '') . ' class="' . $the_class . '" ' . $onChangeClause . ' tabindex="' . ($tabindex + $tabindex_for_value) . '"' - . ' id="field_' . ($idindex) . '_3" />'; + . ' id="field_' . $idindex . '_3" />'; } /** @@ -2344,7 +2334,7 @@ class InsertEdit // inserted multiple rows, we had to increment this if ($total_affected_rows > 0) { - $insert_id = $insert_id + $total_affected_rows - 1; + $insert_id += $total_affected_rows - 1; } $last_message = Message::notice(__('Inserted row id: %1$d')); $last_message->addParam($insert_id); @@ -2448,7 +2438,7 @@ class InsertEdit if ('K' == $_SESSION['tmpval']['relational_display']) { // user chose "relational key" in the display options, so // the title contains the display field - $title = (! empty($dispval)) + $title = ! empty($dispval) ? ' title="' . htmlspecialchars($dispval) . '"' : ''; } else { @@ -2470,7 +2460,7 @@ class InsertEdit if ('D' == $_SESSION['tmpval']['relational_display']) { // user chose "relational display field" in the // display options, so show display field in the cell - $output .= (!empty($dispval)) ? htmlspecialchars($dispval) : ''; + $output .= !empty($dispval) ? htmlspecialchars($dispval) : ''; } else { // otherwise display data in the cell $output .= htmlspecialchars($relation_field_value); diff --git a/libraries/classes/Menu.php b/libraries/classes/Menu.php index 65e8ede30e..e1c414750b 100644 --- a/libraries/classes/Menu.php +++ b/libraries/classes/Menu.php @@ -9,11 +9,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Relation; -use PhpMyAdmin\Tracker; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; /** * Class for generating the top menu diff --git a/libraries/classes/MultSubmits.php b/libraries/classes/MultSubmits.php index 4529e44ff0..3f22ea179b 100644 --- a/libraries/classes/MultSubmits.php +++ b/libraries/classes/MultSubmits.php @@ -11,14 +11,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Operations; -use PhpMyAdmin\RelationCleanup; -use PhpMyAdmin\Sql; -use PhpMyAdmin\Table; -use PhpMyAdmin\Transformations; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; - /** * Functions for multi submit forms * @@ -230,7 +222,7 @@ class MultSubmits ? 'ALTER TABLE ' . Util::backquote($table) : ',') . ' DROP ' . Util::backquote($selected[$i]) - . (($i == $selectedCount - 1) ? ';' : ''); + . ($i == $selectedCount - 1 ? ';' : ''); break; case 'primary_fld': @@ -241,7 +233,7 @@ class MultSubmits : ' DROP PRIMARY KEY,') . ' ADD PRIMARY KEY( ' : ', ') . Util::backquote($selected[$i]) - . (($i == $selectedCount - 1) ? ');' : ''); + . ($i == $selectedCount - 1 ? ');' : ''); break; case 'index_fld': @@ -250,7 +242,7 @@ class MultSubmits . ' ADD INDEX( ' : ', ') . Util::backquote($selected[$i]) - . (($i == $selectedCount - 1) ? ');' : ''); + . ($i == $selectedCount - 1 ? ');' : ''); break; case 'unique_fld': @@ -259,7 +251,7 @@ class MultSubmits . ' ADD UNIQUE( ' : ', ') . Util::backquote($selected[$i]) - . (($i == $selectedCount - 1) ? ');' : ''); + . ($i == $selectedCount - 1 ? ');' : ''); break; case 'spatial_fld': @@ -268,7 +260,7 @@ class MultSubmits . ' ADD SPATIAL( ' : ', ') . Util::backquote($selected[$i]) - . (($i == $selectedCount - 1) ? ');' : ''); + . ($i == $selectedCount - 1 ? ');' : ''); break; case 'fulltext_fld': @@ -277,7 +269,7 @@ class MultSubmits . ' ADD FULLTEXT( ' : ', ') . Util::backquote($selected[$i]) - . (($i == $selectedCount - 1) ? ');' : ''); + . ($i == $selectedCount - 1 ? ');' : ''); break; case 'add_prefix_tbl': diff --git a/libraries/classes/Navigation/Nodes/Node.php b/libraries/classes/Navigation/Nodes/Node.php index 73fb10b513..8c2d9db70f 100644 --- a/libraries/classes/Navigation/Nodes/Node.php +++ b/libraries/classes/Navigation/Nodes/Node.php @@ -279,9 +279,7 @@ class Node $retval = false; $paths = $this->getPaths(); if (count($paths['aPath_clean']) > 3) { - $retval = true; - - return $retval; + return true; } foreach ($this->parent->children as $child) { diff --git a/libraries/classes/Normalization.php b/libraries/classes/Normalization.php index 16f35f8186..a0823cf4ef 100644 --- a/libraries/classes/Normalization.php +++ b/libraries/classes/Normalization.php @@ -9,14 +9,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Index; -use PhpMyAdmin\Message; -use PhpMyAdmin\Relation; -use PhpMyAdmin\Template; -use PhpMyAdmin\Transformations; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; - /** * Set of functions used for normalization * @@ -277,14 +269,13 @@ class Normalization . '<a href="#" id="addNewPrimary">' . __('+ Add a new primary key column') . '</a>'; } - $res = [ + return [ 'legendText' => $legendText, 'headText' => $headText, 'subText' => $subText, 'hasPrimaryKey' => $hasPrimaryKey, 'extra' => $extra ]; - return $res; } /** @@ -316,13 +307,12 @@ class Normalization . '<input type="submit" value="' . __('No redundant column') . '" onclick="goToFinish1NF();"' . '/>'; - $res = [ + return [ 'legendText' => $legendText, 'headText' => $headText, 'subText' => $subText, 'extra' => $extra ]; - return $res; } /** @@ -362,14 +352,13 @@ class Normalization foreach ($primarycols as $col) { $pk[] = $col->getName(); } - $res = [ + return [ 'legendText' => $legendText, 'headText' => $headText, 'subText' => $subText, 'extra' => $extra, 'primary_key' => json_encode($pk) ]; - return $res; } /** @@ -458,14 +447,13 @@ class Normalization ) . '<br/>'; $extra = '<h3>' . __('Table is already in second normal form.') . '</h3>'; } - $res = [ + return [ 'legendText' => $legendText, 'headText' => $headText, 'subText' => $subText, 'extra' => $extra, 'primary_key' => $key ]; - return $res; } /** @@ -867,13 +855,12 @@ class Normalization $subText = ""; $extra = "<h3>" . __("Table is already in Third normal form!") . "</h3>"; } - $res = [ + return [ 'legendText' => $legendText, 'headText' => $headText, 'subText' => $subText, 'extra' => $extra ]; - return $res; } /** diff --git a/libraries/classes/Operations.php b/libraries/classes/Operations.php index 65951c8390..5fc5b1265a 100644 --- a/libraries/classes/Operations.php +++ b/libraries/classes/Operations.php @@ -9,18 +9,8 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Charsets; -use PhpMyAdmin\Core; use PhpMyAdmin\Engines\Innodb; -use PhpMyAdmin\Message; -use PhpMyAdmin\Partition; use PhpMyAdmin\Plugins\Export\ExportSql; -use PhpMyAdmin\Relation; -use PhpMyAdmin\Response; -use PhpMyAdmin\StorageEngine; -use PhpMyAdmin\Table; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; /** * Set of functions with the operations section in phpMyAdmin @@ -1037,7 +1027,7 @@ class Operations private function getHtmlForTableComments($current_value) { $commentLength = $this->dbi->getVersion() >= 50503 ? 2048 : 60; - $html_output = '<tr><td class="vmiddle">' . __('Table comments') . '</td>' + return '<tr><td class="vmiddle">' . __('Table comments') . '</td>' . '<td><input type="text" name="comment" ' . 'maxlength="' . $commentLength . '"' . 'value="' . htmlspecialchars($current_value) . '" />' @@ -1045,8 +1035,6 @@ class Operations . htmlspecialchars($current_value) . '" />' . '</td>' . '</tr>'; - - return $html_output; } /** @@ -1244,7 +1232,7 @@ class Operations . '</td>' . '<td>' . '<input type="checkbox" name="' . $attribute . '" id="' . $attribute . '"' - . ' value="1"' . ((!empty($val) && $val == 1) ? ' checked="checked"' : '') + . ' value="1"' . (!empty($val) && $val == 1 ? ' checked="checked"' : '') . '/>' . '</td>' . '</tr>'; diff --git a/libraries/classes/Plugins/Export/ExportSql.php b/libraries/classes/Plugins/Export/ExportSql.php index e40c039d53..ebd7f0c5d6 100644 --- a/libraries/classes/Plugins/Export/ExportSql.php +++ b/libraries/classes/Plugins/Export/ExportSql.php @@ -14,7 +14,6 @@ use PhpMyAdmin\Charsets; use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\ExportPlugin; -use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertySubgroup; @@ -24,12 +23,12 @@ use PhpMyAdmin\Properties\Options\Items\NumberPropertyItem; use PhpMyAdmin\Properties\Options\Items\RadioPropertyItem; use PhpMyAdmin\Properties\Options\Items\SelectPropertyItem; use PhpMyAdmin\Properties\Options\Items\TextPropertyItem; +use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\SqlParser\Components\CreateDefinition; use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Statements\CreateStatement; use PhpMyAdmin\SqlParser\Token; -use PhpMyAdmin\Transformations; use PhpMyAdmin\Util; /** @@ -1277,7 +1276,7 @@ class ExportSql extends ExportPlugin } $create_query .= implode(',', $tmp) . ');' . $crlf; - return ($create_query); + return $create_query; } /** @@ -1794,7 +1793,7 @@ class ExportSql extends ExportPlugin ) . $alter_footer; } - if ((!empty($indexes)) || (!empty($indexes_fulltext))) { + if (!empty($indexes) || (!empty($indexes_fulltext))) { $sql_indexes = $this->generateComment( $crlf, $sql_indexes, @@ -1813,7 +1812,7 @@ class ExportSql extends ExportPlugin } // Generating auto-increment-related query. - if ((! empty($auto_increment)) && ($update_indexes_increments)) { + if (! empty($auto_increment) && ($update_indexes_increments)) { $sql_auto_increments_query = $alter_header . $crlf . ' MODIFY ' . implode(',' . $crlf . ' MODIFY ', $auto_increment); if (isset($GLOBALS['sql_auto_increment']) @@ -2669,15 +2668,13 @@ class ExportSql extends ExportPlugin '" float NOT NULL$3' . "\n", $create_query ); - $create_query = preg_replace( + return preg_replace( '/" (float|double)(\([0-9,]+,[0-9,]+\))? NOT NULL DEFAULT \'([^\'])/', '" float NOT NULL DEFAULT \'$3', $create_query ); // @todo remove indexes from CREATE TABLE - - return $create_query; } /** @@ -2830,7 +2827,7 @@ class ExportSql extends ExportPlugin } } - if (($statement->options->has('TRIGGER')) + if ($statement->options->has('TRIGGER') || ($statement->options->has('PROCEDURE')) || ($statement->options->has('FUNCTION')) || ($statement->options->has('VIEW')) @@ -2847,10 +2844,10 @@ class ExportSql extends ExportPlugin // Replacing only symbols (that are not variables) and unknown // identifiers. - if ((($token->type === Token::TYPE_SYMBOL) - && (!($token->flags & Token::FLAG_SYMBOL_VARIABLE))) - || ((($token->type === Token::TYPE_KEYWORD) - && (!($token->flags & Token::FLAG_KEYWORD_RESERVED))) + if (($token->type === Token::TYPE_SYMBOL) + && (!($token->flags & Token::FLAG_SYMBOL_VARIABLE)) + || (($token->type === Token::TYPE_KEYWORD) + && (!($token->flags & Token::FLAG_KEYWORD_RESERVED)) || ($token->type === Token::TYPE_NONE)) ) { $alias = $this->getAlias($aliases, $token->value); diff --git a/libraries/classes/Plugins/Export/Helpers/Pdf.php b/libraries/classes/Plugins/Export/Helpers/Pdf.php index 385910635b..5501f786a4 100644 --- a/libraries/classes/Plugins/Export/Helpers/Pdf.php +++ b/libraries/classes/Plugins/Export/Helpers/Pdf.php @@ -168,18 +168,17 @@ class Pdf extends PdfLib foreach ($this->tablewidths as $width) { $fullwidth += $width; } - $this->SetY(($this->tMargin) - ($this->FontSizePt / $this->k) * 5); + $this->SetY($this->tMargin - ($this->FontSizePt / $this->k) * 5); $this->cellFontSize = $this->FontSizePt; $this->SetFont( PdfLib::PMA_PDF_FONT, '', ($this->titleFontSize - ? $this->titleFontSize - : $this->FontSizePt) + ?: $this->FontSizePt) ); $this->Cell(0, $this->FontSizePt, $this->titleText, 0, 1, 'C'); $this->SetFont(PdfLib::PMA_PDF_FONT, '', $this->cellFontSize); - $this->SetY(($this->tMargin) - ($this->FontSizePt / $this->k) * 2.5); + $this->SetY($this->tMargin - ($this->FontSizePt / $this->k) * 2.5); $this->Cell( 0, $this->FontSizePt, @@ -190,25 +189,25 @@ class Pdf extends PdfLib 1, 'L' ); - $l = ($this->lMargin); + $l = $this->lMargin; foreach ($this->colTitles as $col => $txt) { - $this->SetXY($l, ($this->tMargin)); + $this->SetXY($l, $this->tMargin); $this->MultiCell( $this->tablewidths[$col], $this->FontSizePt, $txt ); $l += $this->tablewidths[$col]; - $maxY = ($maxY < $this->GetY()) ? $this->GetY() : $maxY; + $maxY = $maxY < $this->GetY() ? $this->GetY() : $maxY; } $this->SetXY($this->lMargin, $this->tMargin); $this->SetFillColor(200, 200, 200); - $l = ($this->lMargin); + $l = $this->lMargin; foreach ($this->colTitles as $col => $txt) { $this->SetXY($l, $this->tMargin); $this->Cell( $this->tablewidths[$col], - $maxY - ($this->tMargin), + $maxY - $this->tMargin, '', 1, 0, @@ -307,8 +306,8 @@ class Pdf extends PdfLib for ($i = $startpage; $i <= $maxpage; $i++) { $this->page = $i; $l = $this->lMargin; - $t = ($i == $startpage) ? $startheight : $this->tMargin; - $lh = ($i == $maxpage) ? $h : $this->h - $this->bMargin; + $t = $i == $startpage ? $startheight : $this->tMargin; + $lh = $i == $maxpage ? $h : $this->h - $this->bMargin; $this->Line($l, $t, $l, $lh); foreach ($this->tablewidths as $width) { $l += $width; @@ -464,8 +463,8 @@ class Pdf extends PdfLib for ($i = $startpage; $i <= $maxpage; $i++) { $this->page = $i; $l = $this->lMargin; - $t = ($i == $startpage) ? $startheight : $this->tMargin; - $lh = ($i == $maxpage) ? $h : $this->h - $this->bMargin; + $t = $i == $startpage ? $startheight : $this->tMargin; + $lh = $i == $maxpage ? $h : $this->h - $this->bMargin; $this->Line($l, $t, $l, $lh); foreach ($this->tablewidths as $width) { $l += $width; @@ -634,7 +633,7 @@ class Pdf extends PdfLib } $data [] = $column['Field']; $data [] = $type; - $data [] = ($column['Null'] == '' || $column['Null'] == 'NO') + $data [] = $column['Null'] == '' || $column['Null'] == 'NO' ? 'No' : 'Yes'; $data [] = isset($column['Default']) ? $column['Default'] : ''; @@ -705,8 +704,8 @@ class Pdf extends PdfLib for ($i = $startpage; $i <= $maxpage; $i++) { $this->page = $i; $l = $this->lMargin; - $t = ($i == $startpage) ? $startheight : $this->tMargin; - $lh = ($i == $maxpage) ? $h : $this->h - $this->bMargin; + $t = $i == $startpage ? $startheight : $this->tMargin; + $lh = $i == $maxpage ? $h : $this->h - $this->bMargin; $this->Line($l, $t, $l, $lh); foreach ($this->tablewidths as $width) { $l += $width; diff --git a/libraries/classes/Plugins/ExportPlugin.php b/libraries/classes/Plugins/ExportPlugin.php index 03f0da4d93..66814fd01c 100644 --- a/libraries/classes/Plugins/ExportPlugin.php +++ b/libraries/classes/Plugins/ExportPlugin.php @@ -137,7 +137,6 @@ abstract class ExportPlugin */ public function exportRoutines($db, array $aliases = []) { - ; } /** @@ -149,7 +148,6 @@ abstract class ExportPlugin */ public function exportEvents($db) { - ; } /** @@ -187,7 +185,6 @@ abstract class ExportPlugin $dates = false, array $aliases = [] ) { - ; } /** @@ -204,7 +201,6 @@ abstract class ExportPlugin $tables, array $metadataTypes ) { - ; } /** @@ -219,7 +215,6 @@ abstract class ExportPlugin */ public function getTableDefStandIn($db, $view, $crlf, $aliases = []) { - ; } /** @@ -232,7 +227,6 @@ abstract class ExportPlugin */ protected function getTriggers($db, $table) { - ; } /** @@ -242,7 +236,6 @@ abstract class ExportPlugin */ protected function initSpecificVariables() { - ; } /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ diff --git a/libraries/classes/Plugins/Schema/ExportRelationSchema.php b/libraries/classes/Plugins/Schema/ExportRelationSchema.php index ab3233a531..b4cd227d41 100644 --- a/libraries/classes/Plugins/Schema/ExportRelationSchema.php +++ b/libraries/classes/Plugins/Schema/ExportRelationSchema.php @@ -177,7 +177,7 @@ class ExportRelationSchema */ public function setOrientation($value) { - $this->orientation = ($value == 'P') ? 'P' : 'L'; + $this->orientation = $value == 'P' ? 'P' : 'L'; } /** diff --git a/libraries/classes/Plugins/Schema/Pdf/Pdf.php b/libraries/classes/Plugins/Schema/Pdf/Pdf.php index 7041964323..fb975e0c96 100644 --- a/libraries/classes/Plugins/Schema/Pdf/Pdf.php +++ b/libraries/classes/Plugins/Schema/Pdf/Pdf.php @@ -156,8 +156,8 @@ class Pdf extends PdfLib $fill = 0, $link = '' ) { - $h = $h / $this->scale; - $w = $w / $this->scale; + $h /= $this->scale; + $w /= $this->scale; $this->Cell($w, $h, $txt, $border, $ln, $align, $fill, $link); } @@ -226,7 +226,7 @@ class Pdf extends PdfLib public function setFontSizeScale($size) { // Set font size in points - $size = $size / $this->scale; + $size /= $this->scale; $this->SetFontSize($size); } @@ -241,7 +241,7 @@ class Pdf extends PdfLib */ public function setLineWidthScale($width) { - $width = $width / $this->scale; + $width /= $this->scale; $this->SetLineWidth($width); } diff --git a/libraries/classes/RecentFavoriteTable.php b/libraries/classes/RecentFavoriteTable.php index 7579269071..25c4b9a4cf 100644 --- a/libraries/classes/RecentFavoriteTable.php +++ b/libraries/classes/RecentFavoriteTable.php @@ -9,12 +9,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Message; -use PhpMyAdmin\Relation; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; - /** * Handles the recently used and favorite tables. * diff --git a/libraries/classes/Relation.php b/libraries/classes/Relation.php index 00b2ffc9f8..145bf34474 100644 --- a/libraries/classes/Relation.php +++ b/libraries/classes/Relation.php @@ -9,16 +9,8 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Core; -use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Message; -use PhpMyAdmin\RecentFavoriteTable; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Utils\Table as TableUtils; -use PhpMyAdmin\Table; -use PhpMyAdmin\Template; -use PhpMyAdmin\Url; -use PhpMyAdmin\Util; /** * Set of functions used with the relation and PDF feature @@ -1476,7 +1468,7 @@ class Relation $f_query_main = 'SELECT ' . Util::backquote($foreign_field) . ( - ($foreign_display == false) + $foreign_display == false ? '' : ', ' . Util::backquote($foreign_display) ); @@ -1486,17 +1478,17 @@ class Relation . Util::backquote($foreign_field) . ' LIKE "%' . $this->dbi->escapeString($foreign_filter) . '%"' . ( - ($foreign_display == false) + $foreign_display == false ? '' : ' OR ' . Util::backquote($foreign_display) . ' LIKE "%' . $this->dbi->escapeString($foreign_filter) . '%"' ); - $f_query_order = ($foreign_display == false) ? '' : ' ORDER BY ' + $f_query_order = $foreign_display == false ? '' : ' ORDER BY ' . Util::backquote($foreign_table) . '.' . Util::backquote($foreign_display); - $f_query_limit = ! empty($foreign_limit) ? ($foreign_limit) : ''; + $f_query_limit = ! empty($foreign_limit) ?: ''; if (!empty($foreign_filter)) { $the_total = $this->dbi->fetchValue( @@ -2161,7 +2153,7 @@ class Relation $have_rel = false; $res_rel = []; } // end if - return([$res_rel, $have_rel]); + return [$res_rel, $have_rel]; } /** diff --git a/libraries/classes/Replication.php b/libraries/classes/Replication.php index 10ed4fbf3f..912d13bd5e 100644 --- a/libraries/classes/Replication.php +++ b/libraries/classes/Replication.php @@ -9,9 +9,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Core; -use PhpMyAdmin\DatabaseInterface; - /** * PhpMyAdmin\Replication class * diff --git a/libraries/classes/SavedSearches.php b/libraries/classes/SavedSearches.php index 3c9ea0ae5f..67eb916a0e 100644 --- a/libraries/classes/SavedSearches.php +++ b/libraries/classes/SavedSearches.php @@ -9,11 +9,6 @@ declare(strict_types=1); namespace PhpMyAdmin; -use PhpMyAdmin\Message; -use PhpMyAdmin\Relation; -use PhpMyAdmin\Response; -use PhpMyAdmin\Util; - /** * Saved searches managing * diff --git a/libraries/classes/Server/Privileges.php b/libraries/classes/Server/Privileges.php index 370bf34d34..801a8fef0e 100644 --- a/libraries/classes/Server/Privileges.php +++ b/libraries/classes/Server/Privileges.php @@ -782,9 +782,9 @@ class Privileges 'Does not require SSL-encrypted connections.' ), 'label' => 'REQUIRE NONE', - 'checked' => ((isset($row['ssl_type']) + 'checked' => (isset($row['ssl_type']) && ($row['ssl_type'] == 'NONE' - || $row['ssl_type'] == '')) + || $row['ssl_type'] == '') ? 'checked="checked"' : '' ), @@ -1591,16 +1591,15 @@ class Privileges . 'title="' . __('User name') . '">' . "\n"; $html_output .= '<option value="any"' - . ((isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any') + . (isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any' ? ' selected="selected"' : '') . '>' . __('Any user') . '</option>' . "\n"; $html_output .= '<option value="userdefined"' - . ((! isset($GLOBALS['pred_username']) + . (! isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined' - ) ? ' selected="selected"' : '') . '>' . __('Use text field') @@ -1619,9 +1618,8 @@ class Privileges : $GLOBALS['username'] ) . '"' ) - . ((! isset($GLOBALS['pred_username']) + . (! isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined' - ) ? 'required="required"' : '') . ' />' . "\n"; @@ -1679,26 +1677,23 @@ class Privileges } } $html_output .= '<option value="any"' - . ((isset($GLOBALS['pred_hostname']) + . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'any' - ) ? ' selected="selected"' : '') . '>' . __('Any host') . '</option>' . "\n" . '<option value="localhost"' - . ((isset($GLOBALS['pred_hostname']) + . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'localhost' - ) ? ' selected="selected"' : '') . '>' . __('Local') . '</option>' . "\n"; if (! empty($thishost)) { $html_output .= '<option value="thishost"' - . ((isset($GLOBALS['pred_hostname']) + . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'thishost' - ) ? ' selected="selected"' : '') . '>' . __('This Host') @@ -1706,18 +1701,16 @@ class Privileges } unset($thishost); $html_output .= '<option value="hosttable"' - . ((isset($GLOBALS['pred_hostname']) + . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable' - ) ? ' selected="selected"' : '') . '>' . __('Use Host Table') . '</option>' . "\n"; $html_output .= '<option value="userdefined"' - . ((isset($GLOBALS['pred_hostname']) + . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' - ) ? ' selected="selected"' : '') . '>' . __('Use text field:') . '</option>' . "\n" @@ -1729,9 +1722,8 @@ class Privileges // use default value of '%' to match with the default 'Any host' . htmlspecialchars(isset($GLOBALS['hostname']) ? $GLOBALS['hostname'] : '%') . '" title="' . __('Host name') . '" ' - . ((isset($GLOBALS['pred_hostname']) + . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' - ) ? 'required="required"' : '') . ' />' . "\n" @@ -2035,7 +2027,7 @@ class Privileges $sql_query = 'SET PASSWORD FOR \'' . $this->dbi->escapeString($username) . '\'@\'' . $this->dbi->escapeString($hostname) . '\' = ' - . (($_POST['pma_pw'] == '') + . ($_POST['pma_pw'] == '' ? '\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $_POST['pma_pw']) . '\')'); @@ -2059,7 +2051,7 @@ class Privileges . $hostname . "';"; // Update the plugin for the user - if (!($this->dbi->tryQuery($update_plugin_query))) { + if (!$this->dbi->tryQuery($update_plugin_query)) { Util::mysqlDie( $this->dbi->getError(), $update_plugin_query, @@ -2081,7 +2073,7 @@ class Privileges $sql_query = 'SET PASSWORD FOR \'' . $this->dbi->escapeString($username) . '\'@\'' . $this->dbi->escapeString($hostname) . '\' = ' - . (($_POST['pma_pw'] == '') + . ($_POST['pma_pw'] == '' ? '\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $_POST['pma_pw']) . '\')'); @@ -2089,11 +2081,11 @@ class Privileges $local_query = 'SET PASSWORD FOR \'' . $this->dbi->escapeString($username) . '\'@\'' . $this->dbi->escapeString($hostname) . '\' = ' - . (($_POST['pma_pw'] == '') ? '\'\'' : $hashing_function + . ($_POST['pma_pw'] == '' ? '\'\'' : $hashing_function . '(\'' . $this->dbi->escapeString($_POST['pma_pw']) . '\')'); } - if (!($this->dbi->tryQuery($local_query))) { + if (!$this->dbi->tryQuery($local_query)) { Util::mysqlDie( $this->dbi->getError(), $sql_query, @@ -2238,7 +2230,7 @@ class Privileges $max_user_connections = max(0, $max_user_connections); $sql_query .= ' MAX_USER_CONNECTIONS ' . $max_user_connections; } - return ((!empty($sql_query)) ? ' WITH' . $sql_query : ''); + return (!empty($sql_query) ? ' WITH' . $sql_query : ''); } /** @@ -2403,10 +2395,10 @@ class Privileges $specific_db = ''; $specific_table = ''; if ($GLOBALS['is_grantuser']) { - $specific_db = (isset($row['Db']) && $row['Db'] != '*') + $specific_db = isset($row['Db']) && $row['Db'] != '*' ? $row['Db'] : ''; - $specific_table = (isset($row['Table_name']) - && $row['Table_name'] != '*') + $specific_table = isset($row['Table_name']) + && $row['Table_name'] != '*' ? $row['Table_name'] : ''; $html_output .= $this->getUserLink( 'edit', @@ -2837,10 +2829,10 @@ class Privileges // action $html_output .= '<td>'; - $specific_db = (isset($current['Db']) && $current['Db'] != '*') + $specific_db = isset($current['Db']) && $current['Db'] != '*' ? $current['Db'] : ''; - $specific_table = (isset($current['Table_name']) - && $current['Table_name'] != '*') + $specific_table = isset($current['Table_name']) + && $current['Table_name'] != '*' ? $current['Table_name'] : ''; if ($GLOBALS['is_grantuser']) { $html_output .= $this->getUserLink( @@ -3078,7 +3070,7 @@ class Privileges $new_user_string .= '<span style="color: #FF0000">' . __('No') . '</span>'; - }; + } $new_user_string .= '</td>' . "\n"; $new_user_string .= '<td>' @@ -4643,8 +4635,8 @@ class Privileges . '\'</a></i>' . "\n"; $html_output .= ' - '; - $html_output .= ($dbname_is_wildcard - || is_array($dbname) && count($dbname) > 1) + $html_output .= $dbname_is_wildcard + || is_array($dbname) && count($dbname) > 1 ? __('Databases') : __('Database'); if (! empty($entity_name) && $entity_type === 'table') { $html_output .= ' <i><a href="server_privileges.php' @@ -4940,7 +4932,7 @@ class Privileges $html_output .= Url::getHiddenInputs($_params); $html_output .= $this->getHtmlToDisplayPrivilegesTable( // If $dbname is an array, pass any one db as all have same privs. - Core::ifSetOr($dbname, (is_array($dbname)) ? $dbname[0] : '*', 'length'), + Core::ifSetOr($dbname, is_array($dbname) ? $dbname[0] : '*', 'length'), Core::ifSetOr($tablename, '*', 'length') ); |