Unverified Commit 74bdbe01 authored by catch's avatar catch Committed by Alex Pott
Browse files

fix: #3557333 Deprecations in...

fix: #3557333 Deprecations in \Drupal\Core\Entity\EntityStorageBase::mapFromStorageRecords() on PHP 8.5

By: @alexpott
By: @andypost
(cherry picked from commit 946903d0)
parent eb870efd
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -451,7 +451,11 @@ protected function mapFromStorageRecords(array $records) {
      $entity_class = $this->getEntityClass();
      /** @var \Drupal\Core\Entity\EntityInterface $entity */
      $entity = new $entity_class($record, $this->entityTypeId);
      $entities[$entity->id()] = $entity;
      $entity_id = $entity->id();
      if ($entity_id === NULL) {
        throw new EntityMalformedException('The entity does not have an ID.');
      }
      $entities[$entity_id] = $entity;
    }
    return $entities;
  }
+13 −0
Original line number Diff line number Diff line
@@ -128,6 +128,19 @@ public function doLoadMultiple(?array $ids = NULL) {
    return $this->mapFromStorageRecords($entities);
  }

  /**
   * {@inheritdoc}
   */
  protected function mapFromStorageRecords(array $records) {
    $entities = [];
    foreach ($records as $record) {
      /** @var \Drupal\Core\Entity\EntityInterface $entity */
      $entity = $this->doCreate($record);
      $entities[$entity->id()] = $entity;
    }
    return $entities;
  }

  /**
   * {@inheritdoc}
   */
+7 −0
Original line number Diff line number Diff line
@@ -165,6 +165,13 @@ public function testCRUD(): void {
      // Verify that originalID points to new ID directly after renaming.
      $this->assertSame($new_id, $entity_test->id());
    }

    // Test loading multiple entities. There should be an entity keyed by the ID
    // we just created.
    $entities = $storage->loadMultiple();
    $this->assertCount(3, $entities);
    $this->assertArrayHasKey($entity_test->id(), $entities);
    $this->assertSame($entity_test->uuid(), $entities[$entity_test->id()]->uuid());
  }

  /**