From 5aab1cb6a48645854eb244d0ea2321e78594e3be Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Sun, 23 Jun 2024 20:34:06 -0400 Subject: [PATCH] refactor: When saving a redirect, Retour no longer deletes redirects that have the `redirectDestUrl` of the redirect being saved as their `redirectSrcUrl` ([#303](https://github.com/nystudio107/craft-retour/issues/303)) --- src/services/Redirects.php | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/services/Redirects.php b/src/services/Redirects.php index e8481dd6..100dad03 100644 --- a/src/services/Redirects.php +++ b/src/services/Redirects.php @@ -1201,30 +1201,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);