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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zero2one created an issue. See original summary.

zero2one’s picture

Issue summary: View changes
zero2one’s picture

Issue summary: View changes
zero2one’s picture

Attached the patch that fixes the wrong typed data in the constructor.

Berdir’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: redirect_should_check_for_interface-2981781-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • Berdir committed a7de3d8 on 8.x-1.x authored by zero2one
    Issue #2981781 by zero2one: The RedirectRequestSubscriber constructor...
Berdir’s picture

Status: Needs work » Fixed

Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jhnnsbstnbch’s picture

Hello. 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)

Berdir’s picture

8.x-1.6 requires Drupal 8.8. Make sure you clear caches.

jhnnsbstnbch’s picture

Thank you! I am using Drupal 8.8.5. Clearing caches worked... I had to do it directly in the database. Kind regards, david

rtnalm’s picture

I'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.

na.karimi’s picture

Updated patch for version 1.6

na.karimi’s picture