default-content-deploy:export-with-references not working

Created on 27 May 2022, about 2 years ago
Updated 14 May 2024, about 2 months ago

Problem/Motivation

Not working command drush default-content-deploy:export-with-references node

Steps to reproduce

1. Create >2 node entities
2. Run command drush default-content-deploy:export-with-references node
Your get error

AssertionError: Cannot load the "node" entity with NULL ID. in /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php on line 295 #0 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(295): assert(false, 'Cannot load the...')
#1 /app/web/modules/contrib/default_content_deploy/src/Exporter.php(540): Drupal\Core\Entity\EntityStorageBase->load(NULL)
#2 /app/web/modules/contrib/default_content_deploy/src/Exporter.php(355): Drupal\default_content_deploy\Exporter->editEntityData()

Proposed resolution

Need update method \Drupal\default_content_deploy\Exporter::getSerializedContentWithReferences
to

  private function getSerializedContentWithReferences(ContentEntityInterface $entity) {
    $indexed_dependencies = [$entity->uuid() => $entity];
    $entities = $this->getEntityReferencesRecursive($entity, 0, $indexed_dependencies);
    $serialized_entities = [];

    // Serialize all entities and key them by entity TYPE and uuid.
    foreach ($entities as $referenced_entity) {
      $serialize = $this->serializer->serialize($referenced_entity, 'hal_json', [
        'json_encode_options' => JSON_PRETTY_PRINT,
      ]);

      $serialized_entities[$referenced_entity->getEntityTypeId()][$referenced_entity->uuid()] = $this->getSerializedContent($referenced_entity);
    }

    return $serialized_entities;
  }
πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡·πŸ‡ΊRussia batkor Irkutsk

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡΄Norway eiriksm Norway

    Hello! Thanks for fiding and fixing the issue!

    Just to note. This is not yet in a stable release, and thus people will probably still experience the issue. Like in πŸ› AssertionError when trying to export content of entity type with with reference Active for example.

    I added a MR there with a test, when I realized this was actually fixed in -dev :)

    I would be happy to update this issue with the same MR, but feels more relevant to have a test MR in that issue.

    And again. Great if we could get a new stable release with this issue fixed ✌️

  • πŸ‡³πŸ‡΄Norway eiriksm Norway

    Just a friendly nudge that there is still no stable release with this rather critical issue fixed :)

    Since I am now nudging, just also pointing out that the issue adding a test for this issue is still in "needs review" as well

  • πŸ‡³πŸ‡΄Norway eiriksm Norway

    Coming back to this issue once again, after adding default_content_deploy on a project. This issue is marked critical and fixed, after which there has not been a new release. I promise I will stop with these nudges if we can get a new release out? :p

    nudge nudge nudgy nudge :D

Production build 0.69.0 2024