Skip to content

Commit

Permalink
fix: Fixed an issue where a "Integrity constraint violation" error co…
Browse files Browse the repository at this point in the history
…uld occurr if malformed `redirectSrcUrl`s was introduced into the statistics table ([#305](#305))
  • Loading branch information
khalwat committed Jun 19, 2024
1 parent 8a2f744 commit 2f67754
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/services/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ public function incrementStatistics(string $url, bool $handled = false, $siteId
}
// Normalize the $url via the validator
$stats = new StatsModel([
'redirectSrcUrl' => $url,
'redirectSrcUrl' => TextHelper::cleanupText($url),
]);
$stats->validate();
// Find any existing retour_stats record
$statsConfig = (new Query())
->from(['{{%retour_stats}}'])
->where(['redirectSrcUrl' => TextHelper::cleanupText($stats->redirectSrcUrl)])
->where(['redirectSrcUrl' => $stats->redirectSrcUrl])
->one();
// If no record is found, initialize some values
if ($statsConfig === null) {
Expand Down

0 comments on commit 2f67754

Please sign in to comment.