phpmyadmin/libraries/classes/Controllers/Server/Status/Processes/KillController.php
Maurício Meneghini Fauth 6a2c12bdc8
Add missing traversable type hints
Replace array type hint with mixed[] type hint, since it means the same.
This way it's possible to require traversable type hint for new code.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-04-02 01:32:12 -03:00

57 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server\Status\Processes;
use PhpMyAdmin\Controllers\Server\Status\AbstractController;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Message;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Server\Status\Data;
use PhpMyAdmin\Template;
use function __;
final class KillController extends AbstractController
{
public function __construct(
ResponseRenderer $response,
Template $template,
Data $data,
private DatabaseInterface $dbi,
) {
parent::__construct($response, $template, $data);
}
/** @param mixed[] $params Request parameters */
public function __invoke(ServerRequest $request, array $params): void
{
if (! $this->response->isAjax()) {
return;
}
$kill = (int) $params['id'];
$query = $this->dbi->getKillQuery($kill);
if ($this->dbi->tryQuery($query)) {
$message = Message::success(
__('Thread %s was successfully killed.'),
);
$this->response->setRequestStatus(true);
} else {
$message = Message::error(
__(
'phpMyAdmin was unable to kill thread %s. It probably has already been closed.',
),
);
$this->response->setRequestStatus(false);
}
$message->addParam($kill);
$this->response->addJSON(['message' => $message]);
}
}