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?
Issue fork display_builder-3576464
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
Comment #2
pdureau commentedstarted
Comment #4
pdureau commentedHi 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?
Comment #6
mogtofu33 commentedMinor 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.