Use DbTableExists in WrapperController

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2023-12-19 23:32:58 +01:00
parent f849cc5b17
commit 5ef643c3ff
2 changed files with 5 additions and 7 deletions

View File

@ -1576,6 +1576,7 @@ return [
'$transformations' => '@transformations',
'$relation' => '@relation',
'$dbi' => '@dbi',
'$dbTableExists' => '@' . DbTableExists::class,
],
],
UserPasswordController::class => [

View File

@ -8,6 +8,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Controllers\AbstractController;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\DbTableExists;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Identifiers\InvalidIdentifier;
@ -42,6 +43,7 @@ class WrapperController extends AbstractController
private Transformations $transformations,
private Relation $relation,
private DatabaseInterface $dbi,
private DbTableExists $dbTableExists,
) {
parent::__construct($response, $template);
}
@ -61,13 +63,8 @@ class WrapperController extends AbstractController
return;
}
$hasTable = (bool) $this->dbi->getCache()->getCachedTableContent([$db->getName(), $table->getName()]);
if (! $hasTable) {
$result = $this->dbi->tryQuery('SHOW TABLES LIKE ' . $this->dbi->quoteString($table->getName()) . ';');
$hasTable = $result !== false && $result->numRows() > 0;
if (! $hasTable) {
return;
}
if (! $this->dbTableExists->hasTable($db, $table)) {
return;
}
$query = $this->getQuery($table, $request->getParam('where_clause'), $request->getParam('where_clause_sign'));