Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The method generateSampleValue() loads all existing referenceable entities, just to check if there are any.
On a large site with many entities, the process will time out or crash the server.
The check is pointless, and should be removed, since the existing entities are not needed at all.
Comment | File | Size | Author |
---|---|---|---|
#4 | 3084661-generatesamplevalue-loads-all-exiting-entities-1.patch | 958 bytes | anita_novicell |
Comments
Comment #2
super_romeo CreditAttribution: super_romeo as a volunteer commentedComment #3
anita_novicell CreditAttribution: anita_novicell commentedI have run in to the same problem.
In my case, I am using layout builder. I go to my content display mode and choose "manage layout". The layout builder will populate the template with sample values. If my content type has a field of the type entity reference revisions, the generateSampleValues() method will be used to do this.
The generateSampleValues() method invokes the getReferenceableEntities() method in Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection to check if there are any referenceable entities in the database. However, it is invoked without a limit parameter, so it will attempt to load ALL referenceable entities in the database. If you have a large site with thousands of entities, the process will time out.
The patch provided in comment #2 adds a limit to the method, in order to only load 50 entities. However, the generateSampleValues() method doesn't use existing entities but creates its own dummy entity, so there is actually no need at all for this check nor for loading any existing entities. It should be removed completely, unless the method is changed to actually use existing entities for sample values.
This patch will do that: https://www.drupal.org/files/issues/2019-08-18/2568187-errgen-29.patch
I found it in this issue: https://www.drupal.org/project/entity_reference_revisions/issues/2568187
The foreach is not unlimited, just very large, and it will happen with all entity types, not just paragraphs, so the issue title is misleading and the issue has no description. It took me a long time to even find this issue, and I was just about to create a duplicate.
Comment #4
anita_novicell CreditAttribution: anita_novicell commentedI have updated the title and description of the issue
Comment #5
azinck CreditAttribution: azinck commentedCan confirm this is a problem, and can confirm #4 fixes it for us. Thanks @anita_novicell!
Comment #6
BerdirThanks, committed.