Merge pull request #18944 from MauricioFauth/connection-type-enum

Create ConnectionType enum
This commit is contained in:
Maurício Meneghini Fauth 2024-01-29 13:16:50 -03:00 committed by GitHub
commit 0dd9e4fbf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
61 changed files with 641 additions and 719 deletions

View File

@ -7331,7 +7331,7 @@ parameters:
path: src/DatabaseInterface.php
-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string, 0\\|1\\|2\\=\\)\\: non\\-empty\\-string given\\.$#"
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string, PhpMyAdmin\\\\Dbal\\\\ConnectionType\\=\\)\\: non\\-empty\\-string given\\.$#"
count: 1
path: src/DatabaseInterface.php

View File

@ -5058,9 +5058,6 @@
<DeprecatedProperty>
<code>Routing::$route</code>
</DeprecatedProperty>
<InvalidDocblock>
<code>private array $connections = [];</code>
</InvalidDocblock>
<InvalidOperand>
<code><![CDATA[$row['Data_free']]]></code>
<code><![CDATA[$row['Data_length']]]></code>
@ -5072,18 +5069,6 @@
<MixedArgument>
<code>$a</code>
<code>$b</code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->connections[$connectionType]]]></code>
<code><![CDATA[$this->versionComment]]></code>
<code><![CDATA[$this->versionString]]></code>
</MixedArgument>

View File

@ -9,7 +9,7 @@ namespace PhpMyAdmin\Bookmarks;
use PhpMyAdmin\ConfigStorage\Features\BookmarkFeature;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Util;
use function count;
@ -95,7 +95,7 @@ class Bookmark
. $this->dbi->quoteString($this->query) . ', '
. $this->dbi->quoteString($this->label) . ')';
return (bool) $this->dbi->query($query, Connection::TYPE_CONTROL);
return (bool) $this->dbi->query($query, ConnectionType::ControlUser);
}
/**
@ -107,7 +107,7 @@ class Bookmark
. '.' . Util::backquote($this->bookmarkFeature->bookmark)
. ' WHERE id = ' . $this->id;
return (bool) $this->dbi->tryQuery($query, Connection::TYPE_CONTROL);
return (bool) $this->dbi->tryQuery($query, ConnectionType::ControlUser);
}
/**

View File

@ -11,7 +11,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Features\BookmarkFeature;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Util;
@ -93,7 +93,7 @@ final class BookmarkRepository
$query .= ' ORDER BY label ASC';
$result = $this->dbi->fetchResult($query, null, null, Connection::TYPE_CONTROL);
$result = $this->dbi->fetchResult($query, null, null, ConnectionType::ControlUser);
$bookmarks = [];
foreach ($result as $row) {
@ -131,7 +131,7 @@ final class BookmarkRepository
$query .= ' LIMIT 1';
$result = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, Connection::TYPE_CONTROL);
$result = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, ConnectionType::ControlUser);
if ($result !== null) {
return $this->createFromRow($result);
}
@ -159,7 +159,7 @@ final class BookmarkRepository
. ' AND user = ' . $this->dbi->quoteString($user)
. ' LIMIT 1';
$result = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, Connection::TYPE_CONTROL);
$result = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, ConnectionType::ControlUser);
if ($result !== null) {
return $this->createFromRow($result);
}

View File

@ -7,7 +7,7 @@ namespace PhpMyAdmin;
use PhpMyAdmin\Config\Settings;
use PhpMyAdmin\Config\Settings\Server;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Exceptions\ConfigException;
use PhpMyAdmin\Routing\Routing;
use PhpMyAdmin\Theme\ThemeManager;
@ -70,7 +70,6 @@ use const PHP_URL_SCHEME;
/**
* Configuration handling
*
* @psalm-import-type ConnectionType from Connection
* @psalm-import-type ServerSettingsType from Server
* @psalm-import-type SettingsType from Settings
*/
@ -1105,12 +1104,10 @@ class Config
/**
* Return connection parameters for the database server
*
* @psalm-param ConnectionType $connectionType
*/
public static function getConnectionParams(Server $currentServer, int $connectionType): Server
public static function getConnectionParams(Server $currentServer, ConnectionType $connectionType): Server
{
if ($connectionType !== Connection::TYPE_CONTROL) {
if ($connectionType !== ConnectionType::ControlUser) {
if ($currentServer->host !== '' && $currentServer->port !== '') {
return $currentServer;
}

View File

@ -8,7 +8,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Features\PdfFeature;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\InternalRelations;
@ -154,7 +154,7 @@ class Relation
}
$config = Config::getInstance();
$tables = $this->dbi->getTables($config->selectedServer['pmadb'], Connection::TYPE_CONTROL);
$tables = $this->dbi->getTables($config->selectedServer['pmadb'], ConnectionType::ControlUser);
if ($tables === []) {
return null;
}
@ -245,7 +245,7 @@ class Relation
if (
Current::$server === 0
|| $config->selectedServer['pmadb'] === ''
|| ! $this->dbi->selectDb($config->selectedServer['pmadb'], Connection::TYPE_CONTROL)
|| ! $this->dbi->selectDb($config->selectedServer['pmadb'], ConnectionType::ControlUser)
) {
$config->selectedServer['pmadb'] = '';
@ -346,14 +346,14 @@ class Relation
],
(string) $query,
);
$this->dbi->tryMultiQuery($query, Connection::TYPE_CONTROL);
$this->dbi->tryMultiQuery($query, ConnectionType::ControlUser);
// skips result sets of query as we are not interested in it
/** @infection-ignore-all */
do {
$hasResult = $this->dbi->nextResult(Connection::TYPE_CONTROL);
$hasResult = $this->dbi->nextResult(ConnectionType::ControlUser);
} while ($hasResult !== false);
$error = $this->dbi->getError(Connection::TYPE_CONTROL);
$error = $this->dbi->getError(ConnectionType::ControlUser);
// return true if no error exists otherwise false
return $error === '';
@ -391,7 +391,7 @@ class Relation
$relQuery .= ' AND `master_field` = ' . $this->dbi->quoteString($column);
}
$foreign = $this->dbi->fetchResult($relQuery, 'master_field', null, Connection::TYPE_CONTROL);
$foreign = $this->dbi->fetchResult($relQuery, 'master_field', null, ConnectionType::ControlUser);
}
if (($source === 'both' || $source === 'foreign') && strlen($table) > 0) {
@ -459,7 +459,7 @@ class Relation
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db)
. ' AND `table_name` = ' . $this->dbi->quoteString($table);
$row = $this->dbi->fetchSingleRow($dispQuery, DatabaseInterface::FETCH_ASSOC, Connection::TYPE_CONTROL);
$row = $this->dbi->fetchSingleRow($dispQuery, DatabaseInterface::FETCH_ASSOC, ConnectionType::ControlUser);
if (isset($row['display_field'])) {
return $row['display_field'];
}
@ -533,7 +533,7 @@ class Relation
$comQry = 'SELECT `comment`'
. ' FROM ' . Util::backquote($columnCommentsFeature->database)
. '.' . Util::backquote($columnCommentsFeature->columnInfo)
. ' WHERE db_name = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL)
. ' WHERE db_name = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser)
. ' AND table_name = \'\''
. ' AND column_name = \'(db_comment)\'';
$comRs = $this->dbi->tryQueryAsControlUser($comQry);
@ -567,17 +567,17 @@ class Relation
. Util::backquote($columnCommentsFeature->columnInfo)
. ' (`db_name`, `table_name`, `column_name`, `comment`)'
. ' VALUES ('
. $this->dbi->quoteString($db, Connection::TYPE_CONTROL)
. $this->dbi->quoteString($db, ConnectionType::ControlUser)
. ", '', '(db_comment)', "
. $this->dbi->quoteString($comment, Connection::TYPE_CONTROL)
. $this->dbi->quoteString($comment, ConnectionType::ControlUser)
. ') '
. ' ON DUPLICATE KEY UPDATE '
. '`comment` = ' . $this->dbi->quoteString($comment, Connection::TYPE_CONTROL);
. '`comment` = ' . $this->dbi->quoteString($comment, ConnectionType::ControlUser);
} else {
$updQuery = 'DELETE FROM '
. Util::backquote($columnCommentsFeature->database) . '.'
. Util::backquote($columnCommentsFeature->columnInfo)
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL)
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser)
. '
AND `table_name` = \'\'
AND `column_name` = \'(db_comment)\'';
@ -630,11 +630,11 @@ class Relation
`timevalue`,
`sqlquery`)
VALUES
(' . $this->dbi->quoteString($username, Connection::TYPE_CONTROL) . ',
' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL) . ',
' . $this->dbi->quoteString($table, Connection::TYPE_CONTROL) . ',
(' . $this->dbi->quoteString($username, ConnectionType::ControlUser) . ',
' . $this->dbi->quoteString($db, ConnectionType::ControlUser) . ',
' . $this->dbi->quoteString($table, ConnectionType::ControlUser) . ',
NOW(),
' . $this->dbi->quoteString($sqlquery, Connection::TYPE_CONTROL) . ')',
' . $this->dbi->quoteString($sqlquery, ConnectionType::ControlUser) . ')',
);
$this->purgeHistory($username);
@ -676,7 +676,7 @@ class Relation
WHERE `username` = ' . $this->dbi->quoteString($username) . '
ORDER BY `id` DESC';
return $this->dbi->fetchResult($histQuery, null, null, Connection::TYPE_CONTROL);
return $this->dbi->fetchResult($histQuery, null, null, ConnectionType::ControlUser);
}
/**
@ -703,7 +703,7 @@ class Relation
ORDER BY `timevalue` DESC
LIMIT ' . $config->settings['QueryHistoryMax'] . ', 1';
$maxTime = $this->dbi->fetchValue($searchQuery, 0, Connection::TYPE_CONTROL);
$maxTime = $this->dbi->fetchValue($searchQuery, 0, ConnectionType::ControlUser);
if (! $maxTime) {
return;
@ -713,7 +713,7 @@ class Relation
'DELETE FROM '
. Util::backquote($sqlHistoryFeature->database) . '.'
. Util::backquote($sqlHistoryFeature->history) . '
WHERE `username` = ' . $this->dbi->quoteString($username, Connection::TYPE_CONTROL)
WHERE `username` = ' . $this->dbi->quoteString($username, ConnectionType::ControlUser)
. '
AND `timevalue` <= \'' . $maxTime . '\'',
);
@ -1028,10 +1028,10 @@ class Relation
$tableQuery = 'UPDATE '
. Util::backquote($relationParameters->displayFeature->database) . '.'
. Util::backquote($relationParameters->displayFeature->tableInfo)
. ' SET display_field = ' . $this->dbi->quoteString($newName, Connection::TYPE_CONTROL)
. ' WHERE db_name = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL)
. ' AND table_name = ' . $this->dbi->quoteString($table, Connection::TYPE_CONTROL)
. ' AND display_field = ' . $this->dbi->quoteString($field, Connection::TYPE_CONTROL);
. ' SET display_field = ' . $this->dbi->quoteString($newName, ConnectionType::ControlUser)
. ' WHERE db_name = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser)
. ' AND table_name = ' . $this->dbi->quoteString($table, ConnectionType::ControlUser)
. ' AND display_field = ' . $this->dbi->quoteString($field, ConnectionType::ControlUser);
$this->dbi->queryAsControlUser($tableQuery);
}
@ -1042,19 +1042,19 @@ class Relation
$tableQuery = 'UPDATE '
. Util::backquote($relationParameters->relationFeature->database) . '.'
. Util::backquote($relationParameters->relationFeature->relation)
. ' SET master_field = ' . $this->dbi->quoteString($newName, Connection::TYPE_CONTROL)
. ' WHERE master_db = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL)
. ' AND master_table = ' . $this->dbi->quoteString($table, Connection::TYPE_CONTROL)
. ' AND master_field = ' . $this->dbi->quoteString($field, Connection::TYPE_CONTROL);
. ' SET master_field = ' . $this->dbi->quoteString($newName, ConnectionType::ControlUser)
. ' WHERE master_db = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser)
. ' AND master_table = ' . $this->dbi->quoteString($table, ConnectionType::ControlUser)
. ' AND master_field = ' . $this->dbi->quoteString($field, ConnectionType::ControlUser);
$this->dbi->queryAsControlUser($tableQuery);
$tableQuery = 'UPDATE '
. Util::backquote($relationParameters->relationFeature->database) . '.'
. Util::backquote($relationParameters->relationFeature->relation)
. ' SET foreign_field = ' . $this->dbi->quoteString($newName, Connection::TYPE_CONTROL)
. ' WHERE foreign_db = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL)
. ' AND foreign_table = ' . $this->dbi->quoteString($table, Connection::TYPE_CONTROL)
. ' AND foreign_field = ' . $this->dbi->quoteString($field, Connection::TYPE_CONTROL);
. ' SET foreign_field = ' . $this->dbi->quoteString($newName, ConnectionType::ControlUser)
. ' WHERE foreign_db = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser)
. ' AND foreign_table = ' . $this->dbi->quoteString($table, ConnectionType::ControlUser)
. ' AND foreign_field = ' . $this->dbi->quoteString($field, ConnectionType::ControlUser);
$this->dbi->queryAsControlUser($tableQuery);
}
@ -1082,13 +1082,13 @@ class Relation
. Util::backquote($configStorageDatabase) . '.'
. Util::backquote($configStorageTable)
. ' SET '
. $dbField . ' = ' . $this->dbi->quoteString($targetDb, Connection::TYPE_CONTROL)
. $dbField . ' = ' . $this->dbi->quoteString($targetDb, ConnectionType::ControlUser)
. ', '
. $tableField . ' = ' . $this->dbi->quoteString($targetTable, Connection::TYPE_CONTROL)
. $tableField . ' = ' . $this->dbi->quoteString($targetTable, ConnectionType::ControlUser)
. ' WHERE '
. $dbField . ' = ' . $this->dbi->quoteString($sourceDb, Connection::TYPE_CONTROL)
. $dbField . ' = ' . $this->dbi->quoteString($sourceDb, ConnectionType::ControlUser)
. ' AND '
. $tableField . ' = ' . $this->dbi->quoteString($sourceTable, Connection::TYPE_CONTROL);
. $tableField . ' = ' . $this->dbi->quoteString($sourceTable, ConnectionType::ControlUser);
$this->dbi->queryAsControlUser($query);
}
@ -1179,8 +1179,8 @@ class Relation
$removeQuery = 'DELETE FROM '
. Util::backquote($relationParameters->pdfFeature->database) . '.'
. Util::backquote($relationParameters->pdfFeature->tableCoords)
. ' WHERE db_name = ' . $this->dbi->quoteString($sourceDb, Connection::TYPE_CONTROL)
. ' AND table_name = ' . $this->dbi->quoteString($sourceTable, Connection::TYPE_CONTROL);
. ' WHERE db_name = ' . $this->dbi->quoteString($sourceDb, ConnectionType::ControlUser)
. ' AND table_name = ' . $this->dbi->quoteString($sourceTable, ConnectionType::ControlUser);
$this->dbi->queryAsControlUser($removeQuery);
}
}
@ -1218,11 +1218,11 @@ class Relation
$query = 'UPDATE '
. Util::backquote($relationParameters->navigationItemsHidingFeature->database) . '.'
. Util::backquote($relationParameters->navigationItemsHidingFeature->navigationHiding)
. ' SET db_name = ' . $this->dbi->quoteString($targetDb, Connection::TYPE_CONTROL)
. ' SET db_name = ' . $this->dbi->quoteString($targetDb, ConnectionType::ControlUser)
. ','
. ' item_name = ' . $this->dbi->quoteString($targetTable, Connection::TYPE_CONTROL)
. ' WHERE db_name = ' . $this->dbi->quoteString($sourceDb, Connection::TYPE_CONTROL)
. ' AND item_name = ' . $this->dbi->quoteString($sourceTable, Connection::TYPE_CONTROL)
. ' item_name = ' . $this->dbi->quoteString($targetTable, ConnectionType::ControlUser)
. ' WHERE db_name = ' . $this->dbi->quoteString($sourceDb, ConnectionType::ControlUser)
. ' AND item_name = ' . $this->dbi->quoteString($sourceTable, ConnectionType::ControlUser)
. " AND item_type = 'table'";
$this->dbi->queryAsControlUser($query);
}
@ -1240,14 +1240,14 @@ class Relation
. Util::backquote($pdfFeature->pdfPages)
. ' (db_name, page_descr)'
. ' VALUES ('
. $this->dbi->quoteString($db, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($db, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString(
$newpage !== null && $newpage !== '' ? $newpage : __('no description'),
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
) . ')';
$this->dbi->tryQueryAsControlUser($insQuery);
return $this->dbi->insertId(Connection::TYPE_CONTROL);
return $this->dbi->insertId(ConnectionType::ControlUser);
}
/**
@ -1420,10 +1420,10 @@ class Relation
{
$this->dbi->tryQuery(
'CREATE DATABASE IF NOT EXISTS ' . Util::backquote($configurationStorageDbName),
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
);
$error = $this->dbi->getError(Connection::TYPE_CONTROL);
$error = $this->dbi->getError(ConnectionType::ControlUser);
if ($error === '') {
// Re-build the cache to show the list of tables created or not
// This is the case when the DB could be created but no tables just after
@ -1484,15 +1484,15 @@ class Relation
'pma__export_templates' => 'export_templates',
];
$existingTables = $this->dbi->getTables($db, Connection::TYPE_CONTROL);
$existingTables = $this->dbi->getTables($db, ConnectionType::ControlUser);
$tableNameReplacements = $this->getTableReplacementNames($tablesToFeatures);
$createQueries = [];
if ($create) {
$createQueries = $this->getCreateTableSqlQueries($tableNameReplacements);
if (! $this->dbi->selectDb($db, Connection::TYPE_CONTROL)) {
$GLOBALS['message'] = $this->dbi->getError(Connection::TYPE_CONTROL);
if (! $this->dbi->selectDb($db, ConnectionType::ControlUser)) {
$GLOBALS['message'] = $this->dbi->getError(ConnectionType::ControlUser);
return;
}
@ -1514,9 +1514,9 @@ class Relation
continue;
}
$this->dbi->tryQuery($createQueries[$table], Connection::TYPE_CONTROL);
$this->dbi->tryQuery($createQueries[$table], ConnectionType::ControlUser);
$error = $this->dbi->getError(Connection::TYPE_CONTROL);
$error = $this->dbi->getError(ConnectionType::ControlUser);
if ($error !== '') {
$GLOBALS['message'] = $error;

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\ConfigStorage;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Util;
use function sprintf;
@ -38,9 +38,9 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s AND table_name = %s AND column_name = %s',
Util::backquote($columnCommentsFeature->database),
Util::backquote($columnCommentsFeature->columnInfo),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($column, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
$this->dbi->quoteString($column, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -50,9 +50,9 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s AND table_name = %s AND display_field = %s',
Util::backquote($displayFeature->database),
Util::backquote($displayFeature->tableInfo),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($column, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
$this->dbi->quoteString($column, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -65,9 +65,9 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE master_db = %s AND master_table = %s AND master_field = %s',
Util::backquote($relationFeature->database),
Util::backquote($relationFeature->relation),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($column, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
$this->dbi->quoteString($column, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
@ -75,9 +75,9 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE foreign_db = %s AND foreign_table = %s AND foreign_field = %s',
Util::backquote($relationFeature->database),
Util::backquote($relationFeature->relation),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($column, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
$this->dbi->quoteString($column, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -103,8 +103,8 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s AND table_name = %s',
Util::backquote($columnCommentsFeature->database),
Util::backquote($columnCommentsFeature->columnInfo),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -114,8 +114,8 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s AND table_name = %s',
Util::backquote($displayFeature->database),
Util::backquote($displayFeature->tableInfo),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -125,8 +125,8 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s AND table_name = %s',
Util::backquote($pdfFeature->database),
Util::backquote($pdfFeature->tableCoords),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -136,8 +136,8 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE master_db = %s AND master_table = %s',
Util::backquote($relationFeature->database),
Util::backquote($relationFeature->relation),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
@ -145,8 +145,8 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE foreign_db = %s AND foreign_table = %s',
Util::backquote($relationFeature->database),
Util::backquote($relationFeature->relation),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -156,8 +156,8 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s AND table_name = %s',
Util::backquote($uiPreferencesFeature->database),
Util::backquote($uiPreferencesFeature->tableUiPrefs),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -170,9 +170,9 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s AND (table_name = %s OR (item_name = %s AND item_type = \'table\'))',
Util::backquote($navigationItemsHidingFeature->database),
Util::backquote($navigationItemsHidingFeature->navigationHiding),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -204,7 +204,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s',
Util::backquote($columnCommentsFeature->database),
Util::backquote($columnCommentsFeature->columnInfo),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -214,7 +214,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE dbase = %s',
Util::backquote($bookmarkFeature->database),
Util::backquote($bookmarkFeature->bookmark),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -224,7 +224,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s',
Util::backquote($displayFeature->database),
Util::backquote($displayFeature->tableInfo),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -234,7 +234,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s',
Util::backquote($pdfFeature->database),
Util::backquote($pdfFeature->pdfPages),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
@ -242,7 +242,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s',
Util::backquote($pdfFeature->database),
Util::backquote($pdfFeature->tableCoords),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -252,7 +252,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE master_db = %s',
Util::backquote($relationFeature->database),
Util::backquote($relationFeature->relation),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
@ -260,7 +260,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE foreign_db = %s',
Util::backquote($relationFeature->database),
Util::backquote($relationFeature->relation),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -270,7 +270,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s',
Util::backquote($uiPreferencesFeature->database),
Util::backquote($uiPreferencesFeature->tableUiPrefs),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -280,7 +280,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s',
Util::backquote($navigationItemsHidingFeature->database),
Util::backquote($navigationItemsHidingFeature->navigationHiding),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -290,7 +290,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s',
Util::backquote($savedQueryByExampleSearchesFeature->database),
Util::backquote($savedQueryByExampleSearchesFeature->savedSearches),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -303,7 +303,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE db_name = %s',
Util::backquote($centralColumnsFeature->database),
Util::backquote($centralColumnsFeature->centralColumns),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -336,7 +336,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE `user` = %s',
Util::backquote($bookmarkFeature->database),
Util::backquote($bookmarkFeature->bookmark),
$this->dbi->quoteString($username, Connection::TYPE_CONTROL),
$this->dbi->quoteString($username, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -346,7 +346,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE `username` = %s',
Util::backquote($sqlHistoryFeature->database),
Util::backquote($sqlHistoryFeature->history),
$this->dbi->quoteString($username, Connection::TYPE_CONTROL),
$this->dbi->quoteString($username, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -356,7 +356,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE `username` = %s',
Util::backquote($recentlyUsedTablesFeature->database),
Util::backquote($recentlyUsedTablesFeature->recent),
$this->dbi->quoteString($username, Connection::TYPE_CONTROL),
$this->dbi->quoteString($username, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -366,7 +366,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE `username` = %s',
Util::backquote($favoriteTablesFeature->database),
Util::backquote($favoriteTablesFeature->favorite),
$this->dbi->quoteString($username, Connection::TYPE_CONTROL),
$this->dbi->quoteString($username, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -376,7 +376,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE `username` = %s',
Util::backquote($uiPreferencesFeature->database),
Util::backquote($uiPreferencesFeature->tableUiPrefs),
$this->dbi->quoteString($username, Connection::TYPE_CONTROL),
$this->dbi->quoteString($username, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -386,7 +386,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE `username` = %s',
Util::backquote($userPreferencesFeature->database),
Util::backquote($userPreferencesFeature->userConfig),
$this->dbi->quoteString($username, Connection::TYPE_CONTROL),
$this->dbi->quoteString($username, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -396,7 +396,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE `username` = %s',
Util::backquote($configurableMenusFeature->database),
Util::backquote($configurableMenusFeature->users),
$this->dbi->quoteString($username, Connection::TYPE_CONTROL),
$this->dbi->quoteString($username, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -406,7 +406,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE `username` = %s',
Util::backquote($navigationItemsHidingFeature->database),
Util::backquote($navigationItemsHidingFeature->navigationHiding),
$this->dbi->quoteString($username, Connection::TYPE_CONTROL),
$this->dbi->quoteString($username, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -416,7 +416,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE `username` = %s',
Util::backquote($savedQueryByExampleSearchesFeature->database),
Util::backquote($savedQueryByExampleSearchesFeature->savedSearches),
$this->dbi->quoteString($username, Connection::TYPE_CONTROL),
$this->dbi->quoteString($username, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}
@ -429,7 +429,7 @@ class RelationCleanup
'DELETE FROM %s.%s WHERE `username` = %s',
Util::backquote($databaseDesignerSettingsFeature->database),
Util::backquote($databaseDesignerSettingsFeature->designerSettings),
$this->dbi->quoteString($username, Connection::TYPE_CONTROL),
$this->dbi->quoteString($username, ConnectionType::ControlUser),
);
$this->dbi->queryAsControlUser($statement);
}

View File

@ -9,7 +9,7 @@ namespace PhpMyAdmin\ConfigStorage;
use PhpMyAdmin\ConfigStorage\Features\ConfigurableMenusFeature;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
@ -47,7 +47,7 @@ class UserGroups
. '.' . Util::backquote($configurableMenusFeature->users);
$dbi = DatabaseInterface::getInstance();
$sqlQuery = 'SELECT `username` FROM ' . $usersTable
. ' WHERE `usergroup`=' . $dbi->quoteString($userGroup, Connection::TYPE_CONTROL);
. ' WHERE `usergroup`=' . $dbi->quoteString($userGroup, ConnectionType::ControlUser);
$result = $dbi->tryQueryAsControlUser($sqlQuery);
if ($result) {
$i = 0;
@ -162,7 +162,7 @@ class UserGroups
'DELETE FROM %s.%s WHERE `usergroup`=%s',
Util::backquote($configurableMenusFeature->database),
Util::backquote($configurableMenusFeature->users),
$dbi->quoteString($userGroupName, Connection::TYPE_CONTROL),
$dbi->quoteString($userGroupName, ConnectionType::ControlUser),
);
$dbi->queryAsControlUser($statement);
@ -170,7 +170,7 @@ class UserGroups
'DELETE FROM %s.%s WHERE `usergroup`=%s',
Util::backquote($configurableMenusFeature->database),
Util::backquote($configurableMenusFeature->userGroups),
$dbi->quoteString($userGroupName, Connection::TYPE_CONTROL),
$dbi->quoteString($userGroupName, ConnectionType::ControlUser),
);
$dbi->queryAsControlUser($statement);
}
@ -206,7 +206,7 @@ class UserGroups
. '.' . Util::backquote($configurableMenusFeature->userGroups);
$dbi = DatabaseInterface::getInstance();
$sqlQuery = 'SELECT * FROM ' . $groupTable
. ' WHERE `usergroup`=' . $dbi->quoteString($userGroup, Connection::TYPE_CONTROL);
. ' WHERE `usergroup`=' . $dbi->quoteString($userGroup, ConnectionType::ControlUser);
$result = $dbi->tryQueryAsControlUser($sqlQuery);
if ($result) {
foreach ($result as $row) {
@ -301,7 +301,7 @@ class UserGroups
$dbi = DatabaseInterface::getInstance();
if (! $new) {
$sqlQuery = 'DELETE FROM ' . $groupTable
. ' WHERE `usergroup`=' . $dbi->quoteString($userGroup, Connection::TYPE_CONTROL) . ';';
. ' WHERE `usergroup`=' . $dbi->quoteString($userGroup, ConnectionType::ControlUser) . ';';
$dbi->queryAsControlUser($sqlQuery);
}
@ -318,8 +318,8 @@ class UserGroups
$tabName = $tabGroupName . '_' . $tab;
$allowed = isset($_POST[$tabName]) && $_POST[$tabName] === 'Y';
$sqlQuery .= '(' . $dbi->quoteString($userGroup, Connection::TYPE_CONTROL)
. ', ' . $dbi->quoteString($tabName, Connection::TYPE_CONTROL) . ", '"
$sqlQuery .= '(' . $dbi->quoteString($userGroup, ConnectionType::ControlUser)
. ', ' . $dbi->quoteString($tabName, ConnectionType::ControlUser) . ", '"
. ($allowed ? 'Y' : 'N') . "')";
$first = false;
}

View File

@ -10,7 +10,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\Controllers\AbstractController;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\LanguageManager;
use PhpMyAdmin\Query\Utilities;
@ -95,7 +95,7 @@ class DatabasesController extends AbstractController
$this->databases = $this->dbi->getDatabasesFull(
null,
$this->hasStatistics,
Connection::TYPE_USER,
ConnectionType::User,
$this->sortBy,
$this->sortOrder,
$position,

View File

@ -10,7 +10,7 @@ use PhpMyAdmin\ConfigStorage\Features\ConfigurableMenusFeature;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Controllers\AbstractController;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Template;
@ -81,7 +81,7 @@ final class UserGroupsFormController extends AbstractController
$userTable,
$this->dbi->quoteString($username),
);
$userGroup = $this->dbi->fetchValue($sqlQuery, 0, Connection::TYPE_CONTROL);
$userGroup = $this->dbi->fetchValue($sqlQuery, 0, ConnectionType::ControlUser);
$allUserGroups = [];
$sqlQuery = 'SELECT DISTINCT `usergroup` FROM ' . $groupTable;

View File

@ -9,7 +9,7 @@ use PhpMyAdmin\ColumnFull;
use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Message;
use PhpMyAdmin\Template;
use PhpMyAdmin\Util;
@ -119,19 +119,19 @@ class CentralColumns
}
$pmadb = $cfgCentralColumns['db'];
$this->dbi->selectDb($pmadb, Connection::TYPE_CONTROL);
$this->dbi->selectDb($pmadb, ConnectionType::ControlUser);
$centralListTable = $cfgCentralColumns['table'];
//get current values of $db from central column list
if ($num == 0) {
$query = 'SELECT * FROM ' . Util::backquote($centralListTable) . ' '
. 'WHERE db_name = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL) . ';';
. 'WHERE db_name = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser) . ';';
} else {
$query = 'SELECT * FROM ' . Util::backquote($centralListTable) . ' '
. 'WHERE db_name = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL) . ' '
. 'WHERE db_name = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser) . ' '
. 'LIMIT ' . $from . ', ' . $num . ';';
}
$hasList = $this->dbi->fetchResult($query, null, null, Connection::TYPE_CONTROL);
$hasList = $this->dbi->fetchResult($query, null, null, ConnectionType::ControlUser);
$this->handleColumnExtra($hasList);
return $hasList;
@ -152,12 +152,12 @@ class CentralColumns
}
$pmadb = $cfgCentralColumns['db'];
$this->dbi->selectDb($pmadb, Connection::TYPE_CONTROL);
$this->dbi->selectDb($pmadb, ConnectionType::ControlUser);
$centralListTable = $cfgCentralColumns['table'];
$query = 'SELECT count(db_name) FROM '
. Util::backquote($centralListTable) . ' '
. 'WHERE db_name = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL) . ';';
$res = $this->dbi->fetchResult($query, null, null, Connection::TYPE_CONTROL);
. 'WHERE db_name = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser) . ';';
$res = $this->dbi->fetchResult($query, null, null, ConnectionType::ControlUser);
if (isset($res[0])) {
return (int) $res[0];
}
@ -188,18 +188,18 @@ class CentralColumns
$cols = $this->getWhereInColumns($cols);
$pmadb = $cfgCentralColumns['db'];
$this->dbi->selectDb($pmadb, Connection::TYPE_CONTROL);
$this->dbi->selectDb($pmadb, ConnectionType::ControlUser);
$centralListTable = $cfgCentralColumns['table'];
if ($allFields) {
$query = 'SELECT * FROM ' . Util::backquote($centralListTable) . ' WHERE db_name = '
. $this->dbi->quoteString($db, Connection::TYPE_CONTROL) . ' AND col_name IN (' . $cols . ');';
$hasList = $this->dbi->fetchResult($query, null, null, Connection::TYPE_CONTROL);
. $this->dbi->quoteString($db, ConnectionType::ControlUser) . ' AND col_name IN (' . $cols . ');';
$hasList = $this->dbi->fetchResult($query, null, null, ConnectionType::ControlUser);
$this->handleColumnExtra($hasList);
} else {
$query = 'SELECT col_name FROM '
. Util::backquote($centralListTable) . ' WHERE db_name = '
. $this->dbi->quoteString($db, Connection::TYPE_CONTROL) . ' AND col_name IN (' . $cols . ');';
$hasList = $this->dbi->fetchResult($query, null, null, Connection::TYPE_CONTROL);
. $this->dbi->quoteString($db, ConnectionType::ControlUser) . ' AND col_name IN (' . $cols . ');';
$hasList = $this->dbi->fetchResult($query, null, null, ConnectionType::ControlUser);
}
return $hasList;
@ -233,14 +233,14 @@ class CentralColumns
return 'INSERT INTO '
. Util::backquote($centralListTable) . ' '
. 'VALUES ( ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL) . ' ,'
. $this->dbi->quoteString($def->field, Connection::TYPE_CONTROL) . ','
. $this->dbi->quoteString($type, Connection::TYPE_CONTROL) . ','
. $this->dbi->quoteString((string) $length, Connection::TYPE_CONTROL) . ','
. $this->dbi->quoteString($collation, Connection::TYPE_CONTROL) . ','
. $this->dbi->quoteString($isNull, Connection::TYPE_CONTROL) . ','
. 'VALUES ( ' . $this->dbi->quoteString($db, ConnectionType::ControlUser) . ' ,'
. $this->dbi->quoteString($def->field, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($type, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString((string) $length, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($collation, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($isNull, ConnectionType::ControlUser) . ','
. '\'' . implode(',', [$extra, $attribute])
. '\',' . $this->dbi->quoteString($default, Connection::TYPE_CONTROL) . ');';
. '\',' . $this->dbi->quoteString($default, ConnectionType::ControlUser) . ');';
}
/**
@ -329,12 +329,12 @@ class CentralColumns
);
}
$this->dbi->selectDb($pmadb, Connection::TYPE_CONTROL);
$this->dbi->selectDb($pmadb, ConnectionType::ControlUser);
foreach ($insQuery as $query) {
if (! $this->dbi->tryQuery($query, Connection::TYPE_CONTROL)) {
if (! $this->dbi->tryQuery($query, ConnectionType::ControlUser)) {
$message = Message::error(__('Could not add columns!'));
$message->addMessage(
Message::rawError($this->dbi->getError(Connection::TYPE_CONTROL)),
Message::rawError($this->dbi->getError(ConnectionType::ControlUser)),
);
break;
}
@ -416,17 +416,17 @@ class CentralColumns
);
}
$this->dbi->selectDb($pmadb, Connection::TYPE_CONTROL);
$this->dbi->selectDb($pmadb, ConnectionType::ControlUser);
$cols = $this->getWhereInColumns($cols);
$query = 'DELETE FROM ' . Util::backquote($centralListTable) . ' WHERE db_name = '
. $this->dbi->quoteString($database, Connection::TYPE_CONTROL) . ' AND col_name IN (' . $cols . ');';
. $this->dbi->quoteString($database, ConnectionType::ControlUser) . ' AND col_name IN (' . $cols . ');';
if (! $this->dbi->tryQuery($query, Connection::TYPE_CONTROL)) {
if (! $this->dbi->tryQuery($query, ConnectionType::ControlUser)) {
$message = Message::error(__('Could not remove columns!'));
$message->addHtml('<br>' . htmlspecialchars($cols) . '<br>');
$message->addMessage(
Message::rawError($this->dbi->getError(Connection::TYPE_CONTROL)),
Message::rawError($this->dbi->getError(ConnectionType::ControlUser)),
);
}
@ -480,7 +480,7 @@ class CentralColumns
) {
$query .= ' DEFAULT ' . $this->dbi->quoteString(
(string) $column['col_default'],
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
);
} else {
$query .= ' DEFAULT ' . $column['col_default'];
@ -568,7 +568,7 @@ class CentralColumns
}
$centralTable = $cfgCentralColumns['table'];
$this->dbi->selectDb($cfgCentralColumns['db'], Connection::TYPE_CONTROL);
$this->dbi->selectDb($cfgCentralColumns['db'], ConnectionType::ControlUser);
if ($origColName == '') {
$def = new ColumnFull(
$colName,
@ -584,20 +584,20 @@ class CentralColumns
$query = $this->getInsertQuery($def, $db, $centralTable);
} else {
$query = 'UPDATE ' . Util::backquote($centralTable)
. ' SET col_type = ' . $this->dbi->quoteString($colType, Connection::TYPE_CONTROL)
. ', col_name = ' . $this->dbi->quoteString($colName, Connection::TYPE_CONTROL)
. ', col_length = ' . $this->dbi->quoteString($colLength, Connection::TYPE_CONTROL)
. ' SET col_type = ' . $this->dbi->quoteString($colType, ConnectionType::ControlUser)
. ', col_name = ' . $this->dbi->quoteString($colName, ConnectionType::ControlUser)
. ', col_length = ' . $this->dbi->quoteString($colLength, ConnectionType::ControlUser)
. ', col_isNull = ' . $colIsNull
. ', col_collation = ' . $this->dbi->quoteString($collation, Connection::TYPE_CONTROL)
. ', col_collation = ' . $this->dbi->quoteString($collation, ConnectionType::ControlUser)
. ', col_extra = \''
. implode(',', [$colExtra, $colAttribute]) . '\''
. ', col_default = ' . $this->dbi->quoteString($colDefault, Connection::TYPE_CONTROL)
. ' WHERE db_name = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL)
. ' AND col_name = ' . $this->dbi->quoteString($origColName, Connection::TYPE_CONTROL);
. ', col_default = ' . $this->dbi->quoteString($colDefault, ConnectionType::ControlUser)
. ' WHERE db_name = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser)
. ' AND col_name = ' . $this->dbi->quoteString($origColName, ConnectionType::ControlUser);
}
if (! $this->dbi->tryQuery($query, Connection::TYPE_CONTROL)) {
return Message::error($this->dbi->getError(Connection::TYPE_CONTROL));
if (! $this->dbi->tryQuery($query, ConnectionType::ControlUser)) {
return Message::error($this->dbi->getError(ConnectionType::ControlUser));
}
return true;
@ -719,12 +719,12 @@ class CentralColumns
$centralTable = $cfgCentralColumns['table'];
if ($table === '') {
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL) . ';';
. 'WHERE db_name = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser) . ';';
} else {
$this->dbi->selectDb($db);
$columns = $this->dbi->getColumnNames($db, $table);
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL);
. 'WHERE db_name = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser);
if ($columns !== []) {
$query .= ' AND col_name NOT IN (' . $this->getWhereInColumns($columns) . ')';
}
@ -732,8 +732,8 @@ class CentralColumns
$query .= ';';
}
$this->dbi->selectDb($cfgCentralColumns['db'], Connection::TYPE_CONTROL);
$columnsList = $this->dbi->fetchResult($query, null, null, Connection::TYPE_CONTROL);
$this->dbi->selectDb($cfgCentralColumns['db'], ConnectionType::ControlUser);
$columnsList = $this->dbi->fetchResult($query, null, null, ConnectionType::ControlUser);
$this->handleColumnExtra($columnsList);
return $columnsList;
@ -807,13 +807,13 @@ class CentralColumns
}
$pmadb = $cfgCentralColumns['db'];
$this->dbi->selectDb($pmadb, Connection::TYPE_CONTROL);
$this->dbi->selectDb($pmadb, ConnectionType::ControlUser);
$centralListTable = $cfgCentralColumns['table'];
//get current values of $db from central column list
$query = 'SELECT COUNT(db_name) FROM ' . Util::backquote($centralListTable) . ' '
. 'WHERE db_name = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL)
. 'WHERE db_name = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser)
. ($num === 0 ? '' : 'LIMIT ' . $from . ', ' . $num) . ';';
$result = $this->dbi->fetchResult($query, null, null, Connection::TYPE_CONTROL);
$result = $this->dbi->fetchResult($query, null, null, ConnectionType::ControlUser);
if (isset($result[0])) {
return (int) $result[0];
@ -937,7 +937,7 @@ class CentralColumns
private function getWhereInColumns(array $columns): string
{
return implode(',', array_map(
fn (string $string): string => $this->dbi->quoteString($string, Connection::TYPE_CONTROL),
fn (string $string): string => $this->dbi->quoteString($string, ConnectionType::ControlUser),
$columns,
));
}

View File

@ -8,7 +8,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Index;
use PhpMyAdmin\Query\Generator as QueryGenerator;
use PhpMyAdmin\Table\Table;
@ -245,7 +245,7 @@ class Common
. '.' . Util::backquote($pdfFeature->tableCoords) . '
WHERE pdf_page_number = ' . $pg;
return $this->dbi->fetchResult($query, 'name', null, Connection::TYPE_CONTROL);
return $this->dbi->fetchResult($query, 'name', null, ConnectionType::ControlUser);
}
/**
@ -266,7 +266,7 @@ class Common
. ' FROM ' . Util::backquote($pdfFeature->database)
. '.' . Util::backquote($pdfFeature->pdfPages)
. ' WHERE ' . Util::backquote('page_nr') . ' = ' . $pg;
$pageName = $this->dbi->fetchValue($query, 0, Connection::TYPE_CONTROL);
$pageName = $this->dbi->fetchValue($query, 0, ConnectionType::ControlUser);
return $pageName !== false ? $pageName : null;
}
@ -314,10 +314,10 @@ class Common
$query = 'SELECT `page_nr`'
. ' FROM ' . Util::backquote($pdfFeature->database)
. '.' . Util::backquote($pdfFeature->pdfPages)
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL)
. ' AND `page_descr` = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL);
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser)
. ' AND `page_descr` = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser);
$defaultPageNo = $this->dbi->fetchValue($query, 0, Connection::TYPE_CONTROL);
$defaultPageNo = $this->dbi->fetchValue($query, 0, ConnectionType::ControlUser);
return is_string($defaultPageNo) ? intval($defaultPageNo) : -1;
}
@ -338,8 +338,8 @@ class Common
$query = 'SELECT `page_nr`'
. ' FROM ' . Util::backquote($pdfFeature->database)
. '.' . Util::backquote($pdfFeature->pdfPages)
. ' WHERE `page_descr` = ' . $this->dbi->quoteString($pg, Connection::TYPE_CONTROL);
$pageNos = $this->dbi->fetchResult($query, null, null, Connection::TYPE_CONTROL);
. ' WHERE `page_descr` = ' . $this->dbi->quoteString($pg, ConnectionType::ControlUser);
$pageNos = $this->dbi->fetchResult($query, null, null, ConnectionType::ControlUser);
return $pageNos !== [];
}
@ -367,9 +367,9 @@ class Common
$query = 'SELECT MIN(`page_nr`)'
. ' FROM ' . Util::backquote($pdfFeature->database)
. '.' . Util::backquote($pdfFeature->pdfPages)
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL);
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser);
$minPageNo = $this->dbi->fetchValue($query, 0, Connection::TYPE_CONTROL);
$minPageNo = $this->dbi->fetchValue($query, 0, ConnectionType::ControlUser);
return is_string($minPageNo) ? intval($minPageNo) : -1;
}
@ -402,7 +402,7 @@ class Common
return false;
}
$pageId = $this->dbi->quoteString((string) $pg, Connection::TYPE_CONTROL);
$pageId = $this->dbi->quoteString((string) $pg, ConnectionType::ControlUser);
$query = 'DELETE FROM '
. Util::backquote($pdfFeature->database)
@ -423,11 +423,11 @@ class Common
. Util::backquote($pdfFeature->tableCoords)
. ' (`db_name`, `table_name`, `pdf_page_number`, `x`, `y`)'
. ' VALUES ('
. $this->dbi->quoteString($db, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($tab, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($db, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($tab, ConnectionType::ControlUser) . ', '
. $pageId . ', '
. $this->dbi->quoteString($_POST['t_x'][$key], Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($_POST['t_y'][$key], Connection::TYPE_CONTROL) . ')';
. $this->dbi->quoteString($_POST['t_x'][$key], ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($_POST['t_y'][$key], ConnectionType::ControlUser) . ')';
$this->dbi->queryAsControlUser($query);
}
@ -574,18 +574,18 @@ class Common
. '(master_db, master_table, master_field, '
. 'foreign_db, foreign_table, foreign_field)'
. ' values('
. $this->dbi->quoteString($db2, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($t2, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($f2, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($db1, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($t1, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($f1, Connection::TYPE_CONTROL) . ')';
. $this->dbi->quoteString($db2, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($t2, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($f2, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($db1, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($t1, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($f1, ConnectionType::ControlUser) . ')';
if ($this->dbi->tryQueryAsControlUser($q)) {
return [true, __('Internal relationship has been added.')];
}
$error = $this->dbi->getError(Connection::TYPE_CONTROL);
$error = $this->dbi->getError(ConnectionType::ControlUser);
return [false, __('Error: Internal relationship could not be added!') . '<br>' . $error];
}
@ -632,17 +632,17 @@ class Common
$deleteQuery = 'DELETE FROM '
. Util::backquote($relationFeature->database) . '.'
. Util::backquote($relationFeature->relation) . ' WHERE '
. 'master_db = ' . $this->dbi->quoteString($db2, Connection::TYPE_CONTROL)
. ' AND master_table = ' . $this->dbi->quoteString($t2, Connection::TYPE_CONTROL)
. ' AND master_field = ' . $this->dbi->quoteString($f2, Connection::TYPE_CONTROL)
. ' AND foreign_db = ' . $this->dbi->quoteString($db1, Connection::TYPE_CONTROL)
. ' AND foreign_table = ' . $this->dbi->quoteString($t1, Connection::TYPE_CONTROL)
. ' AND foreign_field = ' . $this->dbi->quoteString($f1, Connection::TYPE_CONTROL);
. 'master_db = ' . $this->dbi->quoteString($db2, ConnectionType::ControlUser)
. ' AND master_table = ' . $this->dbi->quoteString($t2, ConnectionType::ControlUser)
. ' AND master_field = ' . $this->dbi->quoteString($f2, ConnectionType::ControlUser)
. ' AND foreign_db = ' . $this->dbi->quoteString($db1, ConnectionType::ControlUser)
. ' AND foreign_table = ' . $this->dbi->quoteString($t1, ConnectionType::ControlUser)
. ' AND foreign_field = ' . $this->dbi->quoteString($f1, ConnectionType::ControlUser);
$result = $this->dbi->tryQueryAsControlUser($deleteQuery);
if (! $result) {
$error = $this->dbi->getError(Connection::TYPE_CONTROL);
$error = $this->dbi->getError(ConnectionType::ControlUser);
return [false, __('Error: Internal relationship could not be removed!') . '<br>' . $error];
}
@ -670,12 +670,12 @@ class Common
. ' FROM ' . Util::backquote($cfgDesigner['db'])
. '.' . Util::backquote($cfgDesigner['table'])
. ' WHERE username = '
. $this->dbi->quoteString($cfgDesigner['user'], Connection::TYPE_CONTROL) . ';';
. $this->dbi->quoteString($cfgDesigner['user'], ConnectionType::ControlUser) . ';';
$origData = $this->dbi->fetchSingleRow(
$origDataQuery,
DatabaseInterface::FETCH_ASSOC,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
);
if ($origData !== null && $origData !== []) {
@ -686,9 +686,9 @@ class Common
$saveQuery = 'UPDATE '
. Util::backquote($cfgDesigner['db'])
. '.' . Util::backquote($cfgDesigner['table'])
. ' SET settings_data = ' . $this->dbi->quoteString($origData, Connection::TYPE_CONTROL)
. ' SET settings_data = ' . $this->dbi->quoteString($origData, ConnectionType::ControlUser)
. ' WHERE username = '
. $this->dbi->quoteString($cfgDesigner['user'], Connection::TYPE_CONTROL) . ';';
. $this->dbi->quoteString($cfgDesigner['user'], ConnectionType::ControlUser) . ';';
$this->dbi->queryAsControlUser($saveQuery);
} else {
@ -698,8 +698,8 @@ class Common
. Util::backquote($cfgDesigner['db'])
. '.' . Util::backquote($cfgDesigner['table'])
. ' (username, settings_data)'
. ' VALUES(' . $this->dbi->quoteString($cfgDesigner['user'], Connection::TYPE_CONTROL)
. ', ' . $this->dbi->quoteString(json_encode($saveData), Connection::TYPE_CONTROL) . ');';
. ' VALUES(' . $this->dbi->quoteString($cfgDesigner['user'], ConnectionType::ControlUser)
. ', ' . $this->dbi->quoteString(json_encode($saveData), ConnectionType::ControlUser) . ');';
$this->dbi->queryAsControlUser($query);
}

View File

@ -7,6 +7,7 @@ namespace PhpMyAdmin;
use PhpMyAdmin\Config\Settings\Server;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionException;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Dbal\DbalInterface;
use PhpMyAdmin\Dbal\DbiExtension;
use PhpMyAdmin\Dbal\DbiMysqli;
@ -72,8 +73,6 @@ use const SORT_DESC;
/**
* Main interface for database interactions
*
* @psalm-import-type ConnectionType from Connection
*/
class DatabaseInterface implements DbalInterface
{
@ -103,7 +102,7 @@ class DatabaseInterface implements DbalInterface
* Opened database connections.
*
* @var array<int, Connection>
* @psalm-var array<ConnectionType, Connection>
* @psalm-var array<value-of<ConnectionType>, Connection>
*/
private array $connections = [];
@ -140,8 +139,8 @@ class DatabaseInterface implements DbalInterface
public function __construct(private DbiExtension $extension)
{
if (defined('TESTSUITE')) {
$this->connections[Connection::TYPE_USER] = new Connection(new stdClass());
$this->connections[Connection::TYPE_CONTROL] = new Connection(new stdClass());
$this->connections[ConnectionType::User->value] = new Connection(new stdClass());
$this->connections[ConnectionType::ControlUser->value] = new Connection(new stdClass());
}
$this->cache = new Cache();
@ -164,11 +163,10 @@ class DatabaseInterface implements DbalInterface
* @param string $query SQL query to execute
* @param int $options optional query options
* @param bool $cacheAffectedRows whether to cache affected rows
* @psalm-param ConnectionType $connectionType
*/
public function query(
string $query,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
int $options = self::QUERY_BUFFERED,
bool $cacheAffectedRows = true,
): ResultInterface {
@ -197,25 +195,24 @@ class DatabaseInterface implements DbalInterface
* is provided, it will instruct the extension
* to use unbuffered mode
* @param bool $cacheAffectedRows whether to cache affected row
* @psalm-param ConnectionType $connectionType
*/
public function tryQuery(
string $query,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
int $options = self::QUERY_BUFFERED,
bool $cacheAffectedRows = true,
): ResultInterface|false {
$config = Config::getInstance();
$debug = isset($config->settings['DBG']) && $config->settings['DBG']['sql'];
if (! isset($this->connections[$connectionType])) {
if (! isset($this->connections[$connectionType->value])) {
return false;
}
$time = microtime(true);
$result = $this->extension->realQuery($query, $this->connections[$connectionType], $options);
$result = $this->extension->realQuery($query, $this->connections[$connectionType->value], $options);
if ($connectionType === Connection::TYPE_USER) {
if ($connectionType === ConnectionType::User) {
$this->lastQueryExecutionTime = microtime(true) - $time;
}
@ -243,7 +240,7 @@ class DatabaseInterface implements DbalInterface
$this->lastQueryExecutionTime,
$this->getWarningCount($connectionType),
$cacheAffectedRows ? 'y' : 'n',
$connectionType,
$connectionType->value,
$query,
),
);
@ -262,17 +259,16 @@ class DatabaseInterface implements DbalInterface
* Send multiple SQL queries to the database server and execute the first one
*
* @param string $multiQuery multi query statement to execute
* @psalm-param ConnectionType $connectionType
*/
public function tryMultiQuery(
string $multiQuery = '',
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): bool {
if (! isset($this->connections[$connectionType])) {
if (! isset($this->connections[$connectionType->value])) {
return false;
}
return $this->extension->realMultiQuery($this->connections[$connectionType], $multiQuery);
return $this->extension->realMultiQuery($this->connections[$connectionType->value], $multiQuery);
}
/**
@ -289,7 +285,7 @@ class DatabaseInterface implements DbalInterface
// is called for tracking purposes but we want to display the correct number
// of rows affected by the original query, not by the query generated for
// tracking.
return $this->query($sql, Connection::TYPE_CONTROL, self::QUERY_BUFFERED, false);
return $this->query($sql, ConnectionType::ControlUser, self::QUERY_BUFFERED, false);
}
/**
@ -306,18 +302,17 @@ class DatabaseInterface implements DbalInterface
// is called for tracking purposes but we want to display the correct number
// of rows affected by the original query, not by the query generated for
// tracking.
return $this->tryQuery($sql, Connection::TYPE_CONTROL, self::QUERY_BUFFERED, false);
return $this->tryQuery($sql, ConnectionType::ControlUser, self::QUERY_BUFFERED, false);
}
/**
* returns array with table names for given db
*
* @param string $database name of database
* @psalm-param ConnectionType $connectionType
*
* @return array<int, string> tables names
*/
public function getTables(string $database, int $connectionType = Connection::TYPE_USER): array
public function getTables(string $database, ConnectionType $connectionType = ConnectionType::User): array
{
if ($database === '') {
return [];
@ -359,7 +354,6 @@ class DatabaseInterface implements DbalInterface
* @param string $sortBy table attribute to sort by
* @param string $sortOrder direction to sort (ASC or DESC)
* @param string|null $tableType whether table or view
* @psalm-param ConnectionType $connectionType
*
* @return (string|int|null)[][] list of tables in given db(s)
*
@ -374,7 +368,7 @@ class DatabaseInterface implements DbalInterface
string $sortBy = 'Name',
string $sortOrder = 'ASC',
string|null $tableType = null,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array {
$config = Config::getInstance();
if ($limitCount === true) {
@ -643,7 +637,6 @@ class DatabaseInterface implements DbalInterface
* @param string $sortOrder ASC or DESC
* @param int $limitOffset starting offset for LIMIT
* @param bool|int $limitCount row count for LIMIT or true for $cfg['MaxDbList']
* @psalm-param ConnectionType $connectionType
*
* @return mixed[]
*
@ -652,7 +645,7 @@ class DatabaseInterface implements DbalInterface
public function getDatabasesFull(
string|null $database = null,
bool $forceStats = false,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
string $sortBy = 'SCHEMA_NAME',
string $sortOrder = 'ASC',
int $limitOffset = 0,
@ -786,7 +779,6 @@ class DatabaseInterface implements DbalInterface
* @param string|null $database name of database
* @param string|null $table name of table to retrieve columns from
* @param string|null $column name of specific column
* @psalm-param ConnectionType $connectionType
*
* @return mixed[]
*/
@ -794,7 +786,7 @@ class DatabaseInterface implements DbalInterface
string|null $database = null,
string|null $table = null,
string|null $column = null,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array {
if (! Config::getInstance()->selectedServer['DisableIS']) {
$sql = QueryGenerator::getInformationSchemaColumnsFullRequest(
@ -849,7 +841,6 @@ class DatabaseInterface implements DbalInterface
* @param string $table name of table to retrieve columns from
* @param string $column name of column
* @param T $full whether to return full info or only column names
* @psalm-param ConnectionType $connectionType
*
* @psalm-return (T is true ? ColumnFull : Column)|null
*
@ -860,7 +851,7 @@ class DatabaseInterface implements DbalInterface
string $table,
string $column,
bool $full = false,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): ColumnFull|Column|null {
$sql = QueryGenerator::getColumnsSql(
$database,
@ -897,7 +888,6 @@ class DatabaseInterface implements DbalInterface
* @param string $database name of database
* @param string $table name of table to retrieve columns from
* @param T $full whether to return full info or only column names
* @psalm-param ConnectionType $connectionType
*
* @return ColumnFull[]|Column[]
* @psalm-return (T is true ? ColumnFull[] : Column[])
@ -908,7 +898,7 @@ class DatabaseInterface implements DbalInterface
string $database,
string $table,
bool $full = false,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array {
$sql = QueryGenerator::getColumnsSql($database, $table, null, $full);
/** @var (string|null)[][] $fields */
@ -1021,14 +1011,13 @@ class DatabaseInterface implements DbalInterface
*
* @param string $database name of database
* @param string $table name of table to retrieve columns from
* @psalm-param ConnectionType $connectionType
*
* @return string[]
*/
public function getColumnNames(
string $database,
string $table,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array {
$sql = QueryGenerator::getColumnsSql($database, $table);
@ -1041,7 +1030,6 @@ class DatabaseInterface implements DbalInterface
*
* @param string $database name of database
* @param string $table name of the table whose indexes are to be retrieved
* @psalm-param ConnectionType $connectionType
*
* @return array<int, array<string, string|null>>
* @psalm-return array<int, array{
@ -1066,7 +1054,7 @@ class DatabaseInterface implements DbalInterface
public function getTableIndexes(
string $database,
string $table,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array {
$sql = QueryGenerator::getTableIndexesSql($database, $table);
@ -1078,14 +1066,13 @@ class DatabaseInterface implements DbalInterface
*
* @param string $var mysql server variable name
* @param int $type DatabaseInterface::GETVAR_SESSION | DatabaseInterface::GETVAR_GLOBAL
* @psalm-param ConnectionType $connectionType
*
* @return false|string|null value for mysql server variable
*/
public function getVariable(
string $var,
int $type = self::GETVAR_SESSION,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): false|string|null {
$modifier = match ($type) {
self::GETVAR_SESSION => ' SESSION',
@ -1101,12 +1088,11 @@ class DatabaseInterface implements DbalInterface
*
* @param string $var variable name
* @param string $value value to set
* @psalm-param ConnectionType $connectionType
*/
public function setVariable(
string $var,
string $value,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): bool {
$currentValue = $this->getVariable($var, self::GETVAR_SESSION, $connectionType);
if ($currentValue == $value) {
@ -1221,14 +1207,13 @@ class DatabaseInterface implements DbalInterface
*
* @param string $query The query to execute
* @param int|string $field field to fetch the value from, starting at 0, with 0 being default
* @psalm-param ConnectionType $connectionType
*
* @return string|false|null value of first field in first row from result or false if not found
*/
public function fetchValue(
string $query,
int|string $field = 0,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): string|false|null {
$result = $this->tryQuery($query, $connectionType, self::QUERY_BUFFERED, false);
if ($result === false) {
@ -1251,12 +1236,11 @@ class DatabaseInterface implements DbalInterface
* @param string $query The query to execute
* @param string $type NUM|ASSOC|BOTH returned array should either numeric associative or both
* @psalm-param DatabaseInterface::FETCH_NUM|DatabaseInterface::FETCH_ASSOC $type
* @psalm-param ConnectionType $connectionType
*/
public function fetchSingleRow(
string $query,
string $type = DbalInterface::FETCH_ASSOC,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array|null {
$result = $this->tryQuery($query, $connectionType, self::QUERY_BUFFERED, false);
if ($result === false) {
@ -1338,7 +1322,6 @@ class DatabaseInterface implements DbalInterface
* used as key for array
* or array of those
* @param string|int|null $value value-name or offset used as value for array
* @psalm-param ConnectionType $connectionType
*
* @return mixed[] resultrows or values indexed by $key
*/
@ -1346,7 +1329,7 @@ class DatabaseInterface implements DbalInterface
string $query,
string|int|array|null $key = null,
string|int|null $value = null,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array {
$resultRows = [];
@ -1428,11 +1411,9 @@ class DatabaseInterface implements DbalInterface
/**
* returns warnings for last query
*
* @psalm-param ConnectionType $connectionType
*
* @return Warning[] warnings
*/
public function getWarnings(int $connectionType = Connection::TYPE_USER): array
public function getWarnings(ConnectionType $connectionType = ConnectionType::User): array
{
$result = $this->tryQuery('SHOW WARNINGS', $connectionType, 0, false);
if ($result === false) {
@ -1559,7 +1540,7 @@ class DatabaseInterface implements DbalInterface
public function isConnected(): bool
{
return isset($this->connections[Connection::TYPE_USER]);
return isset($this->connections[ConnectionType::User->value]);
}
/** @return string[] */
@ -1607,12 +1588,13 @@ class DatabaseInterface implements DbalInterface
/**
* Connects to the database server.
*
* @param int|null $target How to store connection link, defaults to $mode
* @psalm-param ConnectionType $connectionType
* @psalm-param ConnectionType|null $target
* @param ConnectionType|null $target How to store connection link, defaults to $connectionType
*/
public function connect(Server $currentServer, int $connectionType, int|null $target = null): Connection|null
{
public function connect(
Server $currentServer,
ConnectionType $connectionType,
ConnectionType|null $target = null,
): Connection|null {
$server = Config::getConnectionParams($currentServer, $connectionType);
$target ??= $connectionType;
@ -1631,16 +1613,16 @@ class DatabaseInterface implements DbalInterface
$errorHandler->setHideLocation(false);
if ($result !== null) {
$this->connections[$target] = $result;
$this->connections[$target->value] = $result;
/* Run post connect for user connections */
if ($target === Connection::TYPE_USER) {
if ($target === ConnectionType::User) {
$this->postConnect($currentServer);
}
return $result;
}
if ($connectionType === Connection::TYPE_CONTROL) {
if ($connectionType === ConnectionType::ControlUser) {
trigger_error(
__(
'Connection for controluser as defined in your configuration failed.',
@ -1656,66 +1638,59 @@ class DatabaseInterface implements DbalInterface
* selects given database
*
* @param string|DatabaseName $dbname database name to select
* @psalm-param ConnectionType $connectionType
*/
public function selectDb(string|DatabaseName $dbname, int $connectionType = Connection::TYPE_USER): bool
public function selectDb(string|DatabaseName $dbname, ConnectionType $connectionType = ConnectionType::User): bool
{
if (! isset($this->connections[$connectionType])) {
if (! isset($this->connections[$connectionType->value])) {
return false;
}
return $this->extension->selectDb($dbname, $this->connections[$connectionType]);
return $this->extension->selectDb($dbname, $this->connections[$connectionType->value]);
}
/**
* Prepare next result from multi_query
*
* @psalm-param ConnectionType $connectionType
*/
public function nextResult(int $connectionType = Connection::TYPE_USER): ResultInterface|false
public function nextResult(ConnectionType $connectionType = ConnectionType::User): ResultInterface|false
{
if (! isset($this->connections[$connectionType])) {
if (! isset($this->connections[$connectionType->value])) {
return false;
}
// TODO: Figure out if we really need to check the return value of this function.
if (! $this->extension->nextResult($this->connections[$connectionType])) {
if (! $this->extension->nextResult($this->connections[$connectionType->value])) {
return false;
}
return $this->extension->storeResult($this->connections[$connectionType]);
return $this->extension->storeResult($this->connections[$connectionType->value]);
}
/**
* Returns a string representing the type of connection used
*
* @psalm-param ConnectionType $connectionType
*
* @return string|bool type of connection used
*/
public function getHostInfo(int $connectionType = Connection::TYPE_USER): string|bool
public function getHostInfo(ConnectionType $connectionType = ConnectionType::User): string|bool
{
if (! isset($this->connections[$connectionType])) {
if (! isset($this->connections[$connectionType->value])) {
return false;
}
return $this->extension->getHostInfo($this->connections[$connectionType]);
return $this->extension->getHostInfo($this->connections[$connectionType->value]);
}
/**
* Returns the version of the MySQL protocol used
*
* @psalm-param ConnectionType $connectionType
*
* @return int|bool version of the MySQL protocol used
*/
public function getProtoInfo(int $connectionType = Connection::TYPE_USER): int|bool
public function getProtoInfo(ConnectionType $connectionType = ConnectionType::User): int|bool
{
if (! isset($this->connections[$connectionType])) {
if (! isset($this->connections[$connectionType->value])) {
return false;
}
return $this->extension->getProtoInfo($this->connections[$connectionType]);
return $this->extension->getProtoInfo($this->connections[$connectionType->value]);
}
/**
@ -1730,16 +1705,14 @@ class DatabaseInterface implements DbalInterface
/**
* Returns last error message or an empty string if no errors occurred.
*
* @psalm-param ConnectionType $connectionType
*/
public function getError(int $connectionType = Connection::TYPE_USER): string
public function getError(ConnectionType $connectionType = ConnectionType::User): string
{
if (! isset($this->connections[$connectionType])) {
if (! isset($this->connections[$connectionType->value])) {
return '';
}
return $this->extension->getError($this->connections[$connectionType]);
return $this->extension->getError($this->connections[$connectionType->value]);
}
/**
@ -1764,10 +1737,8 @@ class DatabaseInterface implements DbalInterface
/**
* returns last inserted auto_increment id for given $link
* or $GLOBALS['userlink']
*
* @psalm-param ConnectionType $connectionType
*/
public function insertId(int $connectionType = Connection::TYPE_USER): int
public function insertId(ConnectionType $connectionType = ConnectionType::User): int
{
// If the primary key is BIGINT we get an incorrect result
// (sometimes negative, sometimes positive)
@ -1784,15 +1755,14 @@ class DatabaseInterface implements DbalInterface
* returns the number of rows affected by last query
*
* @param bool $getFromCache whether to retrieve from cache
* @psalm-param ConnectionType $connectionType
*
* @psalm-return int|numeric-string
*/
public function affectedRows(
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
bool $getFromCache = true,
): int|string {
if (! isset($this->connections[$connectionType])) {
if (! isset($this->connections[$connectionType->value])) {
return -1;
}
@ -1800,7 +1770,7 @@ class DatabaseInterface implements DbalInterface
return $GLOBALS['cached_affected_rows'];
}
return $this->extension->affectedRows($this->connections[$connectionType]);
return $this->extension->affectedRows($this->connections[$connectionType->value]);
}
/**
@ -1841,15 +1811,14 @@ class DatabaseInterface implements DbalInterface
* Returns properly quoted string for use in MySQL queries.
*
* @param string $str string to be quoted
* @psalm-param ConnectionType $connectionType
*
* @psalm-return non-empty-string
*
* @psalm-taint-escape sql
*/
public function quoteString(string $str, int $connectionType = Connection::TYPE_USER): string
public function quoteString(string $str, ConnectionType $connectionType = ConnectionType::User): string
{
return "'" . $this->extension->escapeString($this->connections[$connectionType], $str) . "'";
return "'" . $this->extension->escapeString($this->connections[$connectionType->value], $str) . "'";
}
/**
@ -2018,11 +1987,10 @@ class DatabaseInterface implements DbalInterface
* Prepare an SQL statement for execution.
*
* @param string $query The query, as a string.
* @psalm-param ConnectionType $connectionType
*/
public function prepare(string $query, int $connectionType = Connection::TYPE_USER): Statement|null
public function prepare(string $query, ConnectionType $connectionType = ConnectionType::User): Statement|null
{
return $this->extension->prepare($this->connections[$connectionType], $query);
return $this->extension->prepare($this->connections[$connectionType->value], $query);
}
public function getDatabaseList(): ListDatabase
@ -2036,15 +2004,13 @@ class DatabaseInterface implements DbalInterface
/**
* Returns the number of warnings from the last query.
*
* @psalm-param ConnectionType $connectionType
*/
private function getWarningCount(int $connectionType): int
private function getWarningCount(ConnectionType $connectionType): int
{
if (! isset($this->connections[$connectionType])) {
if (! isset($this->connections[$connectionType->value])) {
return 0;
}
return $this->extension->getWarningCount($this->connections[$connectionType]);
return $this->extension->getWarningCount($this->connections[$connectionType->value]);
}
}

View File

@ -4,21 +4,9 @@ declare(strict_types=1);
namespace PhpMyAdmin\Dbal;
/**
* @psalm-immutable
* @psalm-type ConnectionType = Connection::TYPE_USER|Connection::TYPE_CONTROL|Connection::TYPE_AUXILIARY
*/
/** @psalm-immutable */
final class Connection
{
/** User connection. */
public const TYPE_USER = 0;
/** Control user connection. */
public const TYPE_CONTROL = 1;
/** Auxiliary connection. Used for example for replication setup. */
public const TYPE_AUXILIARY = 2;
public function __construct(public object $connection)
{
}

View File

@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Dbal;
enum ConnectionType: int
{
/** User connection. */
case User = 0;
/** Control user connection. */
case ControlUser = 1;
/** Auxiliary connection. Used for example for replication setup. */
case Auxiliary = 2;
}

View File

@ -15,8 +15,6 @@ use PhpMyAdmin\Table\Table;
/**
* Main interface for database interactions
*
* @psalm-import-type ConnectionType from Connection
*/
interface DbalInterface
{
@ -29,11 +27,10 @@ interface DbalInterface
* @param string $query SQL query to execute
* @param int $options optional query options
* @param bool $cacheAffectedRows whether to cache affected rows
* @psalm-param ConnectionType $connectionType
*/
public function query(
string $query,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
int $options = 0,
bool $cacheAffectedRows = true,
): ResultInterface;
@ -44,11 +41,10 @@ interface DbalInterface
* @param string $query query to run
* @param int $options query options
* @param bool $cacheAffectedRows whether to cache affected row
* @psalm-param ConnectionType $connectionType
*/
public function tryQuery(
string $query,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
int $options = 0,
bool $cacheAffectedRows = true,
): mixed;
@ -57,22 +53,20 @@ interface DbalInterface
* Send multiple SQL queries to the database server and execute the first one
*
* @param string $multiQuery multi query statement to execute
* @psalm-param ConnectionType $connectionType
*/
public function tryMultiQuery(
string $multiQuery = '',
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): bool;
/**
* returns array with table names for given db
*
* @param string $database name of database
* @psalm-param ConnectionType $connectionType
*
* @return array<int, string> tables names
*/
public function getTables(string $database, int $connectionType = Connection::TYPE_USER): array;
public function getTables(string $database, ConnectionType $connectionType = ConnectionType::User): array;
/**
* returns array of all tables in given db or dbs
@ -96,7 +90,6 @@ interface DbalInterface
* @param string $sortBy table attribute to sort by
* @param string $sortOrder direction to sort (ASC or DESC)
* @param string|null $tableType whether table or view
* @psalm-param ConnectionType $connectionType
*
* @return mixed[] list of tables in given db(s)
*
@ -111,7 +104,7 @@ interface DbalInterface
string $sortBy = 'Name',
string $sortOrder = 'ASC',
string|null $tableType = null,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array;
/**
@ -132,7 +125,6 @@ interface DbalInterface
* @param string $sortOrder ASC or DESC
* @param int $limitOffset starting offset for LIMIT
* @param bool|int $limitCount row count for LIMIT or true for $cfg['MaxDbList']
* @psalm-param ConnectionType $connectionType
*
* @return mixed[]
*
@ -141,7 +133,7 @@ interface DbalInterface
public function getDatabasesFull(
string|null $database = null,
bool $forceStats = false,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
string $sortBy = 'SCHEMA_NAME',
string $sortOrder = 'ASC',
int $limitOffset = 0,
@ -155,7 +147,6 @@ interface DbalInterface
* @param string|null $database name of database
* @param string|null $table name of table to retrieve columns from
* @param string|null $column name of specific column
* @psalm-param ConnectionType $connectionType
*
* @return mixed[]
*/
@ -163,7 +154,7 @@ interface DbalInterface
string|null $database = null,
string|null $table = null,
string|null $column = null,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array;
/**
@ -173,7 +164,6 @@ interface DbalInterface
* @param string $table name of table to retrieve columns from
* @param string $column name of column
* @param T $full whether to return full info or only column names
* @psalm-param ConnectionType $connectionType
*
* @psalm-return (T is true ? ColumnFull : Column)|null
*
@ -184,7 +174,7 @@ interface DbalInterface
string $table,
string $column,
bool $full = false,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): ColumnFull|Column|null;
/**
@ -193,7 +183,6 @@ interface DbalInterface
* @param string $database name of database
* @param string $table name of table to retrieve columns from
* @param T $full whether to return full info or only column names
* @psalm-param ConnectionType $connectionType
*
* @return ColumnFull[]|Column[]
* @psalm-return (T is true ? ColumnFull[] : Column[])
@ -204,7 +193,7 @@ interface DbalInterface
string $database,
string $table,
bool $full = false,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array;
/**
@ -212,14 +201,13 @@ interface DbalInterface
*
* @param string $database name of database
* @param string $table name of table to retrieve columns from
* @psalm-param ConnectionType $connectionType
*
* @return string[]
*/
public function getColumnNames(
string $database,
string $table,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array;
/**
@ -227,7 +215,6 @@ interface DbalInterface
*
* @param string $database name of database
* @param string $table name of the table whose indexes are to be retrieved
* @psalm-param ConnectionType $connectionType
*
* @return array<int, array<string, string|null>>
* @psalm-return array<int, array{
@ -252,7 +239,7 @@ interface DbalInterface
public function getTableIndexes(
string $database,
string $table,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array;
/**
@ -260,14 +247,13 @@ interface DbalInterface
*
* @param string $var mysql server variable name
* @param int $type DatabaseInterface::GETVAR_SESSION | DatabaseInterface::GETVAR_GLOBAL
* @psalm-param ConnectionType $connectionType
*
* @return false|string|null value for mysql server variable
*/
public function getVariable(
string $var,
int $type = DatabaseInterface::GETVAR_SESSION,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): false|string|null;
/**
@ -275,12 +261,11 @@ interface DbalInterface
*
* @param string $var variable name
* @param string $value value to set
* @psalm-param ConnectionType $connectionType
*/
public function setVariable(
string $var,
string $value,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): bool;
/**
@ -311,7 +296,6 @@ interface DbalInterface
*
* @param string $query The query to execute
* @param int|string $field field to fetch the value from, starting at 0, with 0 being default
* @psalm-param ConnectionType $connectionType
*
* @return string|false|null value of first field in first row from result
* or false if not found
@ -319,7 +303,7 @@ interface DbalInterface
public function fetchValue(
string $query,
int|string $field = 0,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): string|false|null;
/**
@ -335,12 +319,11 @@ interface DbalInterface
* @param string $query The query to execute
* @param string $type NUM|ASSOC returned array should either numeric associative or both
* @psalm-param self::FETCH_NUM|self::FETCH_ASSOC $type
* @psalm-param ConnectionType $connectionType
*/
public function fetchSingleRow(
string $query,
string $type = DbalInterface::FETCH_ASSOC,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array|null;
/**
@ -388,7 +371,6 @@ interface DbalInterface
* @param string $query query to execute
* @param string|int|mixed[]|null $key field-name or offset used as key for array or array of those
* @param string|int|null $value value-name or offset used as value for array
* @psalm-param ConnectionType $connectionType
*
* @return mixed[] resultrows or values indexed by $key
*/
@ -396,7 +378,7 @@ interface DbalInterface
string $query,
string|int|array|null $key = null,
string|int|null $value = null,
int $connectionType = Connection::TYPE_USER,
ConnectionType $connectionType = ConnectionType::User,
): array;
/**
@ -409,11 +391,9 @@ interface DbalInterface
/**
* returns warnings for last query
*
* @psalm-param ConnectionType $connectionType
*
* @return mixed[] warnings
*/
public function getWarnings(int $connectionType = Connection::TYPE_USER): array;
public function getWarnings(ConnectionType $connectionType = ConnectionType::User): array;
/**
* gets the current user with host
@ -453,44 +433,39 @@ interface DbalInterface
/**
* Connects to the database server.
*
* @param int|null $target How to store connection link, defaults to $mode
* @psalm-param ConnectionType $connectionType
* @psalm-param ConnectionType|null $target
* @param ConnectionType|null $target How to store connection link, defaults to $connectionType
*/
public function connect(Server $currentServer, int $connectionType, int|null $target = null): Connection|null;
public function connect(
Server $currentServer,
ConnectionType $connectionType,
ConnectionType|null $target = null,
): Connection|null;
/**
* selects given database
*
* @param string|DatabaseName $dbname database name to select
* @psalm-param ConnectionType $connectionType
*/
public function selectDb(string|DatabaseName $dbname, int $connectionType = Connection::TYPE_USER): bool;
public function selectDb(string|DatabaseName $dbname, ConnectionType $connectionType = ConnectionType::User): bool;
/**
* Prepare next result from multi_query
*
* @psalm-param ConnectionType $connectionType
*/
public function nextResult(int $connectionType = Connection::TYPE_USER): ResultInterface|false;
public function nextResult(ConnectionType $connectionType = ConnectionType::User): ResultInterface|false;
/**
* Returns a string representing the type of connection used
*
* @psalm-param ConnectionType $connectionType
*
* @return string|bool type of connection used
*/
public function getHostInfo(int $connectionType = Connection::TYPE_USER): string|bool;
public function getHostInfo(ConnectionType $connectionType = ConnectionType::User): string|bool;
/**
* Returns the version of the MySQL protocol used
*
* @psalm-param ConnectionType $connectionType
*
* @return int|bool version of the MySQL protocol used
*/
public function getProtoInfo(int $connectionType = Connection::TYPE_USER): int|bool;
public function getProtoInfo(ConnectionType $connectionType = ConnectionType::User): int|bool;
/**
* returns a string that represents the client library version
@ -501,10 +476,8 @@ interface DbalInterface
/**
* Returns last error message or an empty string if no errors occurred.
*
* @psalm-param ConnectionType $connectionType
*/
public function getError(int $connectionType = Connection::TYPE_USER): string;
public function getError(ConnectionType $connectionType = ConnectionType::User): string;
/**
* returns the number of rows returned by last query
@ -519,20 +492,20 @@ interface DbalInterface
/**
* returns last inserted auto_increment id for given $link
* or $GLOBALS['userlink']
*
* @psalm-param ConnectionType $connectionType
*/
public function insertId(int $connectionType = Connection::TYPE_USER): int;
public function insertId(ConnectionType $connectionType = ConnectionType::User): int;
/**
* returns the number of rows affected by last query
*
* @param bool $getFromCache whether to retrieve from cache
* @psalm-param ConnectionType $connectionType
*
* @psalm-return int|numeric-string
*/
public function affectedRows(int $connectionType = Connection::TYPE_USER, bool $getFromCache = true): int|string;
public function affectedRows(
ConnectionType $connectionType = ConnectionType::User,
bool $getFromCache = true,
): int|string;
/**
* returns metainfo for fields in $result
@ -547,13 +520,12 @@ interface DbalInterface
* Returns properly quoted string for use in MySQL queries.
*
* @param string $str string to be quoted
* @psalm-param ConnectionType $connectionType
*
* @psalm-return non-empty-string
*
* @psalm-taint-escape sql
*/
public function quoteString(string $str, int $connectionType = Connection::TYPE_USER): string;
public function quoteString(string $str, ConnectionType $connectionType = ConnectionType::User): string;
/**
* Returns properly escaped string for use in MySQL LIKE clauses.
@ -633,7 +605,6 @@ interface DbalInterface
* Prepare an SQL statement for execution.
*
* @param string $query The query, as a string.
* @psalm-param ConnectionType $connectionType
*/
public function prepare(string $query, int $connectionType = Connection::TYPE_USER): Statement|null;
public function prepare(string $query, ConnectionType $connectionType = ConnectionType::User): Statement|null;
}

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Util;
@ -25,17 +25,17 @@ final class TemplateModel
. ' VALUES (%s, %s, %s, %s);',
Util::backquote($db),
Util::backquote($table),
$this->dbi->quoteString($template->getUsername(), Connection::TYPE_CONTROL),
$this->dbi->quoteString($template->getExportType(), Connection::TYPE_CONTROL),
$this->dbi->quoteString($template->getName(), Connection::TYPE_CONTROL),
$this->dbi->quoteString($template->getData(), Connection::TYPE_CONTROL),
$this->dbi->quoteString($template->getUsername(), ConnectionType::ControlUser),
$this->dbi->quoteString($template->getExportType(), ConnectionType::ControlUser),
$this->dbi->quoteString($template->getName(), ConnectionType::ControlUser),
$this->dbi->quoteString($template->getData(), ConnectionType::ControlUser),
);
$result = $this->dbi->tryQueryAsControlUser($query);
if ($result !== false) {
return '';
}
return $this->dbi->getError(Connection::TYPE_CONTROL);
return $this->dbi->getError(ConnectionType::ControlUser);
}
public function delete(DatabaseName $db, TableName $table, string $user, int $id): string
@ -45,14 +45,14 @@ final class TemplateModel
Util::backquote($db),
Util::backquote($table),
$id,
$this->dbi->quoteString($user, Connection::TYPE_CONTROL),
$this->dbi->quoteString($user, ConnectionType::ControlUser),
);
$result = $this->dbi->tryQueryAsControlUser($query);
if ($result !== false) {
return '';
}
return $this->dbi->getError(Connection::TYPE_CONTROL);
return $this->dbi->getError(ConnectionType::ControlUser);
}
public function load(DatabaseName $db, TableName $table, string $user, int $id): Template|string
@ -62,11 +62,11 @@ final class TemplateModel
Util::backquote($db),
Util::backquote($table),
$id,
$this->dbi->quoteString($user, Connection::TYPE_CONTROL),
$this->dbi->quoteString($user, ConnectionType::ControlUser),
);
$result = $this->dbi->tryQueryAsControlUser($query);
if ($result === false) {
return $this->dbi->getError(Connection::TYPE_CONTROL);
return $this->dbi->getError(ConnectionType::ControlUser);
}
$data = [];
@ -89,16 +89,16 @@ final class TemplateModel
'UPDATE %s.%s SET `template_data` = %s WHERE `id` = %d AND `username` = %s;',
Util::backquote($db),
Util::backquote($table),
$this->dbi->quoteString($template->getData(), Connection::TYPE_CONTROL),
$this->dbi->quoteString($template->getData(), ConnectionType::ControlUser),
$template->getId(),
$this->dbi->quoteString($template->getUsername(), Connection::TYPE_CONTROL),
$this->dbi->quoteString($template->getUsername(), ConnectionType::ControlUser),
);
$result = $this->dbi->tryQueryAsControlUser($query);
if ($result !== false) {
return '';
}
return $this->dbi->getError(Connection::TYPE_CONTROL);
return $this->dbi->getError(ConnectionType::ControlUser);
}
/** @return Template[]|string */
@ -108,12 +108,12 @@ final class TemplateModel
'SELECT * FROM %s.%s WHERE `username` = %s AND `export_type` = %s ORDER BY `template_name`;',
Util::backquote($db),
Util::backquote($table),
$this->dbi->quoteString($user, Connection::TYPE_CONTROL),
$this->dbi->quoteString($exportType, Connection::TYPE_CONTROL),
$this->dbi->quoteString($user, ConnectionType::ControlUser),
$this->dbi->quoteString($exportType, ConnectionType::ControlUser),
);
$result = $this->dbi->tryQueryAsControlUser($query);
if ($result === false) {
return $this->dbi->getError(Connection::TYPE_CONTROL);
return $this->dbi->getError(ConnectionType::ControlUser);
}
$templates = [];

View File

@ -11,7 +11,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\DbTableExists;
use PhpMyAdmin\Message;
use PhpMyAdmin\Template;
@ -124,7 +124,7 @@ class RecentFavoriteTables
// Read from phpMyAdmin database, if recent tables is not in session
$sqlQuery = 'SELECT `tables` FROM ' . $this->getPmaTable()
. ' WHERE `username` = '
. $this->dbi->quoteString(Config::getInstance()->selectedServer['user'], Connection::TYPE_CONTROL);
. $this->dbi->quoteString(Config::getInstance()->selectedServer['user'], ConnectionType::ControlUser);
$result = $this->dbi->tryQueryAsControlUser($sqlQuery);
if ($result !== false) {
@ -149,7 +149,7 @@ class RecentFavoriteTables
. ' VALUES (' . $this->dbi->quoteString($username) . ', '
. $this->dbi->quoteString(json_encode($this->tables)) . ')';
$success = $this->dbi->tryQuery($sqlQuery, Connection::TYPE_CONTROL);
$success = $this->dbi->tryQuery($sqlQuery, ConnectionType::ControlUser);
if ($success === false) {
$message = Message::error(match ($this->tableType) {
@ -158,7 +158,7 @@ class RecentFavoriteTables
});
$message->addMessage(
Message::rawError($this->dbi->getError(Connection::TYPE_CONTROL)),
Message::rawError($this->dbi->getError(ConnectionType::ControlUser)),
'<br><br>',
);

View File

@ -10,7 +10,7 @@ use PhpMyAdmin\Config\Settings\Server;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Container\ContainerBuilder;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Exceptions\AuthenticationPluginException;
use PhpMyAdmin\Exceptions\ExitException;
use PhpMyAdmin\Http\Factory\ResponseFactory;
@ -105,11 +105,11 @@ final class Authentication implements MiddlewareInterface
*/
$controlConnection = null;
if ($currentServer->controlUser !== '') {
$controlConnection = $dbi->connect($currentServer, Connection::TYPE_CONTROL);
$controlConnection = $dbi->connect($currentServer, ConnectionType::ControlUser);
}
// Connects to the server (validates user's login)
$userConnection = $dbi->connect($currentServer, Connection::TYPE_USER);
$userConnection = $dbi->connect($currentServer, ConnectionType::User);
if ($userConnection === null) {
$auth->showFailure('mysql-denied');
}
@ -122,6 +122,6 @@ final class Authentication implements MiddlewareInterface
* Open separate connection for control queries, this is needed to avoid problems with table locking used in
* main connection and phpMyAdmin issuing queries to configuration storage, which is not locked by that time.
*/
$dbi->connect($currentServer, Connection::TYPE_USER, Connection::TYPE_CONTROL);
$dbi->connect($currentServer, ConnectionType::User, ConnectionType::ControlUser);
}
}

View File

@ -8,7 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Query\Utilities;
use PhpMyAdmin\Routing\Routing;
use PhpMyAdmin\Tracking\Tracker;
@ -117,7 +117,7 @@ class Menu
. " AND `tab` LIKE '" . $level . "%'"
. ' AND `usergroup` = (SELECT usergroup FROM '
. $userTable . ' WHERE `username` = '
. $this->dbi->quoteString($config->selectedServer['user'], Connection::TYPE_CONTROL) . ')';
. $this->dbi->quoteString($config->selectedServer['user'], ConnectionType::ControlUser) . ')';
$result = $this->dbi->tryQueryAsControlUser($sqlQuery);
if ($result) {

View File

@ -14,7 +14,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Container\ContainerBuilder;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Sanitize;
use PhpMyAdmin\Server\Select;
@ -154,10 +154,10 @@ class Navigation
$sqlQuery = 'INSERT INTO ' . $navTable
. '(`username`, `item_name`, `item_type`, `db_name`, `table_name`)'
. ' VALUES ('
. $this->dbi->quoteString(Config::getInstance()->selectedServer['user'], Connection::TYPE_CONTROL) . ','
. $this->dbi->quoteString($itemName, Connection::TYPE_CONTROL) . ','
. $this->dbi->quoteString($itemType, Connection::TYPE_CONTROL) . ','
. $this->dbi->quoteString($dbName, Connection::TYPE_CONTROL) . ','
. $this->dbi->quoteString(Config::getInstance()->selectedServer['user'], ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($itemName, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($itemType, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($dbName, ConnectionType::ControlUser) . ','
. "'')";
$this->dbi->tryQueryAsControlUser($sqlQuery);
}
@ -185,10 +185,10 @@ class Navigation
$sqlQuery = 'DELETE FROM ' . $navTable
. ' WHERE'
. ' `username`='
. $this->dbi->quoteString(Config::getInstance()->selectedServer['user'], Connection::TYPE_CONTROL)
. ' AND `item_name`=' . $this->dbi->quoteString($itemName, Connection::TYPE_CONTROL)
. ' AND `item_type`=' . $this->dbi->quoteString($itemType, Connection::TYPE_CONTROL)
. ' AND `db_name`=' . $this->dbi->quoteString($dbName, Connection::TYPE_CONTROL);
. $this->dbi->quoteString(Config::getInstance()->selectedServer['user'], ConnectionType::ControlUser)
. ' AND `item_name`=' . $this->dbi->quoteString($itemName, ConnectionType::ControlUser)
. ' AND `item_type`=' . $this->dbi->quoteString($itemType, ConnectionType::ControlUser)
. ' AND `db_name`=' . $this->dbi->quoteString($dbName, ConnectionType::ControlUser);
$this->dbi->tryQueryAsControlUser($sqlQuery);
}
@ -231,8 +231,8 @@ class Navigation
. '.' . Util::backquote($navigationItemsHidingFeature->navigationHiding);
$sqlQuery = 'SELECT `item_name`, `item_type` FROM ' . $navTable
. ' WHERE `username`='
. $this->dbi->quoteString(Config::getInstance()->selectedServer['user'], Connection::TYPE_CONTROL)
. ' AND `db_name`=' . $this->dbi->quoteString($database, Connection::TYPE_CONTROL)
. $this->dbi->quoteString(Config::getInstance()->selectedServer['user'], ConnectionType::ControlUser)
. ' AND `db_name`=' . $this->dbi->quoteString($database, ConnectionType::ControlUser)
. " AND `table_name`=''";
$result = $this->dbi->tryQueryAsControlUser($sqlQuery);

View File

@ -11,7 +11,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Features\NavigationItemsHidingFeature;
use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Navigation\NodeType;
use PhpMyAdmin\UserPrivileges;
@ -631,7 +631,7 @@ class Node
. $dbi->quoteString(Config::getInstance()->selectedServer['user'])
. ' GROUP BY `db_name`';
return $dbi->fetchResult($sqlQuery, 'db_name', 'count', Connection::TYPE_CONTROL);
return $dbi->fetchResult($sqlQuery, 'db_name', 'count', ConnectionType::ControlUser);
}
return null;

View File

@ -11,7 +11,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Features\NavigationItemsHidingFeature;
use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Dbal\ResultInterface;
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Url;
@ -306,11 +306,11 @@ class NodeDatabase extends Node
$dbi = DatabaseInterface::getInstance();
$sqlQuery = 'SELECT `item_name` FROM ' . $navTable
. ' WHERE `username`='
. $dbi->quoteString($relationParameters->user, Connection::TYPE_CONTROL)
. $dbi->quoteString($relationParameters->user, ConnectionType::ControlUser)
. ' AND `item_type`='
. $dbi->quoteString($type, Connection::TYPE_CONTROL)
. $dbi->quoteString($type, ConnectionType::ControlUser)
. ' AND `db_name`='
. $dbi->quoteString($this->realName, Connection::TYPE_CONTROL);
. $dbi->quoteString($this->realName, ConnectionType::ControlUser);
$result = $dbi->tryQueryAsControlUser($sqlQuery);
$hiddenItems = [];
if ($result instanceof ResultInterface) {

View File

@ -8,7 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
@ -213,7 +213,7 @@ class ExportCsv extends ExportPlugin
/**
* Gets the data from the database
*/
$result = $dbi->query($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
// If required, get fields name at the first line
if (isset($GLOBALS['csv_columns']) && $GLOBALS['csv_columns']) {

View File

@ -9,7 +9,7 @@ namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\Column;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
@ -201,7 +201,7 @@ class ExportHtmlword extends ExportPlugin
/**
* Gets the data from the database
*/
$result = $dbi->query($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
// If required, get fields name at the first line
if (isset($GLOBALS['htmlword_columns'])) {

View File

@ -8,7 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\FieldMetadata;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -233,7 +233,7 @@ class ExportJson extends ExportPlugin
return false;
}
$result = $dbi->query($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$columnsCnt = $result->numFields();
$fieldsMeta = $dbi->getFieldsMeta($result);

View File

@ -9,7 +9,7 @@ namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\Config;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
@ -287,7 +287,7 @@ class ExportLatex extends ExportPlugin
$this->initAlias($aliases, $dbAlias, $tableAlias);
$dbi = DatabaseInterface::getInstance();
$result = $dbi->tryQuery($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->tryQuery($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$columnsCnt = $result->numFields();
$columns = [];

View File

@ -8,7 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
@ -300,7 +300,7 @@ class ExportMediawiki extends ExportPlugin
}
// Get the table data from the database
$result = $dbi->query($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$fieldsCnt = $result->numFields();
while ($row = $result->fetchRow()) {

View File

@ -8,7 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\FieldMetadata;
use PhpMyAdmin\OpenDocument;
use PhpMyAdmin\Plugins\ExportPlugin;
@ -204,7 +204,7 @@ class ExportOds extends ExportPlugin
$this->initAlias($aliases, $dbAlias, $tableAlias);
$dbi = DatabaseInterface::getInstance();
// Gets the data from the database
$result = $dbi->query($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$fieldsCnt = $result->numFields();
$fieldsMeta = $dbi->getFieldsMeta($result);

View File

@ -9,7 +9,7 @@ namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\Column;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\OpenDocument;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -230,7 +230,7 @@ class ExportOdt extends ExportPlugin
$this->initAlias($aliases, $dbAlias, $tableAlias);
$dbi = DatabaseInterface::getInstance();
// Gets the data from the database
$result = $dbi->query($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$fieldsCnt = $result->numFields();
$fieldsMeta = $dbi->getFieldsMeta($result);

View File

@ -8,7 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
@ -159,7 +159,7 @@ class ExportPhparray extends ExportPlugin
$this->initAlias($aliases, $dbAlias, $tableAlias);
$dbi = DatabaseInterface::getInstance();
$result = $dbi->query($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$columnsCnt = $result->numFields();
$columns = [];

View File

@ -13,7 +13,7 @@ use PhpMyAdmin\Current;
use PhpMyAdmin\Database\Events;
use PhpMyAdmin\Database\Routines;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
@ -2057,7 +2057,7 @@ class ExportSql extends ExportPlugin
return $this->export->outputHandler($head);
}
$result = $dbi->tryQuery($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->tryQuery($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
// a possible error: the table has crashed
$tmpError = $dbi->getError();
if ($tmpError !== '') {

View File

@ -9,7 +9,7 @@ namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\Column;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
@ -181,7 +181,7 @@ class ExportTexytext extends ExportPlugin
/**
* Gets the data from the database
*/
$result = $dbi->query($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
// If required, get fields name at the first line
if (isset($GLOBALS[$GLOBALS['what'] . '_columns'])) {

View File

@ -9,7 +9,7 @@ use PhpMyAdmin\Current;
use PhpMyAdmin\Database\Events;
use PhpMyAdmin\Database\Routines;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
@ -433,7 +433,7 @@ class ExportXml extends ExportPlugin
$tableAlias = $table;
$this->initAlias($aliases, $dbAlias, $tableAlias);
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
$result = $dbi->query($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$columnsCnt = $result->numFields();
$columns = $result->getFieldNames();

View File

@ -8,7 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\FieldMetadata;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -133,7 +133,7 @@ class ExportYaml extends ExportPlugin
$tableAlias = $table;
$this->initAlias($aliases, $dbAlias, $tableAlias);
$dbi = DatabaseInterface::getInstance();
$result = $dbi->query($sqlQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$columnsCnt = $result->numFields();
$fieldsMeta = $dbi->getFieldsMeta($result);

View File

@ -9,7 +9,7 @@ namespace PhpMyAdmin\Plugins\Export\Helpers;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Dbal\ResultInterface;
use PhpMyAdmin\FieldMetadata;
use PhpMyAdmin\Pdf as PdfLib;
@ -673,7 +673,7 @@ class Pdf extends PdfLib
/**
* Pass 1 for column widths
*/
$this->results = $dbi->query($query, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$this->results = $dbi->query($query, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$numFields = $this->results->numFields();
$fields = $dbi->getFieldsMeta($this->results);
@ -796,7 +796,7 @@ class Pdf extends PdfLib
// Pass 2
$this->results = $dbi->query($query, Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED);
$this->results = $dbi->query($query, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
$this->setY($this->tMargin);
$this->AddPage();
$this->setFont(PdfLib::PMA_PDF_FONT, '', 9);

View File

@ -9,7 +9,7 @@ namespace PhpMyAdmin\Plugins\Schema\Pdf;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Pdf as PdfLib;
use PhpMyAdmin\Util;
@ -254,7 +254,7 @@ class Pdf extends PdfLib
$testQuery = 'SELECT * FROM '
. Util::backquote($pdfFeature->database) . '.'
. Util::backquote($pdfFeature->pdfPages)
. ' WHERE db_name = ' . $dbi->quoteString($this->db, Connection::TYPE_CONTROL)
. ' WHERE db_name = ' . $dbi->quoteString($this->db, ConnectionType::ControlUser)
. ' AND page_nr = ' . $this->pageNumber;
$testRs = $dbi->queryAsControlUser($testQuery);
$pageDesc = (string) $testRs->fetchValue('page_descr');

View File

@ -8,6 +8,7 @@ use PhpMyAdmin\Config\Settings\Server;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Dbal\ResultInterface;
use function explode;
@ -15,8 +16,6 @@ use function mb_strtoupper;
/**
* Replication helpers
*
* @psalm-import-type ConnectionType from Connection
*/
class Replication
{
@ -50,12 +49,14 @@ class Replication
* possible values: SQL_THREAD or IO_THREAD or null.
* If it is set to null, it controls both
* SQL_THREAD and IO_THREAD
* @psalm-param ConnectionType $connectionType
*
* @return ResultInterface|false|int output of DatabaseInterface::tryQuery
*/
public function replicaControl(string $action, string|null $control, int $connectionType): ResultInterface|false|int
{
public function replicaControl(
string $action,
string|null $control,
ConnectionType $connectionType,
): ResultInterface|false|int {
$action = mb_strtoupper($action);
$control = $control !== null ? mb_strtoupper($control) : '';
@ -80,7 +81,6 @@ class Replication
* @param mixed[] $pos position of mysql replication, array should contain fields File and Position
* @param bool $stop shall we stop replica?
* @param bool $start shall we start replica?
* @psalm-param ConnectionType $connectionType
*
* @return ResultInterface|false output of CHANGE MASTER mysql command
*/
@ -92,7 +92,7 @@ class Replication
array $pos,
bool $stop,
bool $start,
int $connectionType,
ConnectionType $connectionType,
): ResultInterface|false {
if ($stop) {
$this->replicaControl('STOP', null, $connectionType);
@ -142,19 +142,17 @@ class Replication
// 5th parameter set to true means that it's an auxiliary connection
// and we must not go back to login page if it fails
return $this->dbi->connect($currentServer, Connection::TYPE_AUXILIARY);
return $this->dbi->connect($currentServer, ConnectionType::Auxiliary);
}
/**
* Fetches position and file of current binary log on primary
*
* @psalm-param ConnectionType $connectionType
*
* @return mixed[] an array containing File and Position in MySQL replication
* on primary server, useful for {@see Replication::replicaChangePrimary()}.
* @phpstan-return array{'File'?: string, 'Position'?: string}
*/
public function replicaBinLogPrimary(int $connectionType): array
public function replicaBinLogPrimary(ConnectionType $connectionType): array
{
$data = $this->dbi->fetchResult('SHOW MASTER STATUS', null, null, $connectionType);
$output = [];

View File

@ -9,7 +9,7 @@ namespace PhpMyAdmin\Replication;
use PhpMyAdmin\Config;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Message;
use PhpMyAdmin\Query\Utilities;
use PhpMyAdmin\ResponseRenderer;
@ -488,7 +488,7 @@ class ReplicationGui
);
} else {
// Read the current primary position
$position = $this->replication->replicaBinLogPrimary(Connection::TYPE_AUXILIARY);
$position = $this->replication->replicaBinLogPrimary(ConnectionType::Auxiliary);
if ($position === []) {
$_SESSION['replication']['sr_action_status'] = 'error';
@ -507,7 +507,7 @@ class ReplicationGui
$position,
true,
false,
Connection::TYPE_USER,
ConnectionType::User,
)
) {
$_SESSION['replication']['sr_action_status'] = 'error';
@ -528,14 +528,14 @@ class ReplicationGui
public function handleRequestForReplicaServerControl(string|null $srReplicaAction, string|null $control): bool
{
if ($srReplicaAction === 'reset') {
$qStop = $this->replication->replicaControl('STOP', null, Connection::TYPE_USER);
$qStop = $this->replication->replicaControl('STOP', null, ConnectionType::User);
$qReset = DatabaseInterface::getInstance()->tryQuery('RESET SLAVE;');
$qStart = $this->replication->replicaControl('START', null, Connection::TYPE_USER);
$qStart = $this->replication->replicaControl('START', null, ConnectionType::User);
return $qStop !== false && $qStop !== -1 && $qReset !== false && $qStart !== false && $qStart !== -1;
}
$qControl = $this->replication->replicaControl($srReplicaAction, $control, Connection::TYPE_USER);
$qControl = $this->replication->replicaControl($srReplicaAction, $control, ConnectionType::User);
return $qControl !== false && $qControl !== -1;
}
@ -543,9 +543,9 @@ class ReplicationGui
public function handleRequestForReplicaSkipError(int $srSkipErrorsCount): bool
{
$dbi = DatabaseInterface::getInstance();
$qStop = $this->replication->replicaControl('STOP', null, Connection::TYPE_USER);
$qStop = $this->replication->replicaControl('STOP', null, ConnectionType::User);
$qSkip = $dbi->tryQuery('SET GLOBAL SQL_SLAVE_SKIP_COUNTER = ' . $srSkipErrorsCount . ';');
$qStart = $this->replication->replicaControl('START', null, Connection::TYPE_USER);
$qStart = $this->replication->replicaControl('START', null, ConnectionType::User);
return $qStop !== false && $qStop !== -1 && $qSkip !== false && $qStart !== false && $qStart !== -1;
}

View File

@ -15,6 +15,7 @@ use PhpMyAdmin\Current;
use PhpMyAdmin\Database\Routines;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Dbal\ResultInterface;
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Html\MySQLDocumentation;
@ -418,20 +419,20 @@ class Privileges
. '.' . Util::backquote($configurableMenusFeature->users);
$sqlQuery = 'SELECT `usergroup` FROM ' . $userTable
. ' WHERE `username` = ' . $this->dbi->quoteString($username, Connection::TYPE_CONTROL);
$oldUserGroup = $this->dbi->fetchValue($sqlQuery, 0, Connection::TYPE_CONTROL);
. ' WHERE `username` = ' . $this->dbi->quoteString($username, ConnectionType::ControlUser);
$oldUserGroup = $this->dbi->fetchValue($sqlQuery, 0, ConnectionType::ControlUser);
if ($oldUserGroup === false) {
$updQuery = 'INSERT INTO ' . $userTable . '(`username`, `usergroup`)'
. ' VALUES (' . $this->dbi->quoteString($username, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($userGroup, Connection::TYPE_CONTROL) . ')';
. ' VALUES (' . $this->dbi->quoteString($username, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($userGroup, ConnectionType::ControlUser) . ')';
} elseif ($userGroup === '') {
$updQuery = 'DELETE FROM ' . $userTable
. ' WHERE `username`=' . $this->dbi->quoteString($username, Connection::TYPE_CONTROL);
. ' WHERE `username`=' . $this->dbi->quoteString($username, ConnectionType::ControlUser);
} elseif ($oldUserGroup != $userGroup) {
$updQuery = 'UPDATE ' . $userTable
. ' SET `usergroup`=' . $this->dbi->quoteString($userGroup, Connection::TYPE_CONTROL)
. ' WHERE `username`=' . $this->dbi->quoteString($username, Connection::TYPE_CONTROL);
. ' SET `usergroup`=' . $this->dbi->quoteString($userGroup, ConnectionType::ControlUser)
. ' WHERE `username`=' . $this->dbi->quoteString($username, ConnectionType::ControlUser);
} else {
return;
}
@ -1310,7 +1311,7 @@ class Privileges
. '.' . Util::backquote($configurableMenusFeature->userGroups);
$sqlQuery = 'SELECT COUNT(*) FROM ' . $userGroupTable;
return (int) $this->dbi->fetchValue($sqlQuery, 0, Connection::TYPE_CONTROL);
return (int) $this->dbi->fetchValue($sqlQuery, 0, ConnectionType::ControlUser);
}
/**
@ -1333,7 +1334,7 @@ class Privileges
. ' WHERE `username` = \'' . $username . '\''
. ' LIMIT 1';
$usergroup = $this->dbi->fetchValue($sqlQuery, 0, Connection::TYPE_CONTROL);
$usergroup = $this->dbi->fetchValue($sqlQuery, 0, ConnectionType::ControlUser);
if ($usergroup === false) {
return null;

View File

@ -11,7 +11,7 @@ use PhpMyAdmin\ConfigStorage\Features\UiPreferencesFeature;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\FieldMetadata;
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Html\MySQLDocumentation;
@ -804,14 +804,14 @@ class Table implements Stringable
$whereParts = [];
foreach ($whereFields as $where => $value) {
$whereParts[] = Util::backquote((string) $where) . ' = '
. $dbi->quoteString((string) $value, Connection::TYPE_CONTROL);
. $dbi->quoteString((string) $value, ConnectionType::ControlUser);
}
$newParts = [];
$newValueParts = [];
foreach ($newFields as $where => $value) {
$newParts[] = Util::backquote((string) $where);
$newValueParts[] = $dbi->quoteString((string) $value, Connection::TYPE_CONTROL);
$newValueParts[] = $dbi->quoteString((string) $value, ConnectionType::ControlUser);
}
$tableCopyQuery = '
@ -831,7 +831,7 @@ class Table implements Stringable
continue;
}
$valueParts[] = $dbi->quoteString($val, Connection::TYPE_CONTROL);
$valueParts[] = $dbi->quoteString($val, ConnectionType::ControlUser);
}
$newTableQuery = 'INSERT IGNORE INTO '
@ -1210,9 +1210,9 @@ class Table implements Stringable
. '.'
. Util::backquote($relationParameters->columnCommentsFeature->columnInfo)
. ' WHERE '
. ' db_name = ' . $dbi->quoteString($sourceDb, Connection::TYPE_CONTROL)
. ' db_name = ' . $dbi->quoteString($sourceDb, ConnectionType::ControlUser)
. ' AND '
. ' table_name = ' . $dbi->quoteString($sourceTable, Connection::TYPE_CONTROL),
. ' table_name = ' . $dbi->quoteString($sourceTable, ConnectionType::ControlUser),
);
// Write every comment as new copied entry. [MIME]
@ -1224,15 +1224,16 @@ class Table implements Stringable
. ($relationParameters->browserTransformationFeature !== null
? ', mimetype, transformation, transformation_options'
: '')
. ') VALUES(' . $dbi->quoteString($targetDb, Connection::TYPE_CONTROL)
. ',' . $dbi->quoteString($targetTable, Connection::TYPE_CONTROL) . ','
. $dbi->quoteString($commentsCopyRow['column_name'], Connection::TYPE_CONTROL)
. ') VALUES(' . $dbi->quoteString($targetDb, ConnectionType::ControlUser)
. ',' . $dbi->quoteString($targetTable, ConnectionType::ControlUser) . ','
. $dbi->quoteString($commentsCopyRow['column_name'], ConnectionType::ControlUser)
. ','
. $dbi->quoteString($commentsCopyRow['comment'], Connection::TYPE_CONTROL)
. $dbi->quoteString($commentsCopyRow['comment'], ConnectionType::ControlUser)
. ($relationParameters->browserTransformationFeature !== null
? ',' . $dbi->quoteString($commentsCopyRow['mimetype'], Connection::TYPE_CONTROL)
. ',' . $dbi->quoteString($commentsCopyRow['transformation'], Connection::TYPE_CONTROL)
. ',' . $dbi->quoteString($commentsCopyRow['transformation_options'], Connection::TYPE_CONTROL)
? ',' . $dbi->quoteString($commentsCopyRow['mimetype'], ConnectionType::ControlUser)
. ',' . $dbi->quoteString($commentsCopyRow['transformation'], ConnectionType::ControlUser)
. ','
. $dbi->quoteString($commentsCopyRow['transformation_options'], ConnectionType::ControlUser)
: '')
. ')';
$dbi->queryAsControlUser($newCommentQuery);
@ -1581,9 +1582,9 @@ class Table implements Stringable
'SELECT `prefs` FROM %s.%s WHERE `username` = %s AND `db_name` = %s AND `table_name` = %s',
Util::backquote($uiPreferencesFeature->database),
Util::backquote($uiPreferencesFeature->tableUiPrefs),
$this->dbi->quoteString(Config::getInstance()->selectedServer['user'], Connection::TYPE_CONTROL),
$this->dbi->quoteString($this->dbName, Connection::TYPE_CONTROL),
$this->dbi->quoteString($this->name, Connection::TYPE_CONTROL),
$this->dbi->quoteString(Config::getInstance()->selectedServer['user'], ConnectionType::ControlUser),
$this->dbi->quoteString($this->dbName, ConnectionType::ControlUser),
$this->dbi->quoteString($this->name, ConnectionType::ControlUser),
);
$value = $this->dbi->queryAsControlUser($sqlQuery)->fetchValue();
@ -1608,19 +1609,19 @@ class Table implements Stringable
$username = $config->selectedServer['user'];
$sqlQuery = ' REPLACE INTO ' . $table
. ' (username, db_name, table_name, prefs) VALUES ('
. $this->dbi->quoteString($username, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($this->dbName, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($this->name, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString((string) json_encode($this->uiprefs), Connection::TYPE_CONTROL) . ')';
. $this->dbi->quoteString($username, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($this->dbName, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($this->name, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString((string) json_encode($this->uiprefs), ConnectionType::ControlUser) . ')';
$success = $this->dbi->tryQuery($sqlQuery, Connection::TYPE_CONTROL);
$success = $this->dbi->tryQuery($sqlQuery, ConnectionType::ControlUser);
if (! $success) {
$message = Message::error(
__('Could not save table UI preferences!'),
);
$message->addMessage(
Message::rawError($this->dbi->getError(Connection::TYPE_CONTROL)),
Message::rawError($this->dbi->getError(ConnectionType::ControlUser)),
'<br><br>',
);
@ -1635,7 +1636,7 @@ class Table implements Stringable
if ($rowsCount > $maxRows) {
$numRowsToDelete = $rowsCount - $maxRows;
$sqlQuery = ' DELETE FROM ' . $table . ' ORDER BY last_update ASC LIMIT ' . $numRowsToDelete;
$success = $this->dbi->tryQuery($sqlQuery, Connection::TYPE_CONTROL);
$success = $this->dbi->tryQuery($sqlQuery, ConnectionType::ControlUser);
if (! $success) {
$message = Message::error(sprintf(
@ -1643,7 +1644,7 @@ class Table implements Stringable
MySQLDocumentation::showDocumentation('config', 'cfg_Servers_MaxTableUiprefs'),
));
$message->addMessage(
Message::rawError($this->dbi->getError(Connection::TYPE_CONTROL)),
Message::rawError($this->dbi->getError(ConnectionType::ControlUser)),
'<br><br>',
);
@ -1893,9 +1894,9 @@ class Table implements Stringable
. Util::backquote($displayFeature->database)
. '.' . Util::backquote($displayFeature->tableInfo)
. '(db_name, table_name, display_field) VALUES('
. $this->dbi->quoteString($this->dbName, Connection::TYPE_CONTROL) . ','
. $this->dbi->quoteString($this->name, Connection::TYPE_CONTROL) . ','
. $this->dbi->quoteString($displayField, Connection::TYPE_CONTROL) . ')';
. $this->dbi->quoteString($this->dbName, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($this->name, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($displayField, ConnectionType::ControlUser) . ')';
}
$this->dbi->queryAsControlUser($updQuery);
@ -1933,12 +1934,12 @@ class Table implements Stringable
. '(master_db, master_table, master_field, foreign_db,'
. ' foreign_table, foreign_field)'
. ' values('
. $this->dbi->quoteString($this->dbName, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($this->name, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($masterField, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($foreignDb, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($foreignTable, Connection::TYPE_CONTROL) . ','
. $this->dbi->quoteString($foreignField, Connection::TYPE_CONTROL) . ')';
. $this->dbi->quoteString($this->dbName, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($this->name, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($masterField, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($foreignDb, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($foreignTable, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($foreignField, ConnectionType::ControlUser) . ')';
} elseif (
$existrel[$masterField]['foreign_db'] != $foreignDb
|| $existrel[$masterField]['foreign_table'] != $foreignTable
@ -1948,28 +1949,28 @@ class Table implements Stringable
. Util::backquote($relationFeature->database)
. '.' . Util::backquote($relationFeature->relation)
. ' SET foreign_db = '
. $this->dbi->quoteString($foreignDb, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($foreignDb, ConnectionType::ControlUser) . ', '
. ' foreign_table = '
. $this->dbi->quoteString($foreignTable, Connection::TYPE_CONTROL) . ', '
. $this->dbi->quoteString($foreignTable, ConnectionType::ControlUser) . ', '
. ' foreign_field = '
. $this->dbi->quoteString($foreignField, Connection::TYPE_CONTROL) . ' '
. $this->dbi->quoteString($foreignField, ConnectionType::ControlUser) . ' '
. ' WHERE master_db = '
. $this->dbi->quoteString($this->dbName, Connection::TYPE_CONTROL)
. $this->dbi->quoteString($this->dbName, ConnectionType::ControlUser)
. ' AND master_table = '
. $this->dbi->quoteString($this->name, Connection::TYPE_CONTROL)
. $this->dbi->quoteString($this->name, ConnectionType::ControlUser)
. ' AND master_field = '
. $this->dbi->quoteString($masterField, Connection::TYPE_CONTROL);
. $this->dbi->quoteString($masterField, ConnectionType::ControlUser);
}
} elseif (isset($existrel[$masterField])) {
$updQuery = 'DELETE FROM '
. Util::backquote($relationFeature->database)
. '.' . Util::backquote($relationFeature->relation)
. ' WHERE master_db = '
. $this->dbi->quoteString($this->dbName, Connection::TYPE_CONTROL)
. $this->dbi->quoteString($this->dbName, ConnectionType::ControlUser)
. ' AND master_table = '
. $this->dbi->quoteString($this->name, Connection::TYPE_CONTROL)
. $this->dbi->quoteString($this->name, ConnectionType::ControlUser)
. ' AND master_field = '
. $this->dbi->quoteString($masterField, Connection::TYPE_CONTROL);
. $this->dbi->quoteString($masterField, ConnectionType::ControlUser);
}
if (! isset($updQuery)) {

View File

@ -12,7 +12,7 @@ use PhpMyAdmin\ConfigStorage\Features\TrackingFeature;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\Export\ExportSql;
use PhpMyAdmin\SqlParser\Parser;
@ -111,11 +111,11 @@ class Tracker
. ' ORDER BY version DESC LIMIT 1',
Util::backquote($trackingFeature->database),
Util::backquote($trackingFeature->tracking),
$dbi->quoteString($dbName, Connection::TYPE_CONTROL),
$dbi->quoteString($tableName, Connection::TYPE_CONTROL),
$dbi->quoteString($dbName, ConnectionType::ControlUser),
$dbi->quoteString($tableName, ConnectionType::ControlUser),
);
$result = $dbi->fetchValue($sqlQuery, 0, Connection::TYPE_CONTROL) == 1;
$result = $dbi->fetchValue($sqlQuery, 0, ConnectionType::ControlUser) == 1;
self::$trackingCache[$dbName][$tableName] = $result;
@ -221,15 +221,15 @@ class Tracker
. ' values (%s, %s, %s, %s, %s, %s, %s, %s, %s)',
Util::backquote($trackingFeature->database),
Util::backquote($trackingFeature->tracking),
$dbi->quoteString($dbName, Connection::TYPE_CONTROL),
$dbi->quoteString($tableName, Connection::TYPE_CONTROL),
$dbi->quoteString($version, Connection::TYPE_CONTROL),
$dbi->quoteString($date, Connection::TYPE_CONTROL),
$dbi->quoteString($date, Connection::TYPE_CONTROL),
$dbi->quoteString($snapshot, Connection::TYPE_CONTROL),
$dbi->quoteString($createSql, Connection::TYPE_CONTROL),
$dbi->quoteString("\n", Connection::TYPE_CONTROL),
$dbi->quoteString($trackingSet, Connection::TYPE_CONTROL),
$dbi->quoteString($dbName, ConnectionType::ControlUser),
$dbi->quoteString($tableName, ConnectionType::ControlUser),
$dbi->quoteString($version, ConnectionType::ControlUser),
$dbi->quoteString($date, ConnectionType::ControlUser),
$dbi->quoteString($date, ConnectionType::ControlUser),
$dbi->quoteString($snapshot, ConnectionType::ControlUser),
$dbi->quoteString($createSql, ConnectionType::ControlUser),
$dbi->quoteString("\n", ConnectionType::ControlUser),
$dbi->quoteString($trackingSet, ConnectionType::ControlUser),
);
$dbi->queryAsControlUser($sqlQuery);
@ -283,15 +283,15 @@ class Tracker
. ' values (%s, %s, %s, %s, %s, %s, %s, %s, %s)',
Util::backquote($trackingFeature->database),
Util::backquote($trackingFeature->tracking),
$dbi->quoteString($dbName, Connection::TYPE_CONTROL),
$dbi->quoteString('', Connection::TYPE_CONTROL),
$dbi->quoteString($version, Connection::TYPE_CONTROL),
$dbi->quoteString($date, Connection::TYPE_CONTROL),
$dbi->quoteString($date, Connection::TYPE_CONTROL),
$dbi->quoteString('', Connection::TYPE_CONTROL),
$dbi->quoteString($createSql, Connection::TYPE_CONTROL),
$dbi->quoteString("\n", Connection::TYPE_CONTROL),
$dbi->quoteString($trackingSet, Connection::TYPE_CONTROL),
$dbi->quoteString($dbName, ConnectionType::ControlUser),
$dbi->quoteString('', ConnectionType::ControlUser),
$dbi->quoteString($version, ConnectionType::ControlUser),
$dbi->quoteString($date, ConnectionType::ControlUser),
$dbi->quoteString($date, ConnectionType::ControlUser),
$dbi->quoteString('', ConnectionType::ControlUser),
$dbi->quoteString($createSql, ConnectionType::ControlUser),
$dbi->quoteString("\n", ConnectionType::ControlUser),
$dbi->quoteString($trackingSet, ConnectionType::ControlUser),
);
return (bool) $dbi->queryAsControlUser($sqlQuery);
@ -324,9 +324,9 @@ class Tracker
Util::backquote($trackingFeature->database),
Util::backquote($trackingFeature->tracking),
$newState,
$dbi->quoteString($dbName, Connection::TYPE_CONTROL),
$dbi->quoteString($tableName, Connection::TYPE_CONTROL),
$dbi->quoteString($version, Connection::TYPE_CONTROL),
$dbi->quoteString($dbName, ConnectionType::ControlUser),
$dbi->quoteString($tableName, ConnectionType::ControlUser),
$dbi->quoteString($version, ConnectionType::ControlUser),
);
return (bool) $dbi->queryAsControlUser($sqlQuery);
@ -379,8 +379,8 @@ class Tracker
'SELECT MAX(version) FROM %s.%s WHERE `db_name` = %s AND `table_name` = %s',
Util::backquote($trackingFeature->database),
Util::backquote($trackingFeature->tracking),
$dbi->quoteString($dbname, Connection::TYPE_CONTROL),
$dbi->quoteString($tablename, Connection::TYPE_CONTROL),
$dbi->quoteString($dbname, ConnectionType::ControlUser),
$dbi->quoteString($tablename, ConnectionType::ControlUser),
);
if ($statement != '') {
@ -644,15 +644,15 @@ class Tracker
Util::backquote($trackingFeature->tracking),
Util::backquote($saveTo),
Util::backquote($saveTo),
$dbi->quoteString("\n" . $query, Connection::TYPE_CONTROL),
$dbi->quoteString($date, Connection::TYPE_CONTROL),
$dbi->quoteString("\n" . $query, ConnectionType::ControlUser),
$dbi->quoteString($date, ConnectionType::ControlUser),
);
// If table was renamed we have to change
// the tablename attribute in pma_tracking too
if ($result['identifier'] === 'RENAME TABLE') {
$sqlQuery .= ', `table_name` = '
. $dbi->quoteString($result['tablename_after_rename'], Connection::TYPE_CONTROL)
. $dbi->quoteString($result['tablename_after_rename'], ConnectionType::ControlUser)
. ' ';
}
@ -666,9 +666,9 @@ class Tracker
' AND `db_name` = %s ' .
' AND `table_name` = %s ' .
' AND `version` = %s ',
$dbi->quoteString($dbname, Connection::TYPE_CONTROL),
$dbi->quoteString($result['tablename'], Connection::TYPE_CONTROL),
$dbi->quoteString((string) $version, Connection::TYPE_CONTROL),
$dbi->quoteString($dbname, ConnectionType::ControlUser),
$dbi->quoteString($result['tablename'], ConnectionType::ControlUser),
$dbi->quoteString((string) $version, ConnectionType::ControlUser),
);
$dbi->queryAsControlUser($sqlQuery);
@ -683,7 +683,7 @@ class Tracker
'/*NOTRACK*/ SELECT 1 FROM %s.%s WHERE tracking_active = 1 AND db_name = %s LIMIT 1',
Util::backquote($trackingFeature->database),
Util::backquote($trackingFeature->tracking),
$dbi->quoteString($dbname, Connection::TYPE_CONTROL),
$dbi->quoteString($dbname, ConnectionType::ControlUser),
);
return $dbi->queryAsControlUser($sqlQuery)->fetchValue() !== false;

View File

@ -12,7 +12,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Dbal\ResultInterface;
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
@ -75,11 +75,11 @@ class Tracking
'/*NOTRACK*/' . "\n" . 'DELETE FROM %s.%s WHERE `db_name` = %s AND `table_name` = %s',
Util::backquote($trackingFeature->database),
Util::backquote($trackingFeature->tracking),
$this->dbi->quoteString($dbName, Connection::TYPE_CONTROL),
$this->dbi->quoteString($tableName, Connection::TYPE_CONTROL),
$this->dbi->quoteString($dbName, ConnectionType::ControlUser),
$this->dbi->quoteString($tableName, ConnectionType::ControlUser),
);
if ($version !== '') {
$sqlQuery .= ' AND `version` = ' . $this->dbi->quoteString($version, Connection::TYPE_CONTROL);
$sqlQuery .= ' AND `version` = ' . $this->dbi->quoteString($version, ConnectionType::ControlUser);
}
return (bool) $this->dbi->queryAsControlUser($sqlQuery);
@ -134,8 +134,8 @@ class Tracking
'SELECT * FROM %s.%s WHERE db_name = %s AND table_name = %s ORDER BY version DESC',
Util::backquote($trackingFeature->database),
Util::backquote($trackingFeature->tracking),
$this->dbi->quoteString($db, Connection::TYPE_CONTROL),
$this->dbi->quoteString($table, Connection::TYPE_CONTROL),
$this->dbi->quoteString($db, ConnectionType::ControlUser),
$this->dbi->quoteString($table, ConnectionType::ControlUser),
);
return $this->dbi->queryAsControlUser($query);
@ -644,13 +644,14 @@ class Tracking
'SELECT * FROM %s.%s WHERE `db_name` = %s',
Util::backquote($trackingFeature->database),
Util::backquote($trackingFeature->tracking),
$this->dbi->quoteString($dbname, Connection::TYPE_CONTROL),
$this->dbi->quoteString($dbname, ConnectionType::ControlUser),
);
if ($tablename !== '') {
$sqlQuery .= ' AND `table_name` = ' . $this->dbi->quoteString($tablename, Connection::TYPE_CONTROL) . ' ';
$sqlQuery .= ' AND `table_name` = '
. $this->dbi->quoteString($tablename, ConnectionType::ControlUser) . ' ';
}
$sqlQuery .= ' AND `version` = ' . $this->dbi->quoteString($version, Connection::TYPE_CONTROL)
$sqlQuery .= ' AND `version` = ' . $this->dbi->quoteString($version, ConnectionType::ControlUser)
. ' ORDER BY `version` DESC LIMIT 1';
$mixed = $this->dbi->queryAsControlUser($sqlQuery)->fetchAssoc();
@ -814,10 +815,10 @@ class Tracking
Util::backquote($trackingFeature->database),
Util::backquote($trackingFeature->tracking),
$logType->getColumnName(),
$this->dbi->quoteString($newDataProcessed, Connection::TYPE_CONTROL),
$this->dbi->quoteString($dbName, Connection::TYPE_CONTROL),
$this->dbi->quoteString($tableName, Connection::TYPE_CONTROL),
$this->dbi->quoteString($version, Connection::TYPE_CONTROL),
$this->dbi->quoteString($newDataProcessed, ConnectionType::ControlUser),
$this->dbi->quoteString($dbName, ConnectionType::ControlUser),
$this->dbi->quoteString($tableName, ConnectionType::ControlUser),
$this->dbi->quoteString($version, ConnectionType::ControlUser),
);
$result = $this->dbi->queryAsControlUser($sqlQuery);
@ -1136,7 +1137,7 @@ class Tracking
// Prepare statement to get HEAD version
$allTablesQuery = ' SELECT table_name, MAX(version) as version FROM '
. Util::backquote($trackingFeature->database) . '.' . Util::backquote($trackingFeature->tracking)
. ' WHERE db_name = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL)
. ' WHERE db_name = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser)
. ' GROUP BY table_name ORDER BY table_name ASC';
$allTablesResult = $this->dbi->queryAsControlUser($allTablesQuery);
@ -1148,9 +1149,9 @@ class Tracking
[$tableName, $versionNumber] = $oneResult;
$tableQuery = ' SELECT * FROM '
. Util::backquote($trackingFeature->database) . '.' . Util::backquote($trackingFeature->tracking)
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db, Connection::TYPE_CONTROL)
. ' AND `table_name` = ' . $this->dbi->quoteString($tableName, Connection::TYPE_CONTROL)
. ' AND `version` = ' . $this->dbi->quoteString($versionNumber, Connection::TYPE_CONTROL);
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser)
. ' AND `table_name` = ' . $this->dbi->quoteString($tableName, ConnectionType::ControlUser)
. ' AND `version` = ' . $this->dbi->quoteString($versionNumber, ConnectionType::ControlUser);
$versions[] = $this->dbi->queryAsControlUser($tableQuery)->fetchAssoc();
}

View File

@ -7,7 +7,7 @@ namespace PhpMyAdmin\Tracking;
use PhpMyAdmin\ConfigStorage\Features\TrackingFeature;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Util;
@ -67,7 +67,7 @@ class TrackingChecker
JOIN %s.%s USING(table_name, version)",
Util::backquote($this->trackingFeature->database),
Util::backquote($this->trackingFeature->tracking),
$this->dbi->quoteString($dbName, Connection::TYPE_CONTROL),
$this->dbi->quoteString($dbName, ConnectionType::ControlUser),
Util::backquote($this->trackingFeature->database),
Util::backquote($this->trackingFeature->tracking),
);

View File

@ -18,7 +18,7 @@ declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\TransformationsInterface;
use function array_shift;
@ -296,8 +296,8 @@ class Transformations
. '`input_transformation_options`'
. ' FROM ' . Util::backquote($browserTransformationFeature->database) . '.'
. Util::backquote($browserTransformationFeature->columnInfo)
. ' WHERE `db_name` = ' . $dbi->quoteString($db, Connection::TYPE_CONTROL)
. ' AND `table_name` = ' . $dbi->quoteString($table, Connection::TYPE_CONTROL)
. ' WHERE `db_name` = ' . $dbi->quoteString($db, ConnectionType::ControlUser)
. ' AND `table_name` = ' . $dbi->quoteString($table, ConnectionType::ControlUser)
. ' AND ( `mimetype` != \'\'' . (! $strict ?
' OR `transformation` != \'\''
. ' OR `transformation_options` != \'\''
@ -314,7 +314,7 @@ class Transformations
* input_transformation_options: string
* }> $result
*/
$result = $dbi->fetchResult($comQry, 'column_name', null, Connection::TYPE_CONTROL);
$result = $dbi->fetchResult($comQry, 'column_name', null, ConnectionType::ControlUser);
foreach ($result as $column => $values) {
// convert mimetype to new format (f.e. Text_Plain, etc)
@ -387,9 +387,9 @@ class Transformations
`comment`
FROM ' . Util::backquote($browserTransformationFeature->database) . '.'
. Util::backquote($browserTransformationFeature->columnInfo) . '
WHERE `db_name` = ' . $dbi->quoteString($db, Connection::TYPE_CONTROL) . '
AND `table_name` = ' . $dbi->quoteString($table, Connection::TYPE_CONTROL) . '
AND `column_name` = ' . $dbi->quoteString($key, Connection::TYPE_CONTROL);
WHERE `db_name` = ' . $dbi->quoteString($db, ConnectionType::ControlUser) . '
AND `table_name` = ' . $dbi->quoteString($table, ConnectionType::ControlUser) . '
AND `column_name` = ' . $dbi->quoteString($key, ConnectionType::ControlUser);
$testRs = $dbi->queryAsControlUser($testQry);
@ -402,15 +402,15 @@ class Transformations
. Util::backquote($browserTransformationFeature->columnInfo)
. ' SET '
. '`mimetype` = '
. $dbi->quoteString($mimetype, Connection::TYPE_CONTROL) . ', '
. $dbi->quoteString($mimetype, ConnectionType::ControlUser) . ', '
. '`transformation` = '
. $dbi->quoteString($transformation, Connection::TYPE_CONTROL) . ', '
. $dbi->quoteString($transformation, ConnectionType::ControlUser) . ', '
. '`transformation_options` = '
. $dbi->quoteString($transformationOpts, Connection::TYPE_CONTROL) . ', '
. $dbi->quoteString($transformationOpts, ConnectionType::ControlUser) . ', '
. '`input_transformation` = '
. $dbi->quoteString($inputTransform, Connection::TYPE_CONTROL) . ', '
. $dbi->quoteString($inputTransform, ConnectionType::ControlUser) . ', '
. '`input_transformation_options` = '
. $dbi->quoteString($inputTransformOpts, Connection::TYPE_CONTROL);
. $dbi->quoteString($inputTransformOpts, ConnectionType::ControlUser);
} else {
$updQuery = 'DELETE FROM '
. Util::backquote($browserTransformationFeature->database)
@ -418,9 +418,9 @@ class Transformations
}
$updQuery .= '
WHERE `db_name` = ' . $dbi->quoteString($db, Connection::TYPE_CONTROL) . '
AND `table_name` = ' . $dbi->quoteString($table, Connection::TYPE_CONTROL) . '
AND `column_name` = ' . $dbi->quoteString($key, Connection::TYPE_CONTROL);
WHERE `db_name` = ' . $dbi->quoteString($db, ConnectionType::ControlUser) . '
AND `table_name` = ' . $dbi->quoteString($table, ConnectionType::ControlUser) . '
AND `column_name` = ' . $dbi->quoteString($key, ConnectionType::ControlUser);
} elseif ($hasValue) {
$updQuery = 'INSERT INTO '
. Util::backquote($browserTransformationFeature->database)
@ -429,14 +429,14 @@ class Transformations
. 'transformation, transformation_options, '
. 'input_transformation, input_transformation_options) '
. ' VALUES('
. $dbi->quoteString($db, Connection::TYPE_CONTROL) . ','
. $dbi->quoteString($table, Connection::TYPE_CONTROL) . ','
. $dbi->quoteString($key, Connection::TYPE_CONTROL) . ','
. $dbi->quoteString($mimetype, Connection::TYPE_CONTROL) . ','
. $dbi->quoteString($transformation, Connection::TYPE_CONTROL) . ','
. $dbi->quoteString($transformationOpts, Connection::TYPE_CONTROL) . ','
. $dbi->quoteString($inputTransform, Connection::TYPE_CONTROL) . ','
. $dbi->quoteString($inputTransformOpts, Connection::TYPE_CONTROL) . ')';
. $dbi->quoteString($db, ConnectionType::ControlUser) . ','
. $dbi->quoteString($table, ConnectionType::ControlUser) . ','
. $dbi->quoteString($key, ConnectionType::ControlUser) . ','
. $dbi->quoteString($mimetype, ConnectionType::ControlUser) . ','
. $dbi->quoteString($transformation, ConnectionType::ControlUser) . ','
. $dbi->quoteString($transformationOpts, ConnectionType::ControlUser) . ','
. $dbi->quoteString($inputTransform, ConnectionType::ControlUser) . ','
. $dbi->quoteString($inputTransformOpts, ConnectionType::ControlUser) . ')';
}
if (isset($updQuery)) {

View File

@ -7,7 +7,7 @@ namespace PhpMyAdmin;
use PhpMyAdmin\Config\ConfigFile;
use PhpMyAdmin\Config\Forms\User\UserFormList;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Identifiers\DatabaseName;
use function __;
@ -89,7 +89,7 @@ class UserPreferences
. ' FROM ' . $queryTable
. ' WHERE `username` = '
. $this->dbi->quoteString((string) $relationParameters->user);
$row = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, Connection::TYPE_CONTROL);
$row = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, ConnectionType::ControlUser);
if (! is_array($row) || ! isset($row['config_data']) || ! isset($row['ts'])) {
return ['config_data' => [], 'mtime' => time(), 'type' => 'db'];
}
@ -135,7 +135,7 @@ class UserPreferences
. ' WHERE `username` = '
. $this->dbi->quoteString($relationParameters->user);
$hasConfig = $this->dbi->fetchValue($query, 0, Connection::TYPE_CONTROL);
$hasConfig = $this->dbi->fetchValue($query, 0, ConnectionType::ControlUser);
$configData = json_encode($configArray);
if ($hasConfig) {
$query = 'UPDATE ' . $queryTable
@ -155,10 +155,10 @@ class UserPreferences
unset($_SESSION['cache'][$cacheKey]['userprefs']);
}
if (! $this->dbi->tryQuery($query, Connection::TYPE_CONTROL)) {
if (! $this->dbi->tryQuery($query, ConnectionType::ControlUser)) {
$message = Message::error(__('Could not save configuration'));
$message->addMessage(
Message::error($this->dbi->getError(Connection::TYPE_CONTROL)),
Message::error($this->dbi->getError(ConnectionType::ControlUser)),
'<br><br>',
);
if (! $this->hasAccessToDatabase($relationParameters->db)) {
@ -188,7 +188,7 @@ class UserPreferences
);
}
return (bool) $this->dbi->fetchSingleRow($query, 'ASSOC', Connection::TYPE_CONTROL);
return (bool) $this->dbi->fetchSingleRow($query, 'ASSOC', ConnectionType::ControlUser);
}
/**

View File

@ -8,7 +8,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\Config\Settings;
use PhpMyAdmin\Config\Settings\Server;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Depends;
@ -43,7 +43,6 @@ use const INFO_MODULES;
use const PHP_OS;
use const TEST_PATH;
/** @psalm-import-type ConnectionType from Connection */
#[CoversClass(Config::class)]
class ConfigTest extends AbstractTestCase
{
@ -734,10 +733,9 @@ PHP;
*
* @param mixed[] $serverCfg Server configuration
* @param mixed[] $expected Expected result
* @psalm-param ConnectionType $connectionType
*/
#[DataProvider('connectionParams')]
public function testGetConnectionParams(array $serverCfg, int $connectionType, array $expected): void
public function testGetConnectionParams(array $serverCfg, ConnectionType $connectionType, array $expected): void
{
$result = Config::getConnectionParams(new Server($serverCfg), $connectionType);
$this->assertEquals(new Server($expected), $result);
@ -780,7 +778,7 @@ PHP;
return [
[
$cfgBasic,
Connection::TYPE_USER,
ConnectionType::User,
[
'user' => 'u',
'password' => 'pass',
@ -796,7 +794,7 @@ PHP;
],
[
$cfgBasic,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
[
'user' => 'u2',
'password' => 'p2',
@ -810,7 +808,7 @@ PHP;
],
[
$cfgSsl,
Connection::TYPE_USER,
ConnectionType::User,
[
'user' => 'u',
'password' => 'pass',
@ -826,7 +824,7 @@ PHP;
],
[
$cfgSsl,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
[
'user' => 'u2',
'password' => 'p2',
@ -840,7 +838,7 @@ PHP;
],
[
$cfgControlSsl,
Connection::TYPE_USER,
ConnectionType::User,
[
'user' => 'u',
'password' => 'pass',
@ -857,7 +855,7 @@ PHP;
],
[
$cfgControlSsl,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
[
'user' => 'u2',
'password' => 'p2',
@ -872,10 +870,9 @@ PHP;
];
}
/** @psalm-param ConnectionType $connectionType */
#[DataProvider('connectionParamsWhenConnectionIsUserOrAuxiliaryProvider')]
public function testGetConnectionParamsWhenConnectionIsUserOrAuxiliary(
int $connectionType,
ConnectionType $connectionType,
string $host,
string $port,
string $expectedHost,
@ -889,15 +886,15 @@ PHP;
/** @psalm-return iterable<string, array{ConnectionType, string, string, string, string}> */
public static function connectionParamsWhenConnectionIsUserOrAuxiliaryProvider(): iterable
{
yield 'user with only port empty' => [Connection::TYPE_USER, 'test.host', '', 'test.host', '0'];
yield 'user with only host empty' => [Connection::TYPE_USER, '', '12345', 'localhost', '12345'];
yield 'user with host and port empty' => [Connection::TYPE_USER, '', '', 'localhost', '0'];
yield 'user with host and port defined' => [Connection::TYPE_USER, 'test.host', '12345', 'test.host', '12345'];
yield 'aux with only port empty' => [Connection::TYPE_AUXILIARY, 'test.host', '', 'test.host', '0'];
yield 'aux with only host empty' => [Connection::TYPE_AUXILIARY, '', '12345', 'localhost', '12345'];
yield 'aux with host and port empty' => [Connection::TYPE_AUXILIARY, '', '', 'localhost', '0'];
yield 'user with only port empty' => [ConnectionType::User, 'test.host', '', 'test.host', '0'];
yield 'user with only host empty' => [ConnectionType::User, '', '12345', 'localhost', '12345'];
yield 'user with host and port empty' => [ConnectionType::User, '', '', 'localhost', '0'];
yield 'user with host and port defined' => [ConnectionType::User, 'test.host', '12345', 'test.host', '12345'];
yield 'aux with only port empty' => [ConnectionType::Auxiliary, 'test.host', '', 'test.host', '0'];
yield 'aux with only host empty' => [ConnectionType::Auxiliary, '', '12345', 'localhost', '12345'];
yield 'aux with host and port empty' => [ConnectionType::Auxiliary, '', '', 'localhost', '0'];
yield 'aux with host and port defined' => [
Connection::TYPE_AUXILIARY,
ConnectionType::Auxiliary,
'test.host',
'12345',
'test.host',

View File

@ -8,7 +8,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\Controllers\Server\VariablesController;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Providers\ServerVariables\ServerVariablesProvider;
@ -57,8 +57,8 @@ class VariablesControllerTest extends AbstractTestCase
$serverGlobalVariables = ['auto_increment_increment' => '0', 'auto_increment_offset' => '12'];
$fetchResult = [
['SHOW SESSION VARIABLES;', 0, 1, Connection::TYPE_USER, $serverSessionVariables],
['SHOW GLOBAL VARIABLES;', 0, 1, Connection::TYPE_USER, $serverGlobalVariables],
['SHOW SESSION VARIABLES;', 0, 1, ConnectionType::User, $serverSessionVariables],
['SHOW GLOBAL VARIABLES;', 0, 1, ConnectionType::User, $serverGlobalVariables],
];
$dbi->expects($this->any())->method('fetchResult')

View File

@ -11,7 +11,7 @@ use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\Current;
use PhpMyAdmin\Database\CentralColumns;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DummyResult;
use PhpMyAdmin\Types;
@ -200,7 +200,7 @@ class CentralColumnsTest extends AbstractTestCase
'SELECT count(db_name) FROM `pma_central_columns` WHERE db_name = \'phpmyadmin\';',
null,
null,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
)
->willReturn([3]);
@ -260,7 +260,7 @@ class CentralColumnsTest extends AbstractTestCase
. "WHERE db_name = 'PMA_db' AND col_name IN ('id','col1','col2');",
null,
null,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
)
->willReturn(['id', 'col1']);
$this->assertEquals(
@ -287,7 +287,7 @@ class CentralColumnsTest extends AbstractTestCase
. "WHERE db_name = 'PMA_db' AND col_name IN ('id','col1','col2');",
null,
null,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
)
->willReturn(array_slice($this->columnData, 0, 2));
$this->assertEquals(
@ -367,7 +367,7 @@ class CentralColumnsTest extends AbstractTestCase
. "WHERE db_name = 'phpmyadmin' AND col_name IN ('col1','col2');",
null,
null,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
)
->willReturn($this->columnData);
$result = $this->centralColumns->getHtmlForEditingPage(
@ -402,7 +402,7 @@ class CentralColumnsTest extends AbstractTestCase
'SELECT * FROM `pma_central_columns` WHERE db_name = \'phpmyadmin\';',
null,
null,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
)
->willReturn($this->columnData);
$this->assertEquals(
@ -427,7 +427,7 @@ class CentralColumnsTest extends AbstractTestCase
. "NOT IN ('id','col1','col2');",
null,
null,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
)
->willReturn($this->columnData);
$this->assertEquals(
@ -450,7 +450,7 @@ class CentralColumnsTest extends AbstractTestCase
'SELECT * FROM `pma_central_columns` WHERE db_name = \'phpmyadmin\' AND col_name IN (\'col1\');',
null,
null,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
)
->willReturn(array_slice($this->columnData, 1, 1));
$this->assertEquals(

View File

@ -10,7 +10,7 @@ use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\Current;
use PhpMyAdmin\Database\Designer\Common;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DbiDummy;
use PhpMyAdmin\Tests\Stubs\DummyResult;
@ -72,7 +72,7 @@ class CommonTest extends AbstractTestCase
WHERE pdf_page_number = " . $pg,
'name',
null,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
);
DatabaseInterface::$instance = $dbi;
@ -99,7 +99,7 @@ class CommonTest extends AbstractTestCase
'SELECT `page_descr` FROM `pmadb`.`pdf_pages`'
. ' WHERE `page_nr` = ' . $pg,
0,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
)
->willReturn($pageName);
DatabaseInterface::$instance = $dbi;
@ -155,7 +155,7 @@ class CommonTest extends AbstractTestCase
. " WHERE `db_name` = '" . $db . "'"
. " AND `page_descr` = '" . $db . "'",
0,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
)
->willReturn($defaultPg);
$dbi->expects($this->any())->method('quoteString')
@ -186,7 +186,7 @@ class CommonTest extends AbstractTestCase
. " WHERE `db_name` = '" . $db . "'"
. " AND `page_descr` = '" . $db . "'",
0,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
)
->willReturn(false);
$dbi->expects($this->any())->method('quoteString')
@ -218,7 +218,7 @@ class CommonTest extends AbstractTestCase
. " WHERE `db_name` = '" . $db . "'"
. " AND `page_descr` = '" . $db . "'",
0,
Connection::TYPE_CONTROL,
ConnectionType::ControlUser,
)
->willReturn($defaultPg);
$dbi->expects($this->any())->method('quoteString')

View File

@ -8,7 +8,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\Current;
use PhpMyAdmin\Database\Routines;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Types;
use PhpMyAdmin\UserPrivileges;
@ -250,8 +250,8 @@ class RoutinesTest extends AbstractTestCase
$dbi->expects($this->any())
->method('quoteString')
->willReturnMap([
['foo', Connection::TYPE_USER, "'foo'"],
["foo's bar", Connection::TYPE_USER, "'foo\'s bar'"],
['foo', ConnectionType::User, "'foo'"],
["foo's bar", ConnectionType::User, "'foo\'s bar'"],
]);
DatabaseInterface::$instance = $dbi;

View File

@ -8,7 +8,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\Config\Settings\Server;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Dbal\DbiExtension;
use PhpMyAdmin\Dbal\ResultInterface;
use PhpMyAdmin\Dbal\Statement;
@ -639,7 +639,7 @@ class DatabaseInterfaceTest extends AbstractTestCase
$dummyDbi->addSelectDb('db1');
$dummyDbi->addSelectDb('db2');
$databaseList = $dbi->getDatabasesFull(null, true, Connection::TYPE_USER, 'SCHEMA_DATA_LENGTH', 'ASC', 0, 100);
$databaseList = $dbi->getDatabasesFull(null, true, ConnectionType::User, 'SCHEMA_DATA_LENGTH', 'ASC', 0, 100);
$this->assertSame([
[
@ -678,7 +678,7 @@ class DatabaseInterfaceTest extends AbstractTestCase
->with($this->isType('object'), $this->equalTo($query))
->willReturn($stmtStub);
$dbi = $this->createDatabaseInterface($dummyDbi);
$stmt = $dbi->prepare($query, Connection::TYPE_CONTROL);
$stmt = $dbi->prepare($query, ConnectionType::ControlUser);
$this->assertSame($stmtStub, $stmt);
}

View File

@ -9,7 +9,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Message;
use PhpMyAdmin\Normalization;
use PhpMyAdmin\Template;
@ -78,12 +78,12 @@ class NormalizationTest extends AbstractTestCase
->method('getColumnNames')
->willReturn(['id', 'col1', 'col2']);
$map = [
['PMA_db', 'PMA_table1', Connection::TYPE_USER, []],
['PMA_db', 'PMA_table', Connection::TYPE_USER, [['Key_name' => 'PRIMARY', 'Column_name' => 'id']]],
['PMA_db', 'PMA_table1', ConnectionType::User, []],
['PMA_db', 'PMA_table', ConnectionType::User, [['Key_name' => 'PRIMARY', 'Column_name' => 'id']]],
[
'PMA_db',
'PMA_table2',
Connection::TYPE_USER,
ConnectionType::User,
[['Key_name' => 'PRIMARY','Column_name' => 'id'], ['Key_name' => 'PRIMARY','Column_name' => 'col1']],
],
];

View File

@ -6,7 +6,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportOds;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -240,7 +240,7 @@ class ExportOdsTest extends AbstractTestCase
$dbi->expects($this->once())
->method('query')
->with('SELECT', Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED)
->with('SELECT', ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED)
->willReturn($resultStub);
$resultStub->expects($this->once())
@ -318,7 +318,7 @@ class ExportOdsTest extends AbstractTestCase
$dbi->expects($this->once())
->method('query')
->with('SELECT', Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED)
->with('SELECT', ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED)
->willReturn($resultStub);
$resultStub->expects($this->once())
@ -370,7 +370,7 @@ class ExportOdsTest extends AbstractTestCase
$dbi->expects($this->once())
->method('query')
->with('SELECT', Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED)
->with('SELECT', ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED)
->willReturn($resultStub);
$resultStub->expects($this->once())

View File

@ -9,7 +9,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Identifiers\TriggerName;
@ -379,7 +379,7 @@ class ExportOdtTest extends AbstractTestCase
$dbi->expects($this->once())
->method('query')
->with('SELECT', Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED)
->with('SELECT', ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED)
->willReturn($resultStub);
$resultStub->expects($this->once())
@ -448,7 +448,7 @@ class ExportOdtTest extends AbstractTestCase
$dbi->expects($this->once())
->method('query')
->with('SELECT', Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED)
->with('SELECT', ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED)
->willReturn($resultStub);
$resultStub->expects($this->once())
@ -500,7 +500,7 @@ class ExportOdtTest extends AbstractTestCase
$dbi->expects($this->once())
->method('query')
->with('SELECT', Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED)
->with('SELECT', ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED)
->willReturn($resultStub);
$resultStub->expects($this->once())

View File

@ -10,7 +10,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportSql;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -590,8 +590,8 @@ class ExportSqlTest extends AbstractTestCase
$dbi->expects($this->exactly(2))
->method('fetchValue')
->willReturnMap([
['SHOW CREATE EVENT `db`.`f1`', 'Create Event', Connection::TYPE_USER, 'f1event'],
['SHOW CREATE EVENT `db`.`f2`', 'Create Event', Connection::TYPE_USER, 'f2event'],
['SHOW CREATE EVENT `db`.`f1`', 'Create Event', ConnectionType::User, 'f1event'],
['SHOW CREATE EVENT `db`.`f2`', 'Create Event', ConnectionType::User, 'f2event'],
]);
$dbi->expects($this->any())->method('quoteString')
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
@ -1061,7 +1061,7 @@ SQL;
$dbi->expects($this->once())
->method('tryQuery')
->with('SELECT a FROM b WHERE 1', Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED)
->with('SELECT a FROM b WHERE 1', ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED)
->willReturn($resultStub);
$resultStub->expects($this->once())
@ -1161,7 +1161,7 @@ SQL;
$dbi->expects($this->once())
->method('tryQuery')
->with('SELECT a FROM b WHERE 1', Connection::TYPE_USER, DatabaseInterface::QUERY_UNBUFFERED)
->with('SELECT a FROM b WHERE 1', ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED)
->willReturn($resultStub);
$resultStub->expects($this->once())

View File

@ -11,7 +11,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Identifiers\TriggerName;
@ -293,8 +293,8 @@ class ExportTexytextTest extends AbstractTestCase
$dbi->expects($this->exactly(2))
->method('getColumns')
->willReturnMap([
['db', 'table', false, Connection::TYPE_USER, [$column]],
['db', 'table', true, Connection::TYPE_USER, [$columnFull]],
['db', 'table', false, ConnectionType::User, [$column]],
['db', 'table', true, ConnectionType::User, [$columnFull]],
]);
DatabaseInterface::$instance = $dbi;

View File

@ -9,7 +9,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\ConfigStorage\RelationCleanup;
use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Dbal\ResultInterface;
use PhpMyAdmin\Dbal\Statement;
use PhpMyAdmin\Html\Generator;
@ -1828,8 +1828,8 @@ class PrivilegesTest extends AbstractTestCase
$userQuery = 'SELECT * FROM `mysql`.`user` WHERE `User` = ? AND `Host` = ?;';
$globalPrivQuery = 'SELECT * FROM `mysql`.`global_priv` WHERE `User` = ? AND `Host` = ?;';
$dbi->expects($this->exactly(2))->method('prepare')->willReturnMap([
[$userQuery, Connection::TYPE_USER, $mysqliStmtStub],
[$globalPrivQuery, Connection::TYPE_USER, $mysqliStmtStub],
[$userQuery, ConnectionType::User, $mysqliStmtStub],
[$globalPrivQuery, ConnectionType::User, $mysqliStmtStub],
]);
$mysqliResultStub->expects($this->exactly(2))

View File

@ -8,7 +8,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\ListDatabase;
use PhpMyAdmin\Query\Cache;
use PhpMyAdmin\SqlParser\Context;
@ -82,35 +82,35 @@ class TableTest extends AbstractTestCase
$sqlAnalyzeStructureTrue,
null,
null,
Connection::TYPE_USER,
ConnectionType::User,
[['COLUMN_NAME' => 'COLUMN_NAME', 'DATA_TYPE' => 'DATA_TYPE']],
],
[
$getUniqueColumnsSql . ' WHERE (Non_unique = 0)',
['Key_name', null],
'Column_name',
Connection::TYPE_USER,
ConnectionType::User,
[['index1'], ['index3'], ['index5']],
],
[
$getUniqueColumnsSql,
'Column_name',
'Column_name',
Connection::TYPE_USER,
ConnectionType::User,
['column1', 'column3', 'column5', 'ACCESSIBLE', 'ADD', 'ALL'],
],
[
'SHOW COLUMNS FROM `PMA`.`PMA_BookMark`',
'Field',
'Field',
Connection::TYPE_USER,
ConnectionType::User,
['column1', 'column3', 'column5', 'ACCESSIBLE', 'ADD', 'ALL'],
],
[
'SHOW COLUMNS FROM `PMA`.`PMA_BookMark`',
null,
null,
Connection::TYPE_USER,
ConnectionType::User,
[
[
'Field' => 'COLUMN_NAME1',
@ -134,7 +134,7 @@ class TableTest extends AbstractTestCase
'SHOW TRIGGERS FROM `PMA` LIKE \'PMA_BookMark\';',
null,
null,
Connection::TYPE_USER,
ConnectionType::User,
[
[
'Trigger' => 'name1',
@ -166,7 +166,7 @@ class TableTest extends AbstractTestCase
'SHOW TRIGGERS FROM `PMA` LIKE \'PMA_.BookMark\';',
null,
null,
Connection::TYPE_USER,
ConnectionType::User,
[
[
'Trigger' => 'name1',
@ -197,21 +197,21 @@ class TableTest extends AbstractTestCase
];
$fetchValue = [
[$sqlIsViewTrue, 0, Connection::TYPE_USER, 'PMA_BookMark'],
[$sqlCopyData, 0, Connection::TYPE_USER, false],
[$sqlIsViewFalse, 0, Connection::TYPE_USER, false],
[$sqlIsUpdatableViewTrue, 0, Connection::TYPE_USER, 'PMA_BookMark'],
[$sqlIsUpdatableViewFalse, 0, Connection::TYPE_USER, false],
[$sqlIsViewTrue, 0, ConnectionType::User, 'PMA_BookMark'],
[$sqlCopyData, 0, ConnectionType::User, false],
[$sqlIsViewFalse, 0, ConnectionType::User, false],
[$sqlIsUpdatableViewTrue, 0, ConnectionType::User, 'PMA_BookMark'],
[$sqlIsUpdatableViewFalse, 0, ConnectionType::User, false],
[
"SELECT 1 FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'aa' AND TABLE_NAME = 'ad'",
0,
Connection::TYPE_USER,
ConnectionType::User,
'ad',
],
[
"SELECT 1 FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'bb' AND TABLE_NAME = 'ad'",
0,
Connection::TYPE_USER,
ConnectionType::User,
false,
],
];
@ -1363,19 +1363,19 @@ class TableTest extends AbstractTestCase
->willReturnMap([
[
'SHOW CREATE TABLE `aa`.`ad`',
Connection::TYPE_USER,
ConnectionType::User,
DatabaseInterface::QUERY_BUFFERED,
true,
$resultStub,
],
[
'SHOW TABLE STATUS FROM `aa` WHERE Name = \'ad\'',
Connection::TYPE_USER,
ConnectionType::User,
DatabaseInterface::QUERY_BUFFERED,
true,
$resultStub,
],
['USE `aa`', Connection::TYPE_USER, DatabaseInterface::QUERY_BUFFERED, true, $resultStub],
['USE `aa`', ConnectionType::User, DatabaseInterface::QUERY_BUFFERED, true, $resultStub],
]);
$resultStub->expects($this->any())
->method('fetchRow')

View File

@ -10,7 +10,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DummyResult;
use PhpMyAdmin\Tracking\Tracker;
@ -185,9 +185,9 @@ class TrackerTest extends AbstractTestCase
$useStatement = 'USE `pma_test`';
$showCreateTableQuery = 'SHOW CREATE TABLE `pma_test`.`pma_tbl`';
$dbi->expects($this->exactly(3))->method('tryQuery')->willReturnMap([
[$showTableStatusQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_BUFFERED, true, $resultStub],
[$useStatement, Connection::TYPE_USER, DatabaseInterface::QUERY_BUFFERED, true, $resultStub],
[$showCreateTableQuery, Connection::TYPE_USER, DatabaseInterface::QUERY_BUFFERED, true, $resultStub],
[$showTableStatusQuery, ConnectionType::User, DatabaseInterface::QUERY_BUFFERED, true, $resultStub],
[$useStatement, ConnectionType::User, DatabaseInterface::QUERY_BUFFERED, true, $resultStub],
[$showCreateTableQuery, ConnectionType::User, DatabaseInterface::QUERY_BUFFERED, true, $resultStub],
]);
$dbi->expects($this->any())->method('query')

View File

@ -10,7 +10,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Message;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Template;
@ -108,7 +108,7 @@ class UserPreferencesTest extends AbstractTestCase
$dbi->expects($this->once())
->method('fetchSingleRow')
->with($query, DatabaseInterface::FETCH_ASSOC, Connection::TYPE_CONTROL)
->with($query, DatabaseInterface::FETCH_ASSOC, ConnectionType::ControlUser)
->willReturn(['ts' => '123', 'config_data' => json_encode([1, 2])]);
$dbi->expects($this->any())
->method('quoteString')
@ -183,12 +183,12 @@ class UserPreferencesTest extends AbstractTestCase
$dbi->expects($this->once())
->method('fetchValue')
->with($query1, 0, Connection::TYPE_CONTROL)
->with($query1, 0, ConnectionType::ControlUser)
->willReturn('1');
$dbi->expects($this->once())
->method('tryQuery')
->with($query2, Connection::TYPE_CONTROL)
->with($query2, ConnectionType::ControlUser)
->willReturn($this->createStub(DummyResult::class));
$dbi->expects($this->any())
@ -213,17 +213,17 @@ class UserPreferencesTest extends AbstractTestCase
$dbi->expects($this->once())
->method('fetchValue')
->with($query1, 0, Connection::TYPE_CONTROL)
->with($query1, 0, ConnectionType::ControlUser)
->willReturn(false);
$dbi->expects($this->once())
->method('tryQuery')
->with($query2, Connection::TYPE_CONTROL)
->with($query2, ConnectionType::ControlUser)
->willReturn(false);
$dbi->expects($this->once())
->method('getError')
->with(Connection::TYPE_CONTROL)
->with(ConnectionType::ControlUser)
->willReturn('err1');
$dbi->expects($this->any())
->method('quoteString')