Use subrequests when getting component list in getAllComponentsKeyedBySource

Created on 8 September 2025, 7 days ago

Overview

XbAiPageBuilderHelper::getAllComponentsKeyedBySource calls ApiConfigControllers::list multiple times and is expensive, calls controller directly. Performing a subrequest would probably improve speed by hitting dynamic page cache.

Subrequest for caching component list to improve performance. Brought getComponentContextForAi down to 62ms for 2 calls.

Proposed resolution

   // Create a subrequest to the internal API route.
    $mainRequest = $this->requestStack->getCurrentRequest();
    $subRequest = Request::create(
      Url::fromRoute('experience_builder.api.config.list', ['xb_config_entity_type_id' => Component::ENTITY_TYPE_ID])->toString(),
      'GET',
      [],
      $mainRequest?->cookies->all() ?? [],
      [],
      $mainRequest?->server->all() ?? []
    );
    $subRequest->attributes->set('_format', 'json');

    $available_components_response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);

User interface changes

Feature request
Status

Active

Version

1.0

Component

AI

Created by

🇺🇸United States mglaman WI, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024