Changes Dbal\DatabaseName, Dbal\TableName and Triggers\TriggerName to implements the new Identifier\Identifier interface. Moves Dbal\DatabaseName, Dbal\TableName and Triggers\TriggerName to the Identifiers namespace. Renames the tryFromValue() and fromValue() methods to just tryFrom() and from() respectively. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpMyAdmin\Controllers\Table\Partition;
|
|
|
|
use PhpMyAdmin\Controllers\AbstractController;
|
|
use PhpMyAdmin\Html\Generator;
|
|
use PhpMyAdmin\Http\ServerRequest;
|
|
use PhpMyAdmin\Identifiers\DatabaseName;
|
|
use PhpMyAdmin\Identifiers\InvalidIdentifier;
|
|
use PhpMyAdmin\Identifiers\TableName;
|
|
use PhpMyAdmin\Message;
|
|
use PhpMyAdmin\Partitioning\Maintenance;
|
|
use PhpMyAdmin\ResponseRenderer;
|
|
use PhpMyAdmin\Template;
|
|
use Webmozart\Assert\Assert;
|
|
use Webmozart\Assert\InvalidArgumentException;
|
|
|
|
use function __;
|
|
|
|
final class CheckController extends AbstractController
|
|
{
|
|
private Maintenance $model;
|
|
|
|
public function __construct(
|
|
ResponseRenderer $response,
|
|
Template $template,
|
|
Maintenance $maintenance,
|
|
) {
|
|
parent::__construct($response, $template);
|
|
|
|
$this->model = $maintenance;
|
|
}
|
|
|
|
public function __invoke(ServerRequest $request): void
|
|
{
|
|
$partitionName = $request->getParsedBodyParam('partition_name');
|
|
|
|
try {
|
|
Assert::stringNotEmpty($partitionName, __('The partition name must be a non-empty string.'));
|
|
$database = DatabaseName::from($request->getParam('db'));
|
|
$table = TableName::from($request->getParam('table'));
|
|
} catch (InvalidIdentifier | InvalidArgumentException $exception) {
|
|
$message = Message::error($exception->getMessage());
|
|
$this->response->addHTML($message->getDisplay());
|
|
|
|
return;
|
|
}
|
|
|
|
[$rows, $query] = $this->model->check($database, $table, $partitionName);
|
|
|
|
$message = Generator::getMessage(
|
|
__('Your SQL query has been executed successfully.'),
|
|
$query,
|
|
'success',
|
|
);
|
|
|
|
$this->render('table/partition/check', [
|
|
'partition_name' => $partitionName,
|
|
'message' => $message,
|
|
'rows' => $rows,
|
|
]);
|
|
}
|
|
}
|