phpmyadmin/libraries/classes/Controllers/Server/Status/Monitor/SlowLogController.php
ru-asdx eff7e23b60
Ref #17769 - Replace superglobals with ServerRequest in Server/Status (#17912)
* Replace superglobals with ServerRequest in Server/Status

Signed-off-by: Evgeny Skorlov <eugene@skorlov.name>
2022-11-30 14:30:46 -03:00

62 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server\Status\Monitor;
use PhpMyAdmin\Controllers\Server\Status\AbstractController;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Server\Status\Data;
use PhpMyAdmin\Server\Status\Monitor;
use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
final class SlowLogController extends AbstractController
{
/** @var Monitor */
private $monitor;
/** @var DatabaseInterface */
private $dbi;
public function __construct(
ResponseRenderer $response,
Template $template,
Data $data,
Monitor $monitor,
DatabaseInterface $dbi
) {
parent::__construct($response, $template, $data);
$this->monitor = $monitor;
$this->dbi = $dbi;
}
public function __invoke(ServerRequest $request): void
{
$GLOBALS['errorUrl'] = $GLOBALS['errorUrl'] ?? null;
$params = [
'time_start' => $request->getParsedBodyParam('time_start'),
'time_end' => $request->getParsedBodyParam('time_end'),
];
$GLOBALS['errorUrl'] = Url::getFromRoute('/');
if ($this->dbi->isSuperUser()) {
$this->dbi->selectDb('mysql');
}
if (! $this->response->isAjax()) {
return;
}
$this->response->addJSON([
'message' => $this->monitor->getJsonForLogDataTypeSlow(
(int) $params['time_start'],
(int) $params['time_end']
),
]);
}
}