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:

  1. Make a content type (node bundle) display overridable with Display Builder
  2. Override the by doing some changes here: /node/1/display/default
  3. Check the changes: /node/1
  4. 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.

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.

grimreaper’s picture

Assigned: Unassigned » grimreaper
pdureau’s picture

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Active » Needs review
Issue tags: -display_builder-1.0.0-beta2 +display_builder-1.0.0-beta
StatusFileSize
new29.35 KB

grimreaper’s picture

pdureau’s picture

Assigned: Unassigned » pdureau
Issue tags: -display_builder-1.0.0-beta2 +display_builder-1.0.0-beta1

If OK today, let's move this to beta1. If not, let's put it back to beta2.

grimreaper’s picture

For 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

pdureau’s picture

Assigned: pdureau » mogtofu33
Status: Needs review » Reviewed & tested by the community

works good for me

grimreaper’s picture

I 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.

grimreaper’s picture

Assigned: mogtofu33 » grimreaper
Status: Reviewed & tested by the community » Needs work

Doing some test with CI.

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs work » Reviewed & tested by the community

CI updated.

Still a problem with a phpmd file path.

pdureau’s picture

Assigned: Unassigned » mogtofu33

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

  • mogtofu33 committed 9e03e831 on 1.0.x authored by grimreaper
    fix: #3555475 Create new revision when a view override is published
    
    By...
mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Reviewed & tested by the community » Fixed

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.

Status: Fixed » Closed (fixed)

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