- Issue created by @alecsmrekar
- 🇷🇴Romania amateescu
Looks good to me :) Since this is just a load safety check, I don't think it needs test coverage.
Redirect currently does not play nicely with the trash module. Once redirects become revisionable ✨ Convert Redirect entity to revisionable Needs work , this will be problematic.
Error:
TypeError: Drupal\redirect\RedirectRepository::findByRedirect(): Argument #1 ($redirect) must be of type Drupal\redirect\Entity\Redirect, null given, called in /var/www/html/docroot/modules/contrib/redirect/src/RedirectRepository.php on line 125 in Drupal\redirect\RedirectRepository->findByRedirect() (line 149 of modules/contrib/redirect/src/RedirectRepository.php).
Drupal\redirect\RedirectRepository->findMatchingRedirect() (Line: 151)
Drupal\redirect\EventSubscriber\RedirectRequestSubscriber->onKernelRequestCheckRedirect() (Line: 246)
diff --git i/redirect.module w/redirect.module
index 4cfb3ca..1680c1b 100644
--- i/redirect.module
+++ w/redirect.module
@@ -15,6 +15,13 @@ use Drupal\redirect\Entity\Redirect;
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
+function redirect_entity_storage_load(array &$entities, string $entity_type_id): void {
+ if ($entity_type_id === 'redirect') {
+ // Mimic what module trash would do for a deleted entity.
+ $entities = [];
+ }
+}
+
/**
* Implements hook_hook_info().
*/
Add a check to findMatchingRedirect
to see if the ::load
method actually returned an entity.
Active
1.0
Code
Looks good to me :) Since this is just a load safety check, I don't think it needs test coverage.