- @grimreaper opened merge request.
- π«π·France Grimreaper France π«π·
I pushed a new solution.
In fact I found 2 problems.
The max_recursion_depth setting not taken into account.
But even with that problem fixed, having no recursion limit should not provoke infinite loop.
This was also due to the fact that the mechanism put in place to prevent infinite loop relayed on the following lines in ImportService::importEntityListData():
$processed_entity = $this->getProcessedEntity($entity_data); $imported_entity_ids[$processed_entity->uuid()] = $processed_entity->id(); // Prevent infinite loop. // Check if we try to import an already imported entity translation. // We can't check this in the STAGE_IS_ENTITY_IMPORTABLE stage because we // need to obtain the entity ID to return it for entity reference fields. $processed_entity_langcode = $processed_entity->language()->getId(); $processed_entity_uuid = $processed_entity->uuid(); if ($this->runtimeImportContext->isEntityTranslationImported($processed_entity_langcode, $processed_entity_uuid)) { continue; } else { // Store data to prevent the entity of being re-imported. $this->runtimeImportContext->addImportedEntity($processed_entity_langcode, $processed_entity_uuid); }
Which happens after the prepare_importable_entity_data stage, which is the stage where the link field, embedded entity and block field importer plugins act. While the standard entity reference importer plugin acts in the process_entity stage, which happens right after the check to prevent infinite loop.
So I have added a new property to the RuntimeImportContext object to store the entities that are going to be imported. The existing $importedEntities could not be used otherwise this would prevent entities to be imported.
I currently do not handle entity language because currently in the JSON data the importer plugins have access, this data is not present so it would require to add more data injected by the JSON:API Extras field enhancer.
This would mean that if regarding the "reference" during the same import, an entity should be imported in multiple languages, this would prevent that.
As currently channels are still for one language, I don't think this is currently problematic.
Enhanced version may become later.
Still needs to write tests.
-
Grimreaper β
committed 3dc8fdac on 8.x-3.x
Issue #3265613 by dgroene, Grimreaper: Infinite loop in link field,...
-
Grimreaper β
committed 3dc8fdac on 8.x-3.x
- Issue was unassigned.
- Status changed to Fixed
about 2 years ago 5:28pm 24 February 2023 - π«π·France Grimreaper France π«π·
Tests ok.
I have not written tests for block field, because it would have required to prepare a block content type that contains a block field.
Not impossible to do, but I have only a short time available.