Problem/Motivation

Since #3575913: Compatibility with JSON API, part 2, past and future steps are "lost" at every instance entity load, only present step is loaded. That's why LogsPanel and HistoryButtons are useless now.

Example:

$instance = $storage->load($instance_id);
$load = $instance->toArray();
$first_load = $load;
// ✅ Load has only present
$builder->setNewPresent([], 'empty everything');
$builder->save();
$load = $builder->toArray();
// ✅ Load has 1 past step
$builder->setNewPresent($first_load['present']->data, 'restore everything');
$builder->save();
$load = $builder->toArray();
// ✅ Load has 2 past step
$instance = $storage->load($instance_id);
$load = $builder->toArray();
// ❌ Load has only present

Proposed resolution

Is it because we do an entity creation in an unexpected place from InstanceStorage?

  protected function doLoadMultiple(?array $ids = NULL): array {
    $entities = [];
    ...
    foreach ($ids as $id) {
      if ($data = $this->state->get(self::STORAGE_PREFIX . $id, NULL)) {
        $entities[$id] = Instance::create($data);
      }
    }

    return $entities;
  }

We may need to do an entity object instantiation instead:

$entities[$id] = new Instance($data, 'display_builder_instance');

It was not detected by tests, do we need to add a new one or extend an existing one?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pdureau created an issue. See original summary.

pdureau’s picture

Status: Active » Needs work

started

pdureau’s picture

Assigned: pdureau » mogtofu33
Status: Needs work » Needs review

Hi Jean,

OK for review.

Apart for JSON:API compatibility, this little mess will be cleaned and will pay off when we will deliver #3562989: Implements RevisionLogInterface for Instance entity & #3555110: Symmetric translation

The problem has not been detected by tests, do we need to add a new one or extend an existing one?

mogtofu33 made their first commit to this issue’s fork.

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs review » Fixed

Minor fix for PHP 8.5 warnings, for tests will see what I can do, strange that it went through, Kernel tests are not entity based so it's normal, but the min playwright should have catch it.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • mogtofu33 committed 3ced4160 on 1.0.x authored by pdureau
    fix: #3576464 Instances are recreated on load
    
    By: pdureau
    By: mogtofu33
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.