Merge pull request #17806 from sivadasrajan/refactoring-db-table
Refactored Bookmark::get() for DatabaseName
This commit is contained in:
commit
b25dc2426e
@ -9,6 +9,7 @@ namespace PhpMyAdmin;
|
||||
|
||||
use PhpMyAdmin\ConfigStorage\Features\BookmarkFeature;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseName;
|
||||
|
||||
use function count;
|
||||
use function preg_match_all;
|
||||
@ -275,7 +276,7 @@ class Bookmark
|
||||
*
|
||||
* @param DatabaseInterface $dbi DatabaseInterface object
|
||||
* @param string $user Current user
|
||||
* @param string $db the current database name
|
||||
* @param DatabaseName $db the current database name
|
||||
* @param int|string $id an identifier of the bookmark to get
|
||||
* @param string $id_field which field to look up the identifier
|
||||
* @param bool $action_bookmark_all true: get all bookmarks regardless
|
||||
@ -287,7 +288,7 @@ class Bookmark
|
||||
public static function get(
|
||||
DatabaseInterface $dbi,
|
||||
string $user,
|
||||
string $db,
|
||||
DatabaseName $db,
|
||||
$id,
|
||||
string $id_field = 'id',
|
||||
bool $action_bookmark_all = false,
|
||||
@ -301,7 +302,7 @@ class Bookmark
|
||||
|
||||
$query = 'SELECT * FROM ' . Util::backquote($bookmarkFeature->database)
|
||||
. '.' . Util::backquote($bookmarkFeature->bookmark)
|
||||
. " WHERE dbase = '" . $dbi->escapeString($db) . "'";
|
||||
. " WHERE dbase = '" . $dbi->escapeString($db->getName()) . "'";
|
||||
if (! $action_bookmark_all) {
|
||||
$query .= " AND (user = '"
|
||||
. $dbi->escapeString($user) . "'";
|
||||
|
||||
@ -9,6 +9,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\AbstractController;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Dbal\DatabaseName;
|
||||
use PhpMyAdmin\Encoding;
|
||||
use PhpMyAdmin\File;
|
||||
use PhpMyAdmin\Html\Generator;
|
||||
@ -332,7 +333,7 @@ final class ImportController extends AbstractController
|
||||
$bookmark = Bookmark::get(
|
||||
$this->dbi,
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$GLOBALS['db'],
|
||||
DatabaseName::fromValue($GLOBALS['db']),
|
||||
$id_bookmark,
|
||||
'id',
|
||||
isset($_POST['action_bookmark_all'])
|
||||
@ -363,7 +364,7 @@ final class ImportController extends AbstractController
|
||||
$bookmark = Bookmark::get(
|
||||
$this->dbi,
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$GLOBALS['db'],
|
||||
DatabaseName::fromValue($GLOBALS['db']),
|
||||
$id_bookmark
|
||||
);
|
||||
if (! $bookmark instanceof Bookmark) {
|
||||
@ -388,7 +389,7 @@ final class ImportController extends AbstractController
|
||||
$bookmark = Bookmark::get(
|
||||
$this->dbi,
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
$GLOBALS['db'],
|
||||
DatabaseName::fromValue($GLOBALS['db']),
|
||||
$id_bookmark
|
||||
);
|
||||
if (! $bookmark instanceof Bookmark) {
|
||||
|
||||
@ -7,6 +7,7 @@ namespace PhpMyAdmin;
|
||||
use PhpMyAdmin\ConfigStorage\Features\BookmarkFeature;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\ConfigStorage\RelationCleanup;
|
||||
use PhpMyAdmin\Dbal\DatabaseName;
|
||||
use PhpMyAdmin\Dbal\ResultInterface;
|
||||
use PhpMyAdmin\Display\DisplayParts;
|
||||
use PhpMyAdmin\Display\Results as DisplayResults;
|
||||
@ -481,7 +482,7 @@ class Sql
|
||||
*/
|
||||
public function getDefaultSqlQueryForBrowse($db, $table): string
|
||||
{
|
||||
$bookmark = Bookmark::get($this->dbi, $GLOBALS['cfg']['Server']['user'], $db, $table, 'label', false, true);
|
||||
$bookmark = Bookmark::get($this->dbi, $GLOBALS['cfg']['Server']['user'], DatabaseName::fromValue($db), $table, 'label', false, true);
|
||||
|
||||
if ($bookmark !== null && $bookmark->getQuery() !== '') {
|
||||
$GLOBALS['using_bookmark_message'] = Message::notice(
|
||||
|
||||
@ -71,7 +71,7 @@ class BookmarkTest extends AbstractTestCase
|
||||
Bookmark::get(
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
'phpmyadmin',
|
||||
DatabaseName::fromValue('phpmyadmin'),
|
||||
'1'
|
||||
)
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user