Problem/Motivation
When publishing a display update from an entity view override, we are saving the content entity, but not creating a new revision.
Example:
- Make a content type (node bundle) display overridable with Display Builder
- Override the by doing some changes here: /node/1/display/default
- Check the changes: /node/1
- Check if a revision has been added: /node/1/revisions
Proposed resolution
I have tried a simple change like that:
--- a/modules/display_builder_entity_view/src/Field/DisplayBuilderItemList.php
+++ b/modules/display_builder_entity_view/src/Field/DisplayBuilderItemList.php
@@ -173,7 +173,11 @@ final class DisplayBuilderItemList extends MapFieldItemList implements DisplayBu
foreach ($data as $offset => $item) {
$this->list[$offset] = $this->createItem($offset, $item);
}
- $this->getEntity()->save();
+ $entity = $this->getEntity();
+ if ($entity->getEntityType()->isRevisionable()) {
+ $entity->setNewRevision();
+ }
+ $entity->save();
}
But I am not sure it works. Anyway, it must not be more complicated than that. Maybe the problem is the way we are updating the field value.
Comments
Comment #2
grimreaperComment #3
pdureau commentedComment #4
grimreaperComment #6
grimreaperComment #7
pdureau commentedIf OK today, let's move this to beta1. If not, let's put it back to beta2.
Comment #8
grimreaperFor the remaining PHPStan error, I think it is a PHPStan bug, because the interface has the method.
I have asked if it is a PHPStan bug on Slack: https://drupal.slack.com/archives/C033S2JUMLJ/p1763572638687859
Comment #9
pdureau commentedworks good for me
Comment #10
grimreaperI got feedbacks for PHPStan.
The ContentEntityInterface::getBundleEntity had been introduced in Core 11.3, so we need to ensure the code quality tasks are executed on 11.3.
I think instead of a new composer task for 11.3, need to override the default composer one.
Comment #11
grimreaperDoing some test with CI.
Comment #12
grimreaperCI updated.
Still a problem with a phpmd file path.
Comment #13
pdureau commentedComment #16
mogtofu33 commented