Follow-up to #2256497: [meta] Menu Links - New Plan for the Homestretch

Problem/Motivation

In the menu link system and other places we may want to associate data with a specific route name AND route parameters e.g. data associated with 'node.view' and node => 1

In Drupal 7, this would be a certain system path, but in Drupal 8, we want to adhere to the priciple that the system path may be altered by altering the route path without changing the relationship to the route name and parameters.

So, the system path is NOT the right answer. Instead one could use the route name and some serialization of the route parameters in a ingle text field.

Proposed resolution

Remaining tasks

User interface changes

API changes

Issue fork drupal-2302139

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

Issue summary: View changes
Status: Active » Postponed
mgifford’s picture

Status: Postponed » Active

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Grimreaper’s picture

Version: 8.6.x-dev » 8.8.x-dev
Status: Active » Needs review
FileSize
3.33 KB

Hello,

Here is a patch that add a static cache on Drupal\Core\Menu\MenuTreeStorage::loadByRoute().

Thanks for the review.

Status: Needs review » Needs work

The last submitted patch, 9: drupal-static_cache_loadByRoute-2302139-9.patch, failed testing. View results

jhedstrom’s picture

It's sort of surprising this wasn't already statically cached. A few nits below:

  1. +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
    @@ -680,27 +680,40 @@ public function loadByProperties(array $properties) {
    +    $cache = &drupal_static(__METHOD__, []);
    

    Rather than use drupal_static (which is in the process of being deprecated and removed), a class variable $this->cache would make more sense here I think.

  2. +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php
    @@ -680,27 +680,40 @@ public function loadByProperties(array $properties) {
    +      // @todo Standardize an efficient way to load by route name and parameters
    +      //   in place of system path. https://www.drupal.org/node/2302139
    

    I'm not certain if a cache is enough to consider this standardized upon, but part of the final patch here needs to remove this todo comment.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

nginex’s picture

Issue tags: +LutskGCW20

Tagging for Drupal Global Contribution Weekend

nickolaj’s picture

Assigned: Unassigned » nickolaj
Status: Needs work » Active
nickolaj’s picture

Reused a cache from the class instead of &drupal_static. Please review.

nickolaj’s picture

Assigned: nickolaj » Unassigned
Status: Active » Needs review
andypost’s picture

Status: Needs review » Needs work

The last submitted patch, 15: drupal-static_cache_loadByRoute-2302139-10.patch, failed testing. View results

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

sanjayk’s picture

Re-roll patch for 9.2 and also fixed failed test case.

abhisekmazumdar’s picture

Status: Needs work » Needs review

Changing the status to Needs review as there is a patch to be reviewed.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Grimreaper’s picture

Rerolling patch from comment 21.

I also created two MR, one against 9.2.x and one against 9.3.x for easier rebase.

I am trying to apply patch on 9.2.4

Status: Needs review » Needs work

The last submitted patch, 26: drupal-route_cache-2302139-24.patch, failed testing. View results

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Rassoni’s picture

Status: Needs work » Needs review
FileSize
4.19 KB
7.74 KB

Rerolling patch from comment 30
Fixed PHPCS and Deperactred code.

Rassoni’s picture

Rassoni’s picture

Forgot to attach interdiff

catch’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Don't think we can use a persistent cache here, or at least not without adding the relevant cache tags to it.

The original approach here was to add a static cache, #3047289: Standardize how we implement in-memory caches has a way to do that without using drupal_static().

Could use an issue summary update. This is also likely cached at a higher level now like the render cache, so we'd want to check if this data is actually requested more than once on the same request (for example after a cache clear).

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.