From 6d262b3b7a70deb277cd98147e02c41ff2129950 Mon Sep 17 00:00:00 2001 From: Dani Garcia Date: Mon, 12 Feb 2024 16:29:12 +0100 Subject: [PATCH 1/2] commandlog/show command: fixed deep search regexp --- CommandlogBundle/Command/ShowCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CommandlogBundle/Command/ShowCommand.php b/CommandlogBundle/Command/ShowCommand.php index a966f8e..3d1e452 100644 --- a/CommandlogBundle/Command/ShowCommand.php +++ b/CommandlogBundle/Command/ShowCommand.php @@ -128,7 +128,7 @@ private function getEntityChangelog(string $entity, string $id, OutputInterface $replacements = [ ':entityId' => $id, ':entity' => $this->connection->quote($entity), - ':data' => '.*\,"arguments":\\[.*[\[,",\,]'. $id .'[\],",\,].*' + ':data' => '"arguments": *\\\\[.*[\\\\[," ]' . $id . '[\\\\]," ]' ]; $query = str_replace( From 4409cf9433bb61c06feb6c9df4647c30a44dc732 Mon Sep 17 00:00:00 2001 From: Dani Garcia Date: Mon, 19 Feb 2024 16:42:53 +0100 Subject: [PATCH 2/2] commandlog/show command: made deep search optional with param --- CommandlogBundle/Command/ShowCommand.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/CommandlogBundle/Command/ShowCommand.php b/CommandlogBundle/Command/ShowCommand.php index 3d1e452..614fa36 100644 --- a/CommandlogBundle/Command/ShowCommand.php +++ b/CommandlogBundle/Command/ShowCommand.php @@ -57,7 +57,14 @@ protected function configure() null, InputOption::VALUE_NONE, 'Show detailed command payload?' - ); + ) + ->addOption( + 'deep', + 'd', + InputOption::VALUE_NONE, + 'Deep search including mass updates, deletes, etc.' + ) + ; } protected function execute(InputInterface $input, OutputInterface $output) @@ -75,6 +82,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $entity, $id, $output, + $input->getOption('deep'), $input->getOption('detailed') ); @@ -118,12 +126,17 @@ private function findEntityByTable(string $table) throw new \Exception('Table does not exist or its not loggable'); } - private function getEntityChangelog(string $entity, string $id, OutputInterface $output, bool $detailed) + private function getEntityChangelog(string $entity, string $id, OutputInterface $output, bool $deepSearch, bool $detailed) { + $deepSearchSql = $deepSearch + ? ' OR (entityId = 0 AND data REGEXP \':data\')' + : ''; + $queryStr = 'select id, commandId, data, createdOn from Changelog where entity = :entity' - . ' and (entityId = \':entityId\' OR (entityId = 0 and data REGEXP \':data\'))' - . ' order by createdOn asc, microtime asc'; + . ' and (entityId = \':entityId\'' + . $deepSearchSql + . ') order by createdOn asc, microtime asc'; $replacements = [ ':entityId' => $id,