fix: #3586587 Don't restore entity key or revision metadata fields on save

Summary

Fixes the entity storage exception when saving a node through the Drupal Canvas editor while the full content view mode has the Canvas layout field active:

Update existing 'node' entity revision while changing the revision ID is not supported.

Root cause

When Canvas publishes auto-saved changes it reconstructs the entity from its values (firing hook_node_field_values_init) and saves it (firing hook_node_presave). Canvas Override's restore logic in both hooks copied every field except title and field_canvas_layout back from the stored entity — including the entity key fields (nid, vid, uuid, langcode, status, …) and the revision metadata keys. Restoring the revision ID after Canvas had cleared it for the new revision is what triggered the storage exception.

Fix

Exclude the entity key fields and the revision metadata keys from the fields that are restored, in both nodeFieldValuesInit() and nodePresave(). Only the content fields that Canvas Override deliberately leaves out of the editor form are restored now; the revision lifecycle is left to Drupal.

This is the maintainer-reviewed patch from the issue (canvas_override_fix_exception_on_save.patch, by arnalyse), confirmed against drupal/canvas 1.5.0.

Verification

  • Verified the restore hooks no longer touch the revision ID (the entity key and revision metadata keys are now in the preserved set).
  • Confirmed normal node saves still work (no regression).
  • The existing functional acceptance suite and unit tests run in CI on this branch.

AI usage disclosure

Per the Policy on the use of AI when contributing to Drupal: AI-Generated: No. The change is the human-authored patch from the issue; it was applied, verified and tested by the contributor, who takes full responsibility for the submission.

Checkpoints:

  • File an issue
  • Addition/Change/Update/Fix
  • Testing to ensure no regression
  • Automated unit testing coverage
  • Automated functional testing coverage
  • UX/UI designer responsibilities
  • Readability
  • Accessibility
  • Performance
  • Security
  • Documentation
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Release notes snippet
  • Release
Edited by Rajab Natshah

Merge request reports

Loading
Loading