Loading src/RedirectRepository.php +2 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,8 @@ class RedirectRepository { return $redirect; } // Reset found redirects. $this->foundRedirects = []; return NULL; } Loading tests/src/Kernel/RedirectAPITest.php +26 −0 Original line number Diff line number Diff line Loading @@ -239,6 +239,32 @@ class RedirectAPITest extends KernelTestBase { } } /** * Test loop detection reset. */ public function testLoopDetectionReset() { // Add a chained redirect that isn't a loop. /** @var \Drupal\redirect\Entity\Redirect $source */ $source = $this->controller->create(); $source->setSource('source-redirect'); $source->setRedirect('target'); $source->save(); /** @var \Drupal\redirect\Entity\Redirect $target */ $target = $this->controller->create(); $target->setSource('target'); $target->setRedirect('second-target'); $target->save(); /** @var \Drupal\redirect\RedirectRepository $repository */ $repository = \Drupal::service('redirect.repository'); $found = $repository->findMatchingRedirect('target'); $this->assertEquals($target->id(), $found->id()); $found = $repository->findMatchingRedirect('source-redirect'); $this->assertEquals($target->id(), $found->id()); } /** * Test redirect_parse_url(). */ Loading Loading
src/RedirectRepository.php +2 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,8 @@ class RedirectRepository { return $redirect; } // Reset found redirects. $this->foundRedirects = []; return NULL; } Loading
tests/src/Kernel/RedirectAPITest.php +26 −0 Original line number Diff line number Diff line Loading @@ -239,6 +239,32 @@ class RedirectAPITest extends KernelTestBase { } } /** * Test loop detection reset. */ public function testLoopDetectionReset() { // Add a chained redirect that isn't a loop. /** @var \Drupal\redirect\Entity\Redirect $source */ $source = $this->controller->create(); $source->setSource('source-redirect'); $source->setRedirect('target'); $source->save(); /** @var \Drupal\redirect\Entity\Redirect $target */ $target = $this->controller->create(); $target->setSource('target'); $target->setRedirect('second-target'); $target->save(); /** @var \Drupal\redirect\RedirectRepository $repository */ $repository = \Drupal::service('redirect.repository'); $found = $repository->findMatchingRedirect('target'); $this->assertEquals($target->id(), $found->id()); $found = $repository->findMatchingRedirect('source-redirect'); $this->assertEquals($target->id(), $found->id()); } /** * Test redirect_parse_url(). */ Loading