Unverified Commit af665970 authored by Alex Pott's avatar Alex Pott
Browse files

perf: #3564973 Optimize field views data building

By: catch
(cherry picked from commit de026a46)
parent d98c9056
Loading
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\Render\Markup;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\FieldStorageConfigInterface;

/**
@@ -110,16 +109,9 @@ public function defaultFieldImplementation(FieldStorageConfigInterface $field_st
    $untranslatable_config_bundles = [];

    foreach ($bundles_names as $bundle) {
      $fields[$bundle] = FieldConfig::loadByName($entity_type->id(), $bundle, $field_name);
    }
    foreach ($fields as $bundle => $config_entity) {
      if (!empty($config_entity)) {
        if ($config_entity->isTranslatable()) {
          $translatable_configs[$bundle] = $config_entity;
        }
        else {
          $untranslatable_configs[$bundle] = $config_entity;
        }
      $bundle_fields = $this->entityFieldManager->getFieldDefinitions($entity_type->id(), $bundle);
      if (isset($bundle_fields[$field_name])) {
        $fields[$bundle] = $bundle_fields[$field_name];
      }
      else {
        // https://www.drupal.org/node/2451657#comment-11462881
@@ -133,6 +125,14 @@ public function defaultFieldImplementation(FieldStorageConfigInterface $field_st
        );
      }
    }
    foreach ($fields as $bundle => $config_entity) {
      if ($config_entity->isTranslatable()) {
        $translatable_configs[$bundle] = $config_entity;
      }
      else {
        $untranslatable_configs[$bundle] = $config_entity;
      }
    }

    // If the field is translatable on all the bundles, there will be a join on
    // the langcode.
+4 −4
Original line number Diff line number Diff line
@@ -128,10 +128,10 @@ protected function doTestNodePageAdministrator(): void {
    }, 'administratorNodePage');

    $expected = [
      'QueryCount' => 322,
      'CacheGetCount' => 349,
      'QueryCount' => 320,
      'CacheGetCount' => 347,
      'CacheGetCountByBin' => [
        'config' => 91,
        'config' => 89,
        'bootstrap' => 16,
        'discovery' => 108,
        'data' => 23,
@@ -141,7 +141,7 @@ protected function doTestNodePageAdministrator(): void {
        'render' => 39,
        'menu' => 24,
      ],
      'CacheSetCount' => 341,
      'CacheSetCount' => 339,
      'CacheDeleteCount' => 0,
      'CacheTagInvalidationCount' => 0,
      'CacheTagLookupQueryCount' => 30,
+3 −3
Original line number Diff line number Diff line
@@ -52,9 +52,9 @@ protected function testFrontPageColdCache(): void {
    $this->assertSession()->pageTextContains('Umami');

    $expected = [
      'QueryCount' => 239,
      'CacheGetCount' => 316,
      'CacheSetCount' => 315,
      'QueryCount' => 235,
      'CacheGetCount' => 312,
      'CacheSetCount' => 311,
      'CacheDeleteCount' => 0,
      'CacheTagLookupQueryCount' => 25,
      'CacheTagInvalidationCount' => 0,
+2 −2
Original line number Diff line number Diff line
@@ -55,8 +55,8 @@ protected function testNodePageColdCache(): void {
    $this->assertSession()->pageTextContains('quiche');

    $expected = [
      'QueryCount' => 251,
      'CacheSetCount' => 299,
      'QueryCount' => 249,
      'CacheSetCount' => 297,
      'CacheDeleteCount' => 0,
      'CacheTagLookupQueryCount' => 24,
      'CacheTagInvalidationCount' => 0,