Infinite loop with Layout Builder

Created on 3 July 2024, 2 months ago
Updated 18 July 2024, about 2 months ago

Describe your bug or feature request.

On a Drupal project with Commerce and Layout Builder activated, after having created around thirty Product Types (and associated Product Variation Type). When I install this project on a new environment from existing setup, I get the following error:

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /app/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php on line 121

On a larger project (with several taxonomies linked to the Product Type), I also got this error when going to on the Taxonomy and Content Type page.

Steps to reproduce it from a clean install.

Steps to reproduce

  • Install a standard project
  • Install Drush
  • Enable Layout builder
  • Install and activate all Commerce plugins
  • Create a store
  • Add fields to Product Type "default"
  • Create 34 product types by duplicating "default" Product Type (with associated Product Variation Type)
  • Export configuration
  • In core.extension.yml set the profile to minimal (otherwise it is not possible to install the project from the configuration with drush)
  • Completely empty the database of all tables
  • Install the project from an existing project with Drush (command: drush si --existing-config)
  • log in to account

What is expected

We are logged into the account and redirected to the user's page.

What is obtained

Runtime error, but if we return to the site we can see that we are connected.
I noticed the creation of a folder "web/sites/default/files/YYYY-MM" (replace "YYYY-MM" by the current year and month) which contains more than 2000 txt files with "lorem ipsum" inside. (Also referenced in the database).
If I log out and try to reconnect the problem persists and the number of txt files increases.

If I disable Layout Builder, no problem to log in.

Debug

With breaking points I was able to determine the following steps :

Drupal\commerce_product\ContextProvider\ProductVariationContext::getRuntimeContexts
-> line 147 - $this->sampleEntityGenerator == LayoutBuilderSampleEntityGenerator

Drupal\layout_builder\Entity\LayoutBuilderSampleEntityGenerator::get
-> line 55 - $entity_storage->createWithSampleValues($bundle_id)
-> entity_storage == Drupal\commerce_product\ProductVariationStorage

Drupal\Core\Entity\ContentEntityStorageBase::createWithSampleValues
-> line 245 - $entity->get($field_name)->generateSampleItems();

if I comment out this last line, refresh the page, the problem disappears, even if I uncomment this line again.
For the bug to reappear, simply delete the contents of the database and redo an installation from the config.

Solution

Unfortunately, I have no solution to offer. I didn't understand why this problem exists. The problem lies too deep in the Commerce module...

This is very problematic because the problem sometimes reappears when you import a new configuration. (For example when pushing to the test environment).

🐛 Bug report
Status

Fixed

Version

2.0

Component

Product

Created by

🇫🇷France VieilOurs

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

Comments & Activities

Production build 0.71.5 2024