Verified Commit 557022fc authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3414398 by catch, Berdir: AssetResolver::getJsAssets() and...

Issue #3414398 by catch, Berdir: AssetResolver::getJsAssets() and AssetResolver::getCssAssets()  can repeatedly try to calculate the same set of assets

(cherry picked from commit e2840d72)
parent 895a6a91
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -122,6 +122,9 @@ protected function getLibrariesToLoad(AttachedAssetsInterface $assets) {
   * {@inheritdoc}
   */
  public function getCssAssets(AttachedAssetsInterface $assets, $optimize, LanguageInterface $language = NULL) {
    if (!$assets->getLibraries()) {
      return [];
    }
    if (!isset($language)) {
      $language = $this->languageManager->getCurrentLanguage();
    }
@@ -214,6 +217,9 @@ protected function getJsSettingsAssets(AttachedAssetsInterface $assets) {
   * {@inheritdoc}
   */
  public function getJsAssets(AttachedAssetsInterface $assets, $optimize, LanguageInterface $language = NULL) {
    if (!$assets->getLibraries() && !$assets->getSettings()) {
      return [[], []];
    }
    if (!isset($language)) {
      $language = $this->languageManager->getCurrentLanguage();
    }
+2 −2
Original line number Diff line number Diff line
@@ -50,11 +50,11 @@ public function testFrontPageAuthenticatedWarmCache(): void {
    $recorded_queries = $performance_data->getQueries();
    $this->assertSame($expected_queries, $recorded_queries);
    $this->assertSame(4, $performance_data->getQueryCount());
    $this->assertSame(48, $performance_data->getCacheGetCount());
    $this->assertSame(43, $performance_data->getCacheGetCount());
    $this->assertSame(0, $performance_data->getCacheSetCount());
    $this->assertSame(0, $performance_data->getCacheDeleteCount());
    $this->assertSame(0, $performance_data->getCacheTagChecksumCount());
    $this->assertSame(16, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(11, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
  }

+4 −4
Original line number Diff line number Diff line
@@ -221,11 +221,11 @@ public function testLogin(): void {
    $recorded_queries = $performance_data->getQueries();
    $this->assertSame($expected_queries, $recorded_queries);
    $this->assertSame(15, $performance_data->getQueryCount());
    $this->assertSame(67, $performance_data->getCacheGetCount());
    $this->assertSame(60, $performance_data->getCacheGetCount());
    $this->assertSame(1, $performance_data->getCacheSetCount());
    $this->assertSame(1, $performance_data->getCacheDeleteCount());
    $this->assertSame(1, $performance_data->getCacheTagChecksumCount());
    $this->assertSame(30, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(23, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
  }

@@ -275,11 +275,11 @@ public function testLoginBlock(): void {
    $recorded_queries = $performance_data->getQueries();
    $this->assertSame($expected_queries, $recorded_queries);
    $this->assertSame(17, $performance_data->getQueryCount());
    $this->assertSame(110, $performance_data->getCacheGetCount());
    $this->assertSame(107, $performance_data->getCacheGetCount());
    $this->assertSame(1, $performance_data->getCacheSetCount());
    $this->assertSame(1, $performance_data->getCacheDeleteCount());
    $this->assertSame(1, $performance_data->getCacheTagChecksumCount());
    $this->assertSame(46, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(43, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
  }