Problem/Motivation
When updating on last dev, error occur:
Error: Call to a member function setNewPresent() on null in Drupa l\display_builder_entity_view\Entity\EntityViewDisplay->postSave() (line 18 2 of /checkout/web/modules/contrib/display_builder/modules/display_builder_entity_view/src/Entity/EntityViewDisplayTrait.php)
Steps to reproduce
Proposed resolution
Here is a patch proposition by @yannickoo
public function postSave(EntityStorageInterface $storage, $update = TRUE): void {
// Reset the state once you import a configuration.
- if ($this->isSyncing()) {
- $instance = $this->getInstance();
+ if ($this->isSyncing() && ($instance = $this->getInstance())) {Remaining tasks
User interface changes
API changes
Data model changes
Issue fork display_builder-3603094
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
mogtofu33 commentedComment #4
pdureau commentedOK for me.
Comment #5
pdureau commentedComment #6
pdureau commentedComment #7
mogtofu33 commentedComment #9
pdureau commentedI see it was not merged yet. Maybe because of fails in phpunit. So back to "Needs work".
This fail was expected, and is related to changes in UI Patterns 2.0.16 released yesterday:
We just need to update the order of properties in the tests.
There are also 4 "Failed asserting that an array is empty." fails, because an empty array inside an empty array is not considered empty by PHP:
Investigating.
Comment #10
mogtofu33 commentedI checked to fix the tests, but so we have now this root array with 'node_id' but source_id = NULL.
Comment #11
pdureau commented3 commits pushed on the MR, I guess this ticket is on your side.
Are you sure those changes in EntityViewDisplayTrait, API controllers, Instance entity and SourceTree are needed just because we have updated UI Patterns from 2.0.15 to 2.0.16?
Comment #12
mogtofu33 commentedEntityViewDisplayTrait is the original bug fix.
There is some inconsistency changes unrelated, like save() usage. But mostly it's tests fix and workaround this source_id => NULL from ui_patterns.
But would be great to know if it's a problem from ui_patterns.
Seems like ui_patterns SourceValueItem inherit FieldItemBase inherit Map for function isEmpty() wich check null when we are empty array. Then FieldItemList::filterEmptyItems() could remove the phantom stuff as currently it didn't.
Comment #13
mogtofu33 commentedI removed the workaround and created an issue on ui_patterns https://www.drupal.org/project/ui_patterns/issues/3604317
Comment #14
pdureau commentedI was investigating that this afternoon.
Argument #1 ($source_id) must be of type string, null given, called in SourceTree.phpis caused by this (relevant) change in UI Patterns:Because we are losing the (maybe too) generous
MapItem::isEmpty()and relying on the more strict and convoluted
Map::isEmpty().So, with those 3 additional lines in UI Patterns + reordering the properties in
InstancePublishingTest::testRestore()(2 lines) must be enough to fix, without the risk of changing our tests, the delicate SourceTree or the publishing logic.I take the ticket back to finish the investigation and maybe to propose another MR (or two 😉).
Comment #15
pdureau commentedI don't understand when I am supposed to work on this ticket or not 😕 it is the second time today commits are pushed while the ticket is assigned to me.
Comment #17
pdureau commentedHere is my proposal: https://git.drupalcode.org/project/display_builder/-/merge_requests/296/...
UI Patterns 2.0.16 compatibility OK with only 2 lines changed in
InstancePublishingTest::testRestore()& 3 lines added in #3604317: SourceValueItem missing isEmpty() causes phantom null items to survive filterEmptyItems() [AI assisted] (see my comment).Without the risk of doing changes in the tests, the SourceTree, the controllers... parts of the codebase which are delicate and tricky.
What do you think?
Edit: I forgot to update composer.json
Comment #18
pdureau commentedI will add the composer.json and also
DisplayBuilderKernelTestBase::testGetParentId()from your MR because it add coverage without expecting a change of the existing logic 😉Comment #19
pdureau commentedDone.