Skip to content

Commit

Permalink
Remove last public use of Tracker::isTracked
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
  • Loading branch information
kamil-tekiela committed Mar 17, 2023
1 parent 938dd6f commit 8eb023b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion libraries/classes/Controllers/Table/TrackingController.php
Expand Up @@ -14,6 +14,7 @@
use PhpMyAdmin\Template;
use PhpMyAdmin\Tracking\Tracker;
use PhpMyAdmin\Tracking\Tracking;
use PhpMyAdmin\Tracking\TrackingChecker;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
use Throwable;
Expand All @@ -35,6 +36,7 @@ public function __construct(
ResponseRenderer $response,
Template $template,
private Tracking $tracking,
private TrackingChecker $trackingChecker,
) {
parent::__construct($response, $template);
}
Expand Down Expand Up @@ -64,9 +66,11 @@ public function __invoke(ServerRequest $request): void
$toggleActivation = $request->getParsedBodyParam('toggle_activation');
$reportExport = $request->getParsedBodyParam('report_export');

$trackedTables = $this->trackingChecker->getTrackedTables($GLOBALS['db']);
if (
Tracker::isActive()
&& Tracker::isTracked($GLOBALS['db'], $GLOBALS['table'])
&& isset($trackedTables[$GLOBALS['table']])
&& $trackedTables[$GLOBALS['table']]->active
&& $toggleActivation !== 'deactivate_now'
&& $reportExport !== 'sqldumpfile'
) {
Expand Down
1 change: 1 addition & 0 deletions libraries/services_controllers.php
Expand Up @@ -1615,6 +1615,7 @@
'$response' => '@response',
'$template' => '@template',
'$tracking' => '@tracking',
'$trackingChecker' => '@tracking_checker',
],
],
Table\TriggersController::class => [
Expand Down
4 changes: 3 additions & 1 deletion test/classes/Controllers/Table/TrackingControllerTest.php
Expand Up @@ -45,6 +45,7 @@ public function testTrackingController(): void

$response = new ResponseRenderer();
$template = new Template();
$trackingChecker = $this->createStub(TrackingChecker::class);
(new TrackingController(
$response,
$template,
Expand All @@ -53,8 +54,9 @@ public function testTrackingController(): void
$template,
new Relation($this->dbi),
$this->dbi,
$this->createStub(TrackingChecker::class),
$trackingChecker,
),
$trackingChecker,
))($this->createStub(ServerRequest::class));

$main = $template->render('table/tracking/main', [
Expand Down

0 comments on commit 8eb023b

Please sign in to comment.