Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libraries/classes/Controllers/Database/DataDictionaryController.php2
-rw-r--r--libraries/classes/Controllers/Table/OperationsController.php2
-rw-r--r--libraries/classes/Controllers/Table/RelationController.php2
-rw-r--r--libraries/classes/Controllers/Table/StructureController.php4
-rw-r--r--libraries/classes/Database/Designer/Common.php2
-rw-r--r--libraries/classes/DatabaseInterface.php2
-rw-r--r--libraries/classes/Display/Results.php2
-rw-r--r--libraries/classes/Index.php45
-rw-r--r--libraries/classes/Normalization.php12
-rw-r--r--libraries/classes/Plugins/Schema/TableStats.php2
-rw-r--r--libraries/classes/Sql.php6
-rw-r--r--libraries/classes/Table.php2
-rw-r--r--libraries/classes/Table/Indexes.php2
-rw-r--r--phpstan-baseline.neon5
-rw-r--r--psalm-baseline.xml3
-rw-r--r--test/classes/Controllers/Table/StructureControllerTest.php4
16 files changed, 41 insertions, 56 deletions
diff --git a/libraries/classes/Controllers/Database/DataDictionaryController.php b/libraries/classes/Controllers/Database/DataDictionaryController.php
index 58de43960a..8284d5e39a 100644
--- a/libraries/classes/Controllers/Database/DataDictionaryController.php
+++ b/libraries/classes/Controllers/Database/DataDictionaryController.php
@@ -110,7 +110,7 @@ class DataDictionaryController extends AbstractController
'has_relation' => $hasRelation,
'has_mime' => $relationParameters->browserTransformationFeature !== null,
'columns' => $rows,
- 'indexes' => Index::getFromTable($tableName, $GLOBALS['db']),
+ 'indexes' => Index::getFromTable($this->dbi, $tableName, $GLOBALS['db']),
];
}
diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php
index 9ff9e72d8f..e0cf459d11 100644
--- a/libraries/classes/Controllers/Table/OperationsController.php
+++ b/libraries/classes/Controllers/Table/OperationsController.php
@@ -407,7 +407,7 @@ class OperationsController extends AbstractController
// a user-defined clustered index (PRIMARY KEY or NOT NULL UNIQUE index).
// InnoDB always orders table rows according to such an index if one is present.
if ($GLOBALS['tbl_storage_engine'] === 'INNODB') {
- $GLOBALS['indexes'] = Index::getFromTable($GLOBALS['table'], $GLOBALS['db']);
+ $GLOBALS['indexes'] = Index::getFromTable($this->dbi, $GLOBALS['table'], $GLOBALS['db']);
foreach ($GLOBALS['indexes'] as $name => $idx) {
if ($name === 'PRIMARY') {
$GLOBALS['hideOrderTable'] = true;
diff --git a/libraries/classes/Controllers/Table/RelationController.php b/libraries/classes/Controllers/Table/RelationController.php
index 187d681d8f..3ecf4501cc 100644
--- a/libraries/classes/Controllers/Table/RelationController.php
+++ b/libraries/classes/Controllers/Table/RelationController.php
@@ -359,7 +359,7 @@ final class RelationController extends AbstractController
$this->response->addJSON('columns', $columnList);
// @todo should be: $server->db($db)->table($table)->primary()
- $primary = Index::getPrimary($foreignTable, $_POST['foreignDb']);
+ $primary = Index::getPrimary($this->dbi, $foreignTable, $_POST['foreignDb']);
if ($primary === false) {
return;
}
diff --git a/libraries/classes/Controllers/Table/StructureController.php b/libraries/classes/Controllers/Table/StructureController.php
index 820696b231..fd071eedc7 100644
--- a/libraries/classes/Controllers/Table/StructureController.php
+++ b/libraries/classes/Controllers/Table/StructureController.php
@@ -134,7 +134,7 @@ class StructureController extends AbstractController
DbTableExists::check($GLOBALS['db'], $GLOBALS['table']);
- $primary = Index::getPrimary($GLOBALS['table'], $GLOBALS['db']);
+ $primary = Index::getPrimary($this->dbi, $GLOBALS['table'], $GLOBALS['db']);
$columns_with_index = $this->dbi
->getTable($GLOBALS['db'], $GLOBALS['table'])
->getColumnsWithIndex(Index::UNIQUE | Index::INDEX | Index::SPATIAL | Index::FULLTEXT);
@@ -262,7 +262,7 @@ class StructureController extends AbstractController
return $this->template->render('table/structure/display_structure', [
'collations' => $collations,
'is_foreign_key_supported' => ForeignKey::isSupported($engine),
- 'indexes' => Index::getFromTable($GLOBALS['table'], $GLOBALS['db']),
+ 'indexes' => Index::getFromTable($this->dbi, $GLOBALS['table'], $GLOBALS['db']),
'indexes_duplicates' => Index::findDuplicates($GLOBALS['table'], $GLOBALS['db']),
'relation_parameters' => $relationParameters,
'hide_structure_actions' => $GLOBALS['cfg']['HideStructureActions'] === true,
diff --git a/libraries/classes/Database/Designer/Common.php b/libraries/classes/Database/Designer/Common.php
index 1aa210d4b3..b8606b52ed 100644
--- a/libraries/classes/Database/Designer/Common.php
+++ b/libraries/classes/Database/Designer/Common.php
@@ -221,7 +221,7 @@ class Common
foreach ($designerTables as $designerTable) {
$schema = $designerTable->getDatabaseName();
// for now, take into account only the first index segment
- foreach (Index::getFromTable($designerTable->getTableName(), $schema) as $index) {
+ foreach (Index::getFromTable($this->dbi, $designerTable->getTableName(), $schema) as $index) {
if ($unique_only && ! $index->isUnique()) {
continue;
}
diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php
index a053fb6d24..9b40bb5040 100644
--- a/libraries/classes/DatabaseInterface.php
+++ b/libraries/classes/DatabaseInterface.php
@@ -964,7 +964,7 @@ class DatabaseInterface implements DbalInterface
}
// Check if column is a part of multiple-column index and set its 'Key'.
- $indexes = Index::getFromTable($table, $database);
+ $indexes = Index::getFromTable($this, $table, $database);
foreach ($fields as $field => $fieldData) {
if (! empty($fieldData['Key'])) {
continue;
diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php
index 3c446494f1..158f861875 100644
--- a/libraries/classes/Display/Results.php
+++ b/libraries/classes/Display/Results.php
@@ -997,7 +997,7 @@ class Results
string $unsortedSqlQuery
): array {
// grab indexes data:
- $indexes = Index::getFromTable($this->properties['table'], $this->properties['db']);
+ $indexes = Index::getFromTable($this->dbi, $this->properties['table'], $this->properties['db']);
// do we have any index?
if ($indexes === []) {
diff --git a/libraries/classes/Index.php b/libraries/classes/Index.php
index 5fdb337fb4..5f9e037ba5 100644
--- a/libraries/classes/Index.php
+++ b/libraries/classes/Index.php
@@ -106,17 +106,17 @@ class Index
}
/**
- * Creates(if not already created) and returns the corresponding Index object
- *
- * @param string $schema database name
- * @param string $table table name
- * @param string $index_name index name
+ * Creates (if not already created) and returns the corresponding Index object
*
* @return Index corresponding Index object
*/
- public static function singleton($schema, $table, $index_name = '')
- {
- self::loadIndexes($table, $schema);
+ public static function singleton(
+ DatabaseInterface $dbi,
+ string $schema,
+ string $table,
+ string $index_name = ''
+ ): Index {
+ self::loadIndexes($dbi, $table, $schema);
if (! isset(self::$registry[$schema][$table][$index_name])) {
$index = new Index();
if (strlen($index_name) > 0) {
@@ -133,14 +133,11 @@ class Index
/**
* returns an array with all indexes from the given table
*
- * @param string $table table
- * @param string $schema schema
- *
- * @return Index[] array of indexes
+ * @return Index[]
*/
- public static function getFromTable($table, $schema)
+ public static function getFromTable(DatabaseInterface $dbi, string $table, string $schema): array
{
- self::loadIndexes($table, $schema);
+ self::loadIndexes($dbi, $table, $schema);
if (isset(self::$registry[$schema][$table])) {
return self::$registry[$schema][$table];
@@ -161,7 +158,7 @@ class Index
public static function getFromTableByChoice($table, $schema, $choices = 31)
{
$indexes = [];
- foreach (self::getFromTable($table, $schema) as $index) {
+ foreach (self::getFromTable($GLOBALS['dbi'], $table, $schema) as $index) {
if (($choices & self::PRIMARY) && $index->getChoice() === 'PRIMARY') {
$indexes[] = $index;
}
@@ -191,14 +188,11 @@ class Index
/**
* return primary if set, false otherwise
*
- * @param string $table table
- * @param string $schema schema
- *
* @return Index|false primary index or false if no one exists
*/
- public static function getPrimary($table, $schema)
+ public static function getPrimary(DatabaseInterface $dbi, string $table, string $schema)
{
- self::loadIndexes($table, $schema);
+ self::loadIndexes($dbi, $table, $schema);
if (isset(self::$registry[$schema][$table]['PRIMARY'])) {
return self::$registry[$schema][$table]['PRIMARY'];
@@ -209,17 +203,14 @@ class Index
/**
* Load index data for table
- *
- * @param string $table table
- * @param string $schema schema
*/
- private static function loadIndexes($table, $schema): bool
+ private static function loadIndexes(DatabaseInterface $dbi, string $table, string $schema): bool
{
if (isset(self::$registry[$schema][$table])) {
return true;
}
- $_raw_indexes = $GLOBALS['dbi']->getTableIndexes($schema, $table);
+ $_raw_indexes = $dbi->getTableIndexes($schema, $table);
foreach ($_raw_indexes as $_each_index) {
$_each_index['Schema'] = $schema;
$keyName = $_each_index['Key_name'];
@@ -471,7 +462,7 @@ class Index
public function hasPrimary(): bool
{
- return (bool) self::getPrimary($this->table, $this->schema);
+ return (bool) self::getPrimary($GLOBALS['dbi'], $this->table, $this->schema);
}
/**
@@ -592,7 +583,7 @@ class Index
*/
public static function findDuplicates($table, $schema)
{
- $indexes = self::getFromTable($table, $schema);
+ $indexes = self::getFromTable($GLOBALS['dbi'], $table, $schema);
$output = '';
diff --git a/libraries/classes/Normalization.php b/libraries/classes/Normalization.php
index 1d2a1a94f0..0ae9bffb85 100644
--- a/libraries/classes/Normalization.php
+++ b/libraries/classes/Normalization.php
@@ -273,7 +273,7 @@ class Normalization
{
$step = 2;
$stepTxt = __('Have a primary key');
- $primary = Index::getPrimary($table, $db);
+ $primary = Index::getPrimary($this->dbi, $table, $db);
$hasPrimaryKey = '0';
$legendText = __('Step 1.') . $step . ' ' . $stepTxt;
$extra = '';
@@ -375,7 +375,7 @@ class Normalization
. __('Done') . '">'
. '<input class="btn btn-secondary" type="submit" value="' . __('No repeating group')
. '" onclick="goToStep4();">';
- $primary = Index::getPrimary($table, $db);
+ $primary = Index::getPrimary($this->dbi, $table, $db);
$primarycols = $primary === false ? [] : $primary->getColumns();
$pk = [];
foreach ($primarycols as $col) {
@@ -402,7 +402,7 @@ class Normalization
public function getHtmlFor2NFstep1($db, $table)
{
$legendText = __('Step 2.') . '1 ' . __('Find partial dependencies');
- $primary = Index::getPrimary($table, $db);
+ $primary = Index::getPrimary($this->dbi, $table, $db);
$primarycols = $primary === false ? [] : $primary->getColumns();
$pk = [];
$subText = '';
@@ -626,7 +626,7 @@ class Normalization
continue;
}
- $primary = Index::getPrimary($table, $db);
+ $primary = Index::getPrimary($this->dbi, $table, $db);
$primarycols = $primary === false ? [] : $primary->getColumns();
$pk = [];
foreach ($primarycols as $col) {
@@ -878,7 +878,7 @@ class Normalization
);
$cnt = 0;
foreach ($tables as $table) {
- $primary = Index::getPrimary($table, $db);
+ $primary = Index::getPrimary($this->dbi, $table, $db);
$primarycols = $primary === false ? [] : $primary->getColumns();
$selectTdForm = '';
$pk = [];
@@ -960,7 +960,7 @@ class Normalization
. Util::backquote($table) . ' LIMIT 500) as dt;'
);
$totalRows = $totalRowsRes[0];
- $primary = Index::getPrimary($table, $db);
+ $primary = Index::getPrimary($this->dbi, $table, $db);
$primarycols = $primary === false ? [] : $primary->getColumns();
$pk = [];
foreach ($primarycols as $col) {
diff --git a/libraries/classes/Plugins/Schema/TableStats.php b/libraries/classes/Plugins/Schema/TableStats.php
index 6c4c0950e9..76a957826c 100644
--- a/libraries/classes/Plugins/Schema/TableStats.php
+++ b/libraries/classes/Plugins/Schema/TableStats.php
@@ -133,7 +133,7 @@ abstract class TableStats
}
if ($this->showKeys) {
- $indexes = Index::getFromTable($this->tableName, $this->db);
+ $indexes = Index::getFromTable($GLOBALS['dbi'], $this->tableName, $this->db);
$all_columns = [];
foreach ($indexes as $index) {
$all_columns = array_merge(
diff --git a/libraries/classes/Sql.php b/libraries/classes/Sql.php
index faacb9be32..eca4bf0628 100644
--- a/libraries/classes/Sql.php
+++ b/libraries/classes/Sql.php
@@ -195,7 +195,7 @@ class Sql
$resultSetColumnNames[] = $oneMeta->name;
}
- foreach (Index::getFromTable($table, $db) as $index) {
+ foreach (Index::getFromTable($this->dbi, $table, $db) as $index) {
if (! $index->isUnique()) {
continue;
}
@@ -502,7 +502,7 @@ class Sql
&& ($GLOBALS['cfg']['TablePrimaryKeyOrder'] !== 'NONE')
) {
$primaryKey = null;
- $primary = Index::getPrimary($table, $db);
+ $primary = Index::getPrimary($this->dbi, $table, $db);
if ($primary !== false) {
$primarycols = $primary->getColumns();
@@ -851,7 +851,7 @@ class Sql
) {
// to refresh the list of indexes (Ajax mode)
- $indexes = Index::getFromTable($table, $db);
+ $indexes = Index::getFromTable($this->dbi, $table, $db);
$indexesDuplicates = Index::findDuplicates($table, $db);
$template = new Template();
diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php
index 3b0eaf1277..ea9c259ab1 100644
--- a/libraries/classes/Table.php
+++ b/libraries/classes/Table.php
@@ -2060,7 +2060,7 @@ class Table implements Stringable
*/
public function getIndex($index)
{
- return Index::singleton($this->dbName, $this->name, $index);
+ return Index::singleton($this->dbi, $this->dbName, $this->name, $index);
}
/**
diff --git a/libraries/classes/Table/Indexes.php b/libraries/classes/Table/Indexes.php
index 8d1e460f2e..12c64cb153 100644
--- a/libraries/classes/Table/Indexes.php
+++ b/libraries/classes/Table/Indexes.php
@@ -91,7 +91,7 @@ final class Indexes
Generator::getMessage($message, $sql_query, 'success')
);
- $indexes = Index::getFromTable($table, $db);
+ $indexes = Index::getFromTable($this->dbi, $table, $db);
$indexesDuplicates = Index::findDuplicates($table, $db);
$this->response->addJSON(
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 125d8c649d..10200ca77f 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -4221,11 +4221,6 @@ parameters:
path: libraries/classes/Index.php
-
- message: "#^Static property PhpMyAdmin\\\\Index\\:\\:\\$registry \\(array\\<string, array\\<string, array\\<string, PhpMyAdmin\\\\Index\\>\\>\\>\\) does not accept array\\<string, array\\<string, array\\<int\\|string, PhpMyAdmin\\\\Index\\>\\>\\>\\.$#"
- count: 1
- path: libraries/classes/Index.php
-
- -
message: "#^Method PhpMyAdmin\\\\IndexColumn\\:\\:__construct\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
count: 1
path: libraries/classes/IndexColumn.php
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 4eeaaf5149..aee49939c7 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -8560,7 +8560,7 @@
</PropertyNotSetInConstructor>
</file>
<file src="libraries/classes/Normalization.php">
- <MixedArgument occurrences="29">
+ <MixedArgument occurrences="28">
<code>$arrDependson</code>
<code>$col</code>
<code>$cols['nonpk']</code>
@@ -8585,7 +8585,6 @@
<code>$table</code>
<code>$table</code>
<code>$table</code>
- <code>$table</code>
<code>$tablesName-&gt;$key</code>
<code>$tablesName-&gt;$key</code>
<code>$totalRows</code>
diff --git a/test/classes/Controllers/Table/StructureControllerTest.php b/test/classes/Controllers/Table/StructureControllerTest.php
index 25ce6bd468..124a7b8eea 100644
--- a/test/classes/Controllers/Table/StructureControllerTest.php
+++ b/test/classes/Controllers/Table/StructureControllerTest.php
@@ -110,7 +110,7 @@ class StructureControllerTest extends AbstractTestCase
],
],
'is_foreign_key_supported' => true,
- 'indexes' => Index::getFromTable($GLOBALS['table'], $GLOBALS['db']),
+ 'indexes' => Index::getFromTable($this->dbi, $GLOBALS['table'], $GLOBALS['db']),
'indexes_duplicates' => Index::findDuplicates($GLOBALS['table'], $GLOBALS['db']),
'relation_parameters' => $relation->getRelationParameters(),
'hide_structure_actions' => true,
@@ -120,7 +120,7 @@ class StructureControllerTest extends AbstractTestCase
'tbl_is_view' => false,
'mime_map' => [],
'tbl_storage_engine' => 'INNODB',
- 'primary' => Index::getPrimary($GLOBALS['table'], $GLOBALS['db']),
+ 'primary' => Index::getPrimary($this->dbi, $GLOBALS['table'], $GLOBALS['db']),
'columns_with_unique_index' => [],
'columns_list' => ['id', 'name', 'datetimefield'],
'table_stats' => null,