Error with export (with references) from xpath selector with certain content

Created on 5 September 2024, 11 months ago
Updated 20 September 2024, 11 months ago

Problem/Motivation

I ran a batch export (with references) using the initial 2k nodes used during development and it works great! Now I am trying a full export of all 16,260 migrated nodes, with references, and I'm running into an error:

ResponseText: The website encountered an unexpected error. Try again later.Drupal\Component\Plugin\Exception\PluginNotFoundException: The "individual" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 142 of core/lib/Drupal/Core/Entity/EntityTypeManager.php). Drupal\Core\Entity\EntityTypeManager->getHandler('individual', 'storage') (Line: 195)
Drupal\Core\Entity\EntityTypeManager->getStorage('individual') (Line: 1101)
Drupal\default_content_deploy\Exporter->getEntityProcessedTextDependencies(Object) (Line: 1151)
Drupal\default_content_deploy\Exporter->getEntityReferencesRecursive(Object, Array, 2, Array) (Line: 1179)
Drupal\default_content_deploy\Exporter->getEntityReferencesRecursive(Object, Array, 1, Array) (Line: 1179)
Drupal\default_content_deploy\Exporter->getEntityReferencesRecursive(Object, Array, 0, Array) (Line: 694)
Drupal\default_content_deploy\Exporter->exportBatchWithReferences('node', '33551', 13692, 16258, Array) (Line: 578)
Drupal\default_content_deploy\Exporter::exportFile('exportBatchWithReferences', 'node', '33551', 13692, 16258, Array) (Line: 296)

The issue is two of these nodes actually use the data-entity-type attribute on form elements within the body of the node. Therefore the xpath selector in getEntityProcessedTextDependencies() is selecting these items, and the value of this attribute does not align with an entity type in Drupal. To fix this, we should ensure any element selected by this xpath also have the data-entity-uuid attribute, to ensure it's actually an entity reference.

Here is an excerpt from the offending node body:

<input type="radio" name="maritalStatus" id="marital-single" value="single" data-marital-option="1" data-entity-type="individual" data-entity-prep="an" data-separate-status="single" data-has-partner="false" data-rule-required="true">

Steps to reproduce

Add the above code to a node body, run an export of that node with processed text references, see batch error.

Proposed resolution

Add to the existing xpath selector to ensure element also has a data-entity-uuid attribute.

🐛 Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

🇨🇦Canada smulvih2 Canada 🍁

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

Comments & Activities

Production build 0.71.5 2024