It looks like the event subscriber causes a fatal error when the splash page is enabled and I try to revert a node revision.

To reproduce:
– Enable the Splash Redirect module.
– Add a redirect and enable it.
– Edit a node that has revisions.
– Try to revert a revision. It fails, with the following error in the report log:

Error: Call to a member function id() on string in Drupal\splash_redirect\EventSubscriber\SplashRedirectEventSubscriber->onKernelRequest() (line 85 of /srv/bindings/a412afed659a45b2821f26a22622e79e/code/modules/contrib/splash_redirect/src/EventSubscriber/SplashRedirectEventSubscriber.php)

85 is the second line in this snippet:

      $route = ($this->currentRouteMatch->getParameter('node')) ?
        '/node/' . $this->currentRouteMatch->getParameter('node')->id() :
        $this->currentRouteMatch->getRouteObject()->getPath();

Any help on how to patch this would be appreciated!

Comments

KurtTrowbridge created an issue. See original summary.

adambernstein’s picture

Status: Active » Needs work

Thanks for the clear and concise bug report, I will look into this as soon as I can.

adambernstein’s picture

Assigned: Unassigned » adambernstein
adambernstein’s picture

Status: Needs work » Needs review
StatusFileSize
new2.95 KB

Here's what I've learned: this is an issue with 'revision' routes and it is a common issue for Drupal. There is an issue in the Drupal Core queue about this and it appears to be in review for the Drupal 8.8.x release. So given that this issue may soon be fixed in core, it may be better to apply this patch in the meantime while we wait for Core to be updated.

The patch adds a RouteSubscriber service to listen for revisions paths and will extract the node ID accordingly. Let me know how it works for you.

kurttrowbridge’s picture

Wow, thanks for the quick turnaround. I applied the patch on a test site and it looks like I can successfully revert revisions now!

adambernstein’s picture

Status: Needs review » Fixed

Good to hear it's working for you! Thanks for submitting the bug.

Status: Fixed » Closed (fixed)

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

grabby’s picture

StatusFileSize
new13.66 KB

I don’t see that #4 made it to 8.x-1.8. I was getting

The website encountered an unexpected error. Please try again later.
Error: Call to a member function id() on string in Drupal\splash_redirect\EventSubscriber\SplashRedirectEventSubscriber->onKernelRequest() (line 85 of modules\contrib\splash_redirect\src\EventSubscriber\SplashRedirectEventSubscriber.php).

Drupal\splash_redirect\EventSubscriber\SplashRedirectEventSubscriber->onKernelRequest(Object, 'kernel.request', Object)
call_user_func(Array, Object, 'kernel.request', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.request') (Line: 134)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
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: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
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)

before applying it to 1.8 and got the same thing afterwards. I’m attaching the patched module just to allow it to be checked.