FieldEmbedView::getFieldBuild() contains the following code.

      $view = Views::getView($display_field['settings']['embed_view']);
      $view->setDisplay($display_settings['settings']['view_display'] ?? 'default');

      $view->setAjaxEnabled($display_settings['settings']['enable_ajax'] ?? 'default');

      // Set the view URL to the current page for the exposed filter form
      // redirection.
      $view->override_url = Url::fromRoute('<current>');

      // Build the view arguments.
      $args = [];
      if (!empty($display_settings['settings']['arguments'])) {
        $view_object = \Drupal::service('entity_type.manager')->getStorage('view')->load($display_field['settings']['embed_view']);

        // Omissis

      }

The code is loading the same view twice, first via Views::getView() and then via \Drupal::service('entity_type.manager')->getStorage('view')->load() which would return the same value, since Views::getView() contains the following code.

  $view = \Drupal::entityTypeManager()
    ->getStorage('view')
    ->load($id);
  if ($view) {
    return static::executableFactory()
      ->get($view);
  }
  return NULL;
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:

Comments

apaderno created an issue. See original summary.

avpaderno’s picture

Issue summary: View changes

avpaderno’s picture

Status: Active » Needs review
vensires’s picture

Issue tags: +GreeceSpringSprint2024

  • apaderno committed 7cbf781d on 9.1.x
    Issue #3432055: Do not load twice the embedded view
    
avpaderno’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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