Skip to content

Commit

Permalink
Merge pull request #29 from irontec/CDD-15-wrong-regexp-changelog
Browse files Browse the repository at this point in the history
Fixed regexp in changelog
  • Loading branch information
danigargar authored Feb 20, 2024
2 parents 61dab1b + 4409cf9 commit 701a7dd
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions CommandlogBundle/Command/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -75,6 +82,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$entity,
$id,
$output,
$input->getOption('deep'),
$input->getOption('detailed')
);

Expand Down Expand Up @@ -118,17 +126,22 @@ 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,
':entity' => $this->connection->quote($entity),
':data' => '.*\,"arguments":\\[.*[\[,",\,]'. $id .'[\],",\,].*'
':data' => '"arguments": *\\\\[.*[\\\\[," ]' . $id . '[\\\\]," ]'
];

$query = str_replace(
Expand Down

0 comments on commit 701a7dd

Please sign in to comment.