-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19171 from kamil-tekiela/Tracking-refactoring
Tracking refactoring
- Loading branch information
Showing
6 changed files
with
78 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,8 @@ | |
use PhpMyAdmin\LanguageManager; | ||
use PhpMyAdmin\Message; | ||
use PhpMyAdmin\ResponseRenderer; | ||
use PhpMyAdmin\Tracking\LogTypeEnum; | ||
use PhpMyAdmin\Tracking\LogType; | ||
use PhpMyAdmin\Tracking\TrackedDataType; | ||
use PhpMyAdmin\Tracking\Tracker; | ||
use PhpMyAdmin\Tracking\Tracking; | ||
use PhpMyAdmin\Tracking\TrackingChecker; | ||
|
@@ -30,7 +31,6 @@ | |
use function array_map; | ||
use function explode; | ||
use function htmlspecialchars; | ||
use function in_array; | ||
use function is_array; | ||
use function mb_strlen; | ||
use function sprintf; | ||
|
@@ -107,7 +107,7 @@ public function __invoke(ServerRequest $request): Response|null | |
/** @var string $tableParam */ | ||
$tableParam = $request->getParsedBodyParam('table'); | ||
|
||
$logType = $this->validateLogTypeParam($request->getParsedBodyParam('log_type')); | ||
$logType = LogType::tryFrom((string) $request->getParsedBodyParam('log_type')) ?? LogType::SchemaAndData; | ||
Check warning on line 110 in src/Controllers/Table/TrackingController.php GitHub Actions / Infection (8.2, ubuntu-latest)
|
||
|
||
$message = ''; | ||
$sqlDump = ''; | ||
|
@@ -162,7 +162,7 @@ public function __invoke(ServerRequest $request): Response|null | |
Current::$table, | ||
$versionParam, | ||
$trackedData->ddlog, | ||
LogTypeEnum::DDL, | ||
TrackedDataType::DDL, | ||
(int) $request->getParsedBodyParam('delete_ddlog'), | ||
); | ||
// After deletion reload data from the database | ||
|
@@ -173,7 +173,7 @@ public function __invoke(ServerRequest $request): Response|null | |
Current::$table, | ||
$versionParam, | ||
$trackedData->dmlog, | ||
LogTypeEnum::DML, | ||
TrackedDataType::DML, | ||
(int) $request->getParsedBodyParam('delete_dmlog'), | ||
); | ||
// After deletion reload data from the database | ||
|
@@ -273,12 +273,6 @@ public function __invoke(ServerRequest $request): Response|null | |
return null; | ||
} | ||
|
||
/** @psalm-return 'schema'|'data'|'schema_and_data' */ | ||
private function validateLogTypeParam(mixed $param): string | ||
{ | ||
return in_array($param, ['schema', 'data'], true) ? $param : 'schema_and_data'; | ||
} | ||
|
||
private function validateDateTimeParam(mixed $param): DateTimeImmutable | ||
{ | ||
try { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpMyAdmin\Tracking; | ||
|
||
enum LogType: string | ||
{ | ||
case Schema = 'schema'; | ||
case Data = 'data'; | ||
case SchemaAndData = 'schema_and_data'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.