Fix bookmarks not being properly saved

Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.com.br>
This commit is contained in:
Maurício Meneghini Fauth 2026-05-22 19:32:03 -03:00
parent 28778d272a
commit f6d656b6a3
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
26 changed files with 139 additions and 192 deletions

View File

@ -385,7 +385,7 @@ return [
VersionInformation::class => ['class' => VersionInformation::class],
BookmarkRepository::class => [
'class' => BookmarkRepository::class,
'arguments' => [DatabaseInterface::class, Relation::class],
'arguments' => [DatabaseInterface::class, Relation::class, Config::class],
],
Console::class => [
'class' => Console::class,

View File

@ -186,27 +186,12 @@ parameters:
count: 2
path: src/Bookmarks/Bookmark.php
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
Use dependency injection instead\.$#
'''
identifier: staticMethod.deprecated
count: 1
path: src/Bookmarks/BookmarkRepository.php
-
message: '#^Parameter \#1 \$row of method PhpMyAdmin\\Bookmarks\\BookmarkRepository\:\:createFromRow\(\) expects array\<string\>, array\<string\|null\> given\.$#'
identifier: argument.type
count: 3
path: src/Bookmarks/BookmarkRepository.php
-
message: '#^Parameter \#2 \$bookmarkFeature of class PhpMyAdmin\\Bookmarks\\Bookmark constructor expects PhpMyAdmin\\ConfigStorage\\Features\\BookmarkFeature, PhpMyAdmin\\ConfigStorage\\Features\\BookmarkFeature\|null given\.$#'
identifier: argument.type
count: 1
path: src/Bookmarks/BookmarkRepository.php
-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
identifier: equal.notAllowed
@ -2505,18 +2490,6 @@ parameters:
count: 1
path: src/Controllers/Sql/RelationalValuesController.php
-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
identifier: notEqual.notAllowed
count: 3
path: src/Controllers/Sql/SqlController.php
-
message: '#^Only booleans are allowed in an if condition, bool\|null given\.$#'
identifier: if.condNotBoolean
count: 1
path: src/Controllers/Sql/SqlController.php
-
message: '#^Parameter \#2 \$signature of static method PhpMyAdmin\\Core\:\:checkSqlQuerySignature\(\) expects string, mixed given\.$#'
identifier: argument.type
@ -13770,24 +13743,6 @@ parameters:
count: 1
path: tests/unit/Advisory/RulesTest.php
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
Use dependency injection instead\.$#
'''
identifier: staticMethod.deprecated
count: 2
path: tests/unit/Bookmarks/BookmarkTest.php
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
Use dependency injection instead\.$#
'''
identifier: staticMethod.deprecated
count: 3
path: tests/unit/Bookmarks/BookmarkTest.php
-
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertStringContainsString\(\) expects string, mixed given\.$#'
identifier: argument.type
@ -14280,15 +14235,6 @@ parameters:
count: 1
path: tests/unit/Controllers/CheckRelationsControllerTest.php
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
Use dependency injection instead\.$#
'''
identifier: staticMethod.deprecated
count: 2
path: tests/unit/Controllers/Console/Bookmark/AddControllerTest.php
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:

View File

@ -30,17 +30,11 @@
</PossiblyUnusedReturnValue>
</file>
<file src="src/Bookmarks/BookmarkRepository.php">
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArgument>
<code><![CDATA[$result]]></code>
<code><![CDATA[$result]]></code>
<code><![CDATA[$row]]></code>
</InvalidArgument>
<PossiblyNullArgument>
<code><![CDATA[$this->bookmarkFeature]]></code>
</PossiblyNullArgument>
</file>
<file src="src/Cache.php">
<MixedAssignment>
@ -8629,15 +8623,6 @@
<code><![CDATA[testAdvisorBytime]]></code>
</PossiblyInvalidArgument>
</file>
<file src="tests/unit/Bookmarks/BookmarkTest.php">
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
<code><![CDATA[Config::getInstance()]]></code>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
</DeprecatedMethod>
</file>
<file src="tests/unit/BrowseForeignersTest.php">
<MixedArgument>
<code><![CDATA[$result]]></code>
@ -9004,12 +8989,6 @@
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
</file>
<file src="tests/unit/Controllers/Console/Bookmark/AddControllerTest.php">
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
</file>
<file src="tests/unit/Controllers/Console/Bookmark/RefreshControllerTest.php">
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>

View File

@ -10,6 +10,7 @@ namespace PhpMyAdmin\Bookmarks;
use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Features\BookmarkFeature;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Dbal\DatabaseInterface;
use PhpMyAdmin\Identifiers\DatabaseName;
@ -20,13 +21,13 @@ use PhpMyAdmin\Util;
*/
final class BookmarkRepository
{
private BookmarkFeature|null $bookmarkFeature;
private readonly Config $config;
private RelationParameters|null $relationParameters = null;
public function __construct(private DatabaseInterface $dbi, Relation $relation)
{
$this->bookmarkFeature = $relation->getRelationParameters()->bookmarkFeature;
$this->config = Config::getInstance();
public function __construct(
private readonly DatabaseInterface $dbi,
private readonly Relation $relation,
private readonly Config $config,
) {
}
/**
@ -41,7 +42,8 @@ final class BookmarkRepository
string $database,
bool $shared = false,
): Bookmark|false {
if ($this->bookmarkFeature === null) {
$bookmarkFeature = $this->getBookmarkFeature();
if ($bookmarkFeature === null) {
return false;
}
@ -57,7 +59,7 @@ final class BookmarkRepository
return false;
}
return new Bookmark($this->dbi, $this->bookmarkFeature, $database, $shared ? '' : $user, $label, $sqlQuery);
return new Bookmark($this->dbi, $bookmarkFeature, $database, $shared ? '' : $user, $label, $sqlQuery);
}
/**
@ -74,14 +76,15 @@ final class BookmarkRepository
string $user,
string|false $db = false,
): array {
if ($this->bookmarkFeature === null) {
$bookmarkFeature = $this->getBookmarkFeature();
if ($bookmarkFeature === null) {
return [];
}
$exactUserMatch = ! $this->config->config->AllowSharedBookmarks;
$query = 'SELECT * FROM ' . Util::backquote($this->bookmarkFeature->database)
. '.' . Util::backquote($this->bookmarkFeature->bookmark)
$query = 'SELECT * FROM ' . Util::backquote($bookmarkFeature->database)
. '.' . Util::backquote($bookmarkFeature->bookmark)
. ' WHERE (`user` = ' . $this->dbi->quoteString($user);
if (! $exactUserMatch) {
$query .= " OR `user` = ''";
@ -99,7 +102,7 @@ final class BookmarkRepository
$bookmarks = [];
foreach ($result as $row) {
$bookmarks[] = $this->createFromRow($row);
$bookmarks[] = $this->createFromRow($row, $bookmarkFeature);
}
return $bookmarks;
@ -112,12 +115,13 @@ final class BookmarkRepository
string|null $user,
int $id,
): Bookmark|null {
if ($this->bookmarkFeature === null) {
$bookmarkFeature = $this->getBookmarkFeature();
if ($bookmarkFeature === null) {
return null;
}
$query = 'SELECT * FROM ' . Util::backquote($this->bookmarkFeature->database)
. '.' . Util::backquote($this->bookmarkFeature->bookmark)
$query = 'SELECT * FROM ' . Util::backquote($bookmarkFeature->database)
. '.' . Util::backquote($bookmarkFeature->bookmark)
. ' WHERE `id` = ' . $id;
if ($user !== null) {
@ -135,7 +139,7 @@ final class BookmarkRepository
$result = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, ConnectionType::ControlUser);
if ($result !== []) {
return $this->createFromRow($result);
return $this->createFromRow($result, $bookmarkFeature);
}
return null;
@ -149,12 +153,13 @@ final class BookmarkRepository
DatabaseName $db,
string $label,
): Bookmark|null {
if ($this->bookmarkFeature === null) {
$bookmarkFeature = $this->getBookmarkFeature();
if ($bookmarkFeature === null) {
return null;
}
$query = 'SELECT * FROM ' . Util::backquote($this->bookmarkFeature->database)
. '.' . Util::backquote($this->bookmarkFeature->bookmark)
$query = 'SELECT * FROM ' . Util::backquote($bookmarkFeature->database)
. '.' . Util::backquote($bookmarkFeature->bookmark)
. ' WHERE `label`'
. ' = ' . $this->dbi->quoteString($label)
. ' AND dbase = ' . $this->dbi->quoteString($db->getName())
@ -163,18 +168,18 @@ final class BookmarkRepository
$result = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, ConnectionType::ControlUser);
if ($result !== []) {
return $this->createFromRow($result);
return $this->createFromRow($result, $bookmarkFeature);
}
return null;
}
/** @param string[] $row Resource used to build the bookmark */
private function createFromRow(array $row): Bookmark
private function createFromRow(array $row, BookmarkFeature $bookmarkFeature): Bookmark
{
return new Bookmark(
$this->dbi,
$this->bookmarkFeature,
$bookmarkFeature,
$row['dbase'],
$row['user'],
$row['label'],
@ -182,4 +187,13 @@ final class BookmarkRepository
(int) $row['id'],
);
}
private function getBookmarkFeature(): BookmarkFeature|null
{
if ($this->relationParameters === null) {
$this->relationParameters = $this->relation->getRelationParameters();
}
return $this->relationParameters->bookmarkFeature;
}
}

View File

@ -23,6 +23,7 @@ use PhpMyAdmin\Url;
use PhpMyAdmin\UrlParams;
use function __;
use function is_array;
use function is_string;
use function mb_strpos;
use function str_contains;
@ -78,13 +79,12 @@ readonly class SqlController implements InvocableController
$errorUrl .= '&amp;table=' . urlencode(Current::$table);
}
/** @var array<string>|null $bkmFields */
$bkmFields = $request->getParsedBodyParam('bkm_fields');
$bookmarkFields = $this->getBookmarkFields($request->getParsedBodyParam('bkm_fields'));
$sqlQuery = $request->getParsedBodyParamAsStringOrNull('sql_query');
// Coming from a bookmark dialog
if ($bkmFields !== null && $bkmFields['bkm_sql_query'] != null) {
Current::$sqlQuery = $bkmFields['bkm_sql_query'];
if (isset($bookmarkFields['bkm_sql_query'])) {
Current::$sqlQuery = $bookmarkFields['bkm_sql_query'];
} elseif ($sqlQuery !== null) {
Current::$sqlQuery = $sqlQuery;
} elseif ($request->hasQueryParam('sql_query') && $request->hasQueryParam('sql_signature')) {
@ -98,8 +98,8 @@ readonly class SqlController implements InvocableController
}
// This one is just to fill $db
if ($bkmFields !== null && $bkmFields['bkm_database'] != null) {
Current::$database = $bkmFields['bkm_database'];
if (isset($bookmarkFields['bkm_database'])) {
Current::$database = $bookmarkFields['bkm_database'];
}
// Default to browse if no query set and we have table
@ -122,7 +122,7 @@ readonly class SqlController implements InvocableController
$request->isAjax(),
);
if (Current::$table != $tableFromSql && $tableFromSql !== '') {
if (Current::$table !== $tableFromSql && $tableFromSql !== '') {
Current::$table = $tableFromSql;
}
@ -157,8 +157,8 @@ readonly class SqlController implements InvocableController
*/
$storeBkm = $request->hasBodyParam('store_bkm');
$bkmAllUsers = $request->getParsedBodyParam('bkm_all_users'); // Should this be hasBodyParam?
if ($storeBkm && $bkmFields !== null) {
return $this->addBookmark(UrlParams::$goto, $bkmFields, (bool) $bkmAllUsers);
if ($storeBkm) {
return $this->addBookmark(UrlParams::$goto, $bookmarkFields, (bool) $bkmAllUsers);
}
/**
@ -192,31 +192,31 @@ readonly class SqlController implements InvocableController
return $this->response->response();
}
/** @param array<string> $bkmFields */
private function addBookmark(string $goto, array $bkmFields, bool $bkmAllUsers): Response
/** @param array<string> $bookmarkFields */
private function addBookmark(string $goto, array $bookmarkFields, bool $bkmAllUsers): Response
{
$bookmark = $this->bookmarkRepository->createBookmark(
$bkmFields['bkm_sql_query'],
$bkmFields['bkm_label'],
$bkmFields['bkm_user'],
$bkmFields['bkm_database'],
$bookmarkFields['bkm_sql_query'] ?? '',
$bookmarkFields['bkm_label'] ?? '',
$bookmarkFields['bkm_user'] ?? '',
$bookmarkFields['bkm_database'] ?? '',
$bkmAllUsers,
);
$result = null;
$result = false;
if ($bookmark !== false) {
$result = $bookmark->save();
}
if (! $this->response->isAjax()) {
$this->response->redirect('./' . $goto . '&label=' . $bkmFields['bkm_label']);
$this->response->redirect('./' . $goto . '&label=' . $bookmarkFields['bkm_label']);
return $this->response->response();
}
if ($result) {
$msg = Message::success(__('Bookmark %s has been created.'));
$msg->addParam($bkmFields['bkm_label']);
$msg->addParam($bookmarkFields['bkm_label']);
$this->response->addJSON('message', $msg);
return $this->response->response();
@ -228,4 +228,23 @@ readonly class SqlController implements InvocableController
return $this->response->response();
}
/** @return array{bkm_label?: string, bkm_database?: string, bkm_sql_query?: string, bkm_user?: string} */
private function getBookmarkFields(mixed $param): array
{
if (! is_array($param)) {
return [];
}
$fields = [];
foreach (['bkm_label', 'bkm_database', 'bkm_sql_query', 'bkm_user'] as $key) {
if (! isset($param[$key]) || ! is_string($param[$key])) {
continue;
}
$fields[$key] = $param[$key];
}
return $fields;
}
}

View File

@ -23,8 +23,9 @@ final class BookmarkRepositoryTest extends AbstractTestCase
RelationParameters::BOOKMARK => 'pma_bookmark',
]);
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters);
$config = new Config();
$dbi = $this->createDatabaseInterface();
$bookmarkRepository = new BookmarkRepository($dbi, new Relation($dbi, new Config()));
$bookmarkRepository = new BookmarkRepository($dbi, new Relation($dbi, $config), $config);
$bookmark = $bookmarkRepository->createBookmark('SELECT "phpmyadmin"', 'bookmark1', 'root', 'phpmyadmin');
self::assertNotFalse($bookmark);
self::assertSame(0, $bookmark->getId());

View File

@ -9,19 +9,13 @@ use PhpMyAdmin\Bookmarks\BookmarkRepository;
use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\ConfigStorage\RelationParameters;
use PhpMyAdmin\Dbal\DatabaseInterface;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DbiDummy;
use PHPUnit\Framework\Attributes\CoversClass;
use ReflectionProperty;
#[CoversClass(Bookmark::class)]
class BookmarkTest extends AbstractTestCase
{
protected DatabaseInterface $dbi;
protected DbiDummy $dummyDbi;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
@ -30,10 +24,6 @@ class BookmarkTest extends AbstractTestCase
{
parent::setUp();
$this->dummyDbi = $this->createDbiDummy();
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
DatabaseInterface::$instance = $this->dbi;
$relationParameters = RelationParameters::fromArray([
RelationParameters::BOOKMARK_WORK => true,
RelationParameters::DATABASE => 'phpmyadmin',
@ -47,19 +37,19 @@ class BookmarkTest extends AbstractTestCase
*/
public function testGetList(): void
{
$this->dummyDbi->addResult(
$dbiDummy = $this->createDbiDummy();
$dbiDummy->addResult(
'SELECT * FROM `phpmyadmin`.`pma_bookmark` WHERE (`user` = \'root\' OR `user` = \'\')'
. ' AND dbase = \'sakila\' ORDER BY label ASC',
[['1', 'sakila', 'root', 'label', 'SELECT * FROM `actor` WHERE `actor_id` < 10;']],
['id', 'dbase', 'user', 'label', 'query'],
);
$dbi = DatabaseInterface::getInstance();
$actual = (new BookmarkRepository($dbi, new Relation($dbi)))->getList(
Config::getInstance()->selectedServer['user'],
'sakila',
);
$config = new Config();
$dbi = $this->createDatabaseInterface($dbiDummy, $config);
$bookmarkRepository = new BookmarkRepository($dbi, new Relation($dbi, $config), $config);
$actual = $bookmarkRepository->getList($config->selectedServer['user'], 'sakila');
self::assertContainsOnlyInstancesOf(Bookmark::class, $actual);
$this->dummyDbi->assertAllSelectsConsumed();
$dbiDummy->assertAllSelectsConsumed();
}
/**
@ -67,18 +57,16 @@ class BookmarkTest extends AbstractTestCase
*/
public function testGet(): void
{
$this->dummyDbi->addResult(
$dbiDummy = $this->createDbiDummy();
$dbiDummy->addResult(
"SELECT * FROM `phpmyadmin`.`pma_bookmark` WHERE `id` = 1 AND (user = 'root' OR user = '') LIMIT 1",
[],
['id', 'dbase', 'user', 'label', 'query'],
);
$dbi = DatabaseInterface::getInstance();
self::assertNull(
(new BookmarkRepository($dbi, new Relation($dbi)))->get(
Config::getInstance()->selectedServer['user'],
1,
),
);
$config = new Config();
$dbi = $this->createDatabaseInterface($dbiDummy, $config);
$bookmarkRepository = new BookmarkRepository($dbi, new Relation($dbi, $config), $config);
self::assertNull($bookmarkRepository->get($config->selectedServer['user'], 1));
}
/**
@ -86,18 +74,17 @@ class BookmarkTest extends AbstractTestCase
*/
public function testSave(): void
{
$this->dummyDbi->addResult(
$dbiDummy = $this->createDbiDummy();
$dbiDummy->addResult(
'INSERT INTO `phpmyadmin`.`pma_bookmark` (id, dbase, user, query, label)' .
" VALUES (NULL, 'phpmyadmin', 'root', 'SELECT \\\"phpmyadmin\\\"', 'bookmark1')",
true,
);
$dbi = DatabaseInterface::getInstance();
$bookmark = (new BookmarkRepository($dbi, new Relation($dbi)))->createBookmark(
'SELECT "phpmyadmin"',
'bookmark1',
'root',
'phpmyadmin',
);
$config = new Config();
$dbi = $this->createDatabaseInterface($dbiDummy, $config);
$relation = new Relation($dbi, $config);
$bookmarkRepository = new BookmarkRepository($dbi, $relation, $config);
$bookmark = $bookmarkRepository->createBookmark('SELECT "phpmyadmin"', 'bookmark1', 'root', 'phpmyadmin');
self::assertNotFalse($bookmark);
self::assertTrue($bookmark->save());
}

View File

@ -22,7 +22,7 @@ class ConsoleTest extends AbstractTestCase
$dbi = DatabaseInterface::getInstance();
$config = Config::getInstance();
$relation = new Relation($dbi);
$bookmarkRepository = new BookmarkRepository($dbi, $relation);
$bookmarkRepository = new BookmarkRepository($dbi, $relation, $config);
$history = new History($dbi, $relation, $config);
$console = new Console($relation, new Template($config), $bookmarkRepository, $history);
self::assertSame(['console.js'], $console->getScripts());

View File

@ -23,6 +23,7 @@ class AddControllerTest extends AbstractTestCase
{
public function testWithInvalidParams(): void
{
$config = new Config();
$dbi = $this->createDatabaseInterface();
DatabaseInterface::$instance = $dbi;
$response = new ResponseRenderer();
@ -33,24 +34,24 @@ class AddControllerTest extends AbstractTestCase
'bookmark_query' => null,
'shared' => null,
]);
$relation = new Relation($dbi);
$bookmarkRepository = new BookmarkRepository($dbi, $relation);
$controller = new AddController($response, $bookmarkRepository, new Config());
$relation = new Relation($dbi, $config);
$bookmarkRepository = new BookmarkRepository($dbi, $relation, $config);
$controller = new AddController($response, $bookmarkRepository, $config);
$this->expectException(InvalidArgumentException::class);
$controller($request);
}
public function testWithoutRelationParameters(): void
{
$config = Config::getInstance();
$config = new Config();
$config->selectedServer['user'] = 'user';
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, null);
$dbi = $this->createDatabaseInterface();
DatabaseInterface::$instance = $dbi;
$response = new ResponseRenderer();
$request = self::createStub(ServerRequest::class);
$relation = new Relation($dbi);
$bookmarkRepository = new BookmarkRepository($dbi, $relation);
$relation = new Relation($dbi, $config);
$bookmarkRepository = new BookmarkRepository($dbi, $relation, $config);
$controller = new AddController($response, $bookmarkRepository, $config);
$controller($request);
self::assertSame(['message' => 'Failed'], $response->getJSONResult());
@ -58,7 +59,7 @@ class AddControllerTest extends AbstractTestCase
public function testWithValidParameters(): void
{
$config = Config::getInstance();
$config = new Config();
$config->selectedServer['user'] = 'test_user';
$relationParameters = RelationParameters::fromArray([
RelationParameters::USER => 'test_user',
@ -84,8 +85,8 @@ class AddControllerTest extends AbstractTestCase
'bookmark_query' => 'test_query',
'shared' => 'true',
]);
$relation = new Relation($dbi);
$bookmarkRepository = new BookmarkRepository($dbi, $relation);
$relation = new Relation($dbi, $config);
$bookmarkRepository = new BookmarkRepository($dbi, $relation, $config);
$controller = new AddController($response, $bookmarkRepository, $config);
$controller($request);
self::assertSame(

View File

@ -26,8 +26,8 @@ class RefreshControllerTest extends AbstractTestCase
$response = new ResponseRenderer();
$dbi = DatabaseInterface::getInstance();
$config = Config::getInstance();
$relation = new Relation($dbi);
$bookmarkRepository = new BookmarkRepository($dbi, $relation);
$relation = new Relation($dbi, $config);
$bookmarkRepository = new BookmarkRepository($dbi, $relation, $config);
$template = new Template($config);
$history = new History($dbi, $relation, $config);
$controller = new RefreshController(

View File

@ -75,7 +75,7 @@ final class QueryControllerTest extends AbstractTestCase
new RelationCleanup($dbi, $relation),
new Transformations($dbi, $relation),
new Template($config),
new BookmarkRepository($dbi, $relation),
new BookmarkRepository($dbi, $relation, $config),
$config,
$responseRenderer,
);

View File

@ -56,7 +56,7 @@ final class SqlControllerTest extends AbstractTestCase
return new SqlController(
$responseRenderer,
new SqlQueryForm($template, $dbi, new BookmarkRepository($dbi, $relation)),
new SqlQueryForm($template, $dbi, new BookmarkRepository($dbi, $relation, $config)),
new PageSettings(new UserPreferences($dbi, $relation, $template, $config, new Clock()), $responseRenderer),
new DbTableExists($dbi),
);

View File

@ -71,7 +71,7 @@ final class TrackingControllerTest extends AbstractTestCase
return new TrackingController(
new ResponseRenderer(),
new Tracking(
new SqlQueryForm($template, $dbi, new BookmarkRepository($dbi, $relation)),
new SqlQueryForm($template, $dbi, new BookmarkRepository($dbi, $relation, $config)),
$template,
$relation,
$dbi,

View File

@ -85,8 +85,8 @@ class ImportControllerTest extends AbstractTestCase
);
$responseRenderer = new ResponseRenderer();
$relation = new Relation($this->dbi);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation);
$relation = new Relation($this->dbi, $config);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation, $config);
$template = new Template($config);
$sql = new Sql(
$this->dbi,

View File

@ -62,8 +62,8 @@ class EnumValuesControllerTest extends AbstractTestCase
$responseRenderer = new ResponseRenderer();
$config = Config::getInstance();
$template = new Template($config);
$relation = new Relation($this->dbi);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation);
$relation = new Relation($this->dbi, $config);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation, $config);
$sql = new Sql(
$this->dbi,
$relation,
@ -125,8 +125,8 @@ class EnumValuesControllerTest extends AbstractTestCase
$responseRenderer = new ResponseRenderer();
$config = Config::getInstance();
$template = new Template($config);
$relation = new Relation($this->dbi);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation);
$relation = new Relation($this->dbi, $config);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation, $config);
$sql = new Sql(
$this->dbi,
$relation,

View File

@ -62,8 +62,8 @@ class SetValuesControllerTest extends AbstractTestCase
$responseRenderer = new ResponseRenderer();
$config = Config::getInstance();
$template = new Template($config);
$relation = new Relation($this->dbi);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation);
$relation = new Relation($this->dbi, $config);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation, $config);
$sql = new Sql(
$this->dbi,
$relation,
@ -125,8 +125,8 @@ class SetValuesControllerTest extends AbstractTestCase
$responseRenderer = new ResponseRenderer();
$config = Config::getInstance();
$template = new Template($config);
$relation = new Relation($this->dbi);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation);
$relation = new Relation($this->dbi, $config);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation, $config);
$sql = new Sql(
$this->dbi,
$relation,

View File

@ -69,7 +69,7 @@ class DeleteRowsControllerTest extends AbstractTestCase
new RelationCleanup($dbi, $relation),
new Transformations($dbi, $relation),
new Template($config),
new BookmarkRepository($dbi, $relation),
new BookmarkRepository($dbi, $relation, $config),
$config,
$response,
);

View File

@ -96,13 +96,13 @@ class ReplaceControllerTest extends AbstractTestCase
$dummyDbi = $this->createDbiDummy();
$dbi = $this->createDatabaseInterface($dummyDbi);
$config = Config::getInstance();
$relation = new Relation($dbi);
$relation = new Relation($dbi, $config);
$transformations = new Transformations($dbi, $relation);
$template = new Template($config);
$response = new ResponseRenderer();
$pageSettings = self::createStub(PageSettings::class);
$bookmarkRepository = new BookmarkRepository($dbi, $relation);
$bookmarkRepository = new BookmarkRepository($dbi, $relation, $config);
$sqlController = new SqlController(
$response,
new Sql(

View File

@ -54,7 +54,7 @@ final class SearchControllerTest extends AbstractTestCase
new RelationCleanup($dbi, $relation),
new Transformations($dbi, $relation),
$template,
new BookmarkRepository($dbi, $relation),
new BookmarkRepository($dbi, $relation, $config),
$config,
$responseRenderer,
);

View File

@ -44,9 +44,10 @@ final class SqlControllerTest extends AbstractTestCase
$dbiDummy->addResult('SELECT 1 FROM `test_db`.`test_table` LIMIT 1;', [['1']]);
$template = new Template($config);
$relation = new Relation($dbi, $config);
$userPreferences = new UserPreferences(
$dbi,
new Relation($dbi, $config),
$relation,
$template,
$config,
new Clock(),
@ -54,8 +55,7 @@ final class SqlControllerTest extends AbstractTestCase
$request = ServerRequestFactory::create()->createServerRequest('GET', 'http://example.com/')
->withQueryParams(['db' => 'test_db', 'table' => 'test_table']);
$relation = new Relation($dbi);
$bookmarkRepository = new BookmarkRepository($dbi, $relation);
$bookmarkRepository = new BookmarkRepository($dbi, $relation, $config);
$responseRenderer = new ResponseRenderer();
$response = (new SqlController(
$responseRenderer,

View File

@ -57,8 +57,8 @@ class TrackingControllerTest extends AbstractTestCase
$responseRenderer = new ResponseRenderer();
$template = new Template($config);
$trackingChecker = self::createStub(TrackingChecker::class);
$relation = new Relation($this->dbi);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation);
$relation = new Relation($this->dbi, $config);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation, $config);
$response = (new TrackingController(
$responseRenderer,
new Tracking(

View File

@ -72,7 +72,7 @@ class HeaderTest extends AbstractTestCase
return new Header(
$template,
new Console($relation, $template, new BookmarkRepository($dbi, $relation), $history),
new Console($relation, $template, new BookmarkRepository($dbi, $relation, $config), $history),
$config,
$dbi,
$relation,
@ -91,7 +91,7 @@ class HeaderTest extends AbstractTestCase
$relation = new Relation($dbi, $config);
$template = new Template($config);
$history = new History($dbi, $relation, $config);
$console = new Console($relation, $template, new BookmarkRepository($dbi, $relation), $history);
$console = new Console($relation, $template, new BookmarkRepository($dbi, $relation, $config), $history);
$userPreferences = new UserPreferences($dbi, $relation, $template, $config, new Clock());
$userPreferencesHandler = new UserPreferencesHandler(
$config,

View File

@ -56,7 +56,7 @@ class SqlQueryFormTest extends AbstractTestCase
DatabaseInterface::$instance = $this->dbi;
$config = Config::getInstance();
$relation = new Relation($this->dbi);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation);
$bookmarkRepository = new BookmarkRepository($this->dbi, $relation, $config);
$this->sqlQueryForm = new SqlQueryForm(new Template($config), $this->dbi, $bookmarkRepository);
Current::$database = 'PMA_db';

View File

@ -60,7 +60,7 @@ class SqlTest extends AbstractTestCase
new RelationCleanup($this->dbi, $relation),
new Transformations($this->dbi, $relation),
new Template($config),
new BookmarkRepository($this->dbi, $relation),
new BookmarkRepository($this->dbi, $relation, $config),
$config,
new ResponseRenderer(),
);
@ -667,7 +667,7 @@ class SqlTest extends AbstractTestCase
new RelationCleanup($this->dbi, $relation),
new Transformations($this->dbi, $relation),
new Template($config),
new BookmarkRepository($this->dbi, $relation),
new BookmarkRepository($this->dbi, $relation, $config),
$config,
new ResponseRenderer(),
);

View File

@ -63,7 +63,7 @@ class ResponseRenderer extends \PhpMyAdmin\ResponseRenderer
$dbi = DatabaseInterface::getInstanceForTest($dummyDbi, $config);
$relation = new Relation($dbi, $config);
$history = new History($dbi, $relation, $config);
$console = new Console($relation, $template, new BookmarkRepository($dbi, $relation), $history);
$console = new Console($relation, $template, new BookmarkRepository($dbi, $relation, $config), $history);
$userPreferences = new UserPreferences($dbi, $relation, $template, $config, new Clock());
$userPreferencesHandler = new UserPreferencesHandler(
$config,

View File

@ -65,8 +65,8 @@ final class TrackingTest extends AbstractTestCase
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters);
$template = new Template($config);
$relation = new Relation($dbi);
$bookmarkRepository = new BookmarkRepository($dbi, $relation);
$relation = new Relation($dbi, $config);
$bookmarkRepository = new BookmarkRepository($dbi, $relation, $config);
$this->tracking = new Tracking(
new SqlQueryForm($template, $dbi, $bookmarkRepository),
$template,