Skip to content

Commit

Permalink
refactor: When saving a redirect, Retour no longer deletes redirects …
Browse files Browse the repository at this point in the history
…that have the `redirectDestUrl` of the redirect being saved as their `redirectSrcUrl` ([#303](#303))
  • Loading branch information
khalwat committed Jun 24, 2024
1 parent 566b52d commit 794cbf6
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions src/services/Redirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -1172,30 +1172,6 @@ public function saveRedirect(array $redirectConfig): bool
return false;
}
}
// To prevent redirect loops, see if any static redirects have our redirectDestUrl as their redirectSrcUrl
$testRedirectConfig = $this->getRedirectByRedirectSrcUrl(
$redirectConfig['redirectDestUrl'],
$redirectConfig['siteId']
);
if ($testRedirectConfig !== null) {
Craft::debug(
Craft::t(
'retour',
'Deleting redirect to prevent a loop: {redirect}',
['redirect' => print_r($testRedirectConfig, true)]
),
__METHOD__
);
// Delete the redirect that has a redirectSrcUrl the same as this record's redirectDestUrl
try {
$db->createCommand()->delete(
'{{%retour_static_redirects}}',
['id' => $testRedirectConfig['id']]
)->execute();
} catch (Exception $e) {
Craft::error($e->getMessage(), __METHOD__);
}
}
// Trigger a 'afterSaveRedirect' event
$this->trigger(self::EVENT_AFTER_SAVE_REDIRECT, $event);

Expand Down

0 comments on commit 794cbf6

Please sign in to comment.