Committer notes: This was worked on by kim.pepper and dashaforbes together so please include him in the commit credits.

Problem/Motivation

As a part of #1744302: [meta] Resolve known performance regressions in Drupal 8 we want to reduce the number of getContainer() calls in LinkGenerator. We can do this by avoiding calling it for external links.

Proposed resolution

Remaining tasks

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Update the issue summary noting if allowed during the beta Instructions
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards Instructions

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kim.pepper’s picture

Assigned: kim.pepper » Unassigned
Issue summary: View changes
Status: Active » Needs review
FileSize
5.92 KB

This injects Renderer and UnroutedUrlAssembler into LinkGenerator to reduce the number of calls to getContainer().

This also adds a new test to ensure the renderer is called when $text is an array.

larowlan’s picture

  1. +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php
    @@ -72,11 +92,11 @@ public function generate($text, Url $url) {
    +    $url->setUnroutedUrlAssembler($this->urlAssembler);
    

    This can be wrapped in a

    if (!$url->isRouted()) {
    }
  2. +++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
    @@ -108,6 +116,8 @@ public function testGenerateHrefs($route_name, array $parameters, $absolute, $ex
    +
    +
    

    not needed

kim.pepper’s picture

Fixes for #2

The last submitted patch, 1: 2421197-link-generator-container-1.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 3: 2421197-link-generator-container-3.patch, failed testing.

dawehner’s picture

  1. +++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
    @@ -299,6 +307,38 @@ public function testGenerateXss() {
    +   *
    +   * @see \Drupal\Core\Utility\LinkGenerator::generate()
    +   */
    +  public function testGenerateTextAsRenderArray() {
    

    What about using @covers?

  2. +++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
    @@ -299,6 +307,38 @@ public function testGenerateXss() {
    +      ->will($this->returnValue(
    +        '/test-route-7'
    +      ));
    ...
    +      ->will($this->returnValue('<em>Test</em>'));
    

    Note: You can do the same with ->willReturn('/test-route-7') and similar.

The last submitted patch, 3: 2421197-link-generator-container-3.patch, failed testing.

kim.pepper’s picture

Status: Needs work » Needs review
FileSize
6.32 KB
2.17 KB

Fixes for #6 as well as a reroll for missing constructor args in FieldPluginBaseTest.

Status: Needs review » Needs work

The last submitted patch, 9: 2421197-link-generator-container-9.patch, failed testing.

YesCT’s picture

Issue summary: View changes
Issue tags: +Needs issue summary update

needs a beta evaluation in the issue summary (especially since this is a normal task).

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.

joelpittet’s picture

Status: Needs work » Needs review
Issue tags: -Needs issue summary update
FileSize
5.5 KB

Re-rolled this, doesn't need beta evaluation anymore.

Status: Needs review » Needs work

The last submitted patch, 14: 2421197-14.patch, failed testing.

joelpittet’s picture

Status: Needs work » Needs review
FileSize
5.15 KB

Added a duplicate renderer property by accident.

Status: Needs review » Needs work

The last submitted patch, 16: 2421197-16.patch, failed testing.

dawehner’s picture

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

I believe this is clearly not a bug, so it just applied to 8.3.x. In that case though there is no BC problem involved.

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

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now 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.

joelpittet’s picture

Status: Needs work » Needs review
FileSize
5.15 KB

Reroll

Status: Needs review » Needs work

The last submitted patch, 20: 2421197-16-reroll.patch, failed testing.

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now 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.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now 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.

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.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.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.

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.

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.

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.

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.