Problem/Motivation

CurrentRouteMatch::getRouteMatch() is smart enough to only statically cache the route match once it believe routing has finished.
Unfortunately, a complex RouteFilter (like the one in Page Manager) may need to alter the request during filtering, and if any code calls the route match during that process, a stale request will be stored.

Proposed resolution

Add a method to reset the route match static cache.

Remaining tasks

N/A

User interface changes

N/A

API changes

BC-compatible API addition: A new CurrentRouteMatchInterface is used and is given the new resetRouteMatch() method.

Data model changes

N/A

Comments

tim.plunkett created an issue. See original summary.

tim.plunkett’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new3.09 KB
new3.14 KB

The FAIL patch has the method body emptied out, since it must be implemented to prevent a fatal.

dawehner’s picture

+++ b/core/lib/Drupal/Core/Routing/CurrentRouteMatchInterface.php
@@ -0,0 +1,25 @@
+/**
+ * @todo.
+ */
+interface CurrentRouteMatchInterface extends RouteMatchInterface, StackedRouteMatchInterface {

Well, the StackedRouteMatchInterface was about that, so ideally we have a ResetableStackedRouteMatch

tim.plunkett’s picture

Issue summary: View changes
StatusFileSize
new3.24 KB

+1

The last submitted patch, 2: 2659144-route_match-2-FAIL.patch, failed testing.

dawehner’s picture

Status: Needs review » Needs work

For a second I was considering to suggest to use serialize + hashing as the key to always be unique about it, but this would most probably add quite some performance overhead.

  1. +++ b/core/lib/Drupal/Core/Routing/ResettableStackedRouteMatchInterface.php
    @@ -0,0 +1,25 @@
    +/**
    + * Defines an interface for a resettable stack of route matches.
    + */
    

    Do you mind adding the todo still?

  2. +++ b/core/lib/Drupal/Core/Routing/ResettableStackedRouteMatchInterface.php
    @@ -0,0 +1,25 @@
    +interface ResettableStackedRouteMatchInterface extends StackedRouteMatchInterface {
    

    Can someone fix english to use Resetable instead of Resettable?

tim.plunkett’s picture

Can't help you with #6.2, but took care of #6.1 :)

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thank you

  • catch committed 6cbd981 on 8.1.x
    Issue #2659144 by tim.plunkett: CurrentRouteMatch::getRouteMatch() needs...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.1.x, thanks!

Status: Fixed » Closed (fixed)

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