Problem/Motivation
When a custom AliasManager is used a fatal error is thrown by the Drupal\redirect\EventSubscriber\RedirectRequestSubscriber
constructor.
Fatal error: Uncaught TypeError: Argument 4 passed to Drupal\redirect\EventSubscriber\RedirectRequestSubscriber::__construct() must be an instance of Drupal\Core\Path\AliasManager
This is because the constructor checks if the passed AliasManager is in instance of Drupal\Core\Path\AliasManager instead of the interface it implements (Drupal\Core\Path\AliasManagerInterface
).
This makes it impossible to use an alternative alias manager.
Proposed resolution
Change the type declaration from Drupal\Core\Path\AliasManager
to Drupal\Core\Path\AliasManagerInterface
.
Comment | File | Size | Author |
---|---|---|---|
#15 | redirect_should_check_for_interface-2981781-v1-6.patch | 1.36 KB | na.karimi |
#4 | redirect_should_check_for_interface-2981781-4.patch | 2.16 KB | zero2one |
|
Comments
Comment #2
zero2one CreditAttribution: zero2one at Serial Graphics for District09 commentedComment #3
zero2one CreditAttribution: zero2one at Serial Graphics for District09 commentedComment #4
zero2one CreditAttribution: zero2one at Serial Graphics for District09 commentedAttached the patch that fixes the wrong typed data in the constructor.
Comment #5
BerdirComment #8
BerdirThanks.
Comment #10
jhnnsbstnbch CreditAttribution: jhnnsbstnbch commentedHello. I just upgraded the Redirect module from version 8.x-1.5 to 8.x-1.6. I received the following error message. Can you tell me what if anything I did wrong, or what the problem could be? Thank you.
The website encountered an unexpected error. Please try again later.
TypeError: Argument 4 passed to Drupal\redirect\EventSubscriber\RedirectRequestSubscriber::__construct() must implement interface Drupal\path_alias\AliasManagerInterface, instance of Drupal\Core\Path\AliasManager given, called in /homepages/xx/d8154dddd/htdocs/xxxx/core/lib/Drupal/Component/DependencyInjection/Container.php on line 301 in Drupal\redirect\EventSubscriber\RedirectRequestSubscriber->__construct() (line 93 of modules/redirect/src/EventSubscriber/RedirectRequestSubscriber.php).
Drupal\redirect\EventSubscriber\RedirectRequestSubscriber->__construct(Object, Object, Object, Object, Object, Object, Object, Object, Object) (Line: 301)
Drupal\Component\DependencyInjection\Container->createService(Array, 'redirect.request_subscriber') (Line: 173)
Drupal\Component\DependencyInjection\Container->get('redirect.request_subscriber') (Line: 105)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.request', Object) (Line: 127)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comment #11
Berdir8.x-1.6 requires Drupal 8.8. Make sure you clear caches.
Comment #12
jhnnsbstnbch CreditAttribution: jhnnsbstnbch commentedThank you! I am using Drupal 8.8.5. Clearing caches worked... I had to do it directly in the database. Kind regards, david
Comment #13
rtnalm CreditAttribution: rtnalm commentedI'm running into this problem on Drupal 8.8.6 upgrade and clearing cache did not work. Any suggestion?All working; error with local git repo where codes did not completely checked out because of some untracked code directories.
Comment #14
na.karimi CreditAttribution: na.karimi as a volunteer commentedUpdated patch for version 1.6
Comment #15
na.karimi CreditAttribution: na.karimi as a volunteer commentedUpdated patch for version 1.6