Overview

Content entity
  1. Create a page
  2. Make some changes to the page
  3. Delete that page
  4. Try to publish
  5. Receive a 500 error
Config entity
See #6

Proposed resolution

Clean up autosave entries when an entity is updated/saved or deleted.

User interface changes

The status badge now always works correctly (#3505118: The status badge should indicate if there are changes to the page), plus the Add to components button (#3500071: Adding code components to components) now always appears when appropriate.

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

larowlan created an issue. See original summary.

wim leers’s picture

Title: Deleting a content entity should clear its values from the auto-save store » Deleting or updating a content entity should clear its values from the auto-save store
StatusFileSize
new2.79 KB

This implements the "update" part — just needs one added hook to implement this part.

lauriii’s picture

I'm not sure we should be just deleting the autosave entry when an entity is updated. I realize this is an edge case but this could still result in loss of data for the user. I think in this situation it might make sense to provide the user an option to choose if they want to continue from the autosave state of the latest revision.

wim leers’s picture

Assigned: Unassigned » wim leers
Issue tags: +sprint, +Needs tests

@balintbrews and @hooroomoo reported the following bug:

  1. Add a new code component and name it “Test”
  2. Add some JS code so it gets autosaved  e.g.
    export default function MyComponent() {
      return <h1>HELLO WORLD</h1>
    }
    
  3. Use the new “Add to components” button to make the code component external.
  4. Visit /xb/xb_page/1/code-editor/code/[machineName] to edit the component again (workaround to see the issue), update something to trigger an autosave.
    Check /xb/api/config/auto-save/js_component/test and it says status: FALSE

That's another symptom of the same root cause. Confirmed through manual testing.

wim leers’s picture

Issue summary: View changes
Status: Active » Needs review
Issue tags: -Needs tests
Related issues: +#3500071: Adding code components to components
wim leers’s picture

Assigned: wim leers » larowlan

Given how many issues we've recently been working on in the auto-save realm, including this one and the critical #3502902: Only auto-save content entities/PageRegion config entities when there are actual changes: simply previewing incorrectly causes them to appear in "Review x changes", I think it's time to carve out an explicit issue queue component for it. #3489743: Create AutoSave service and HTTP API to retrieve all entities with pending changes introduced it, and was led by @tedbow and @larowlan, so assigning to @larowlan for review.

balintbrews’s picture

Title: Deleting or updating a content entity should clear its values from the auto-save store » Deleting or updating a content or config entity should clear its values from the auto-save store
wim leers’s picture

Nice catch on the title! 😄

wim leers’s picture

Component: Internal HTTP API » Auto-save
wim leers’s picture

Title: Deleting or updating a content or config entity should clear its values from the auto-save store » Deleting/updating a config entity and deleting a content entity should clear its values from the auto-save store
Assigned: larowlan » Unassigned
Status: Needs review » Reviewed & tested by the community

I'm very glad_ I asked you to review this! 😄 You managed to avoid the content entity data loss @lauriii was worried about in #3 in an elegant way while still allowing the main issue to be fixed.

larowlan’s picture

I think is ready to go now, will merge on green.
Get some rest 🛌
Updating issue credits.

  • larowlan committed 1f31bc7e on 0.x authored by wim leers
    Issue #3507334 by wim leers, larowlan, balintbrews, lauriii, hooroomoo:...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks all

nagwani’s picture

Issue tags: -sprint

Status: Fixed » Closed (fixed)

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