Skip to content

Bugfix/16778 provisional draft already exists#16911

Merged
brandonkelly merged 9 commits into5.xfrom
bugfix/16778-provisional-draft-already-exists
Mar 18, 2025
Merged

Bugfix/16778 provisional draft already exists#16911
brandonkelly merged 9 commits into5.xfrom
bugfix/16778-provisional-draft-already-exists

Conversation

@i-just
Copy link
Copy Markdown
Contributor

@i-just i-just commented Mar 18, 2025

Description

Steps to reproduce:

  1. clean 5.6.11 install
  2. create a matrix Matrix field with an entry type (matrixEt) - it doesn’t have to have any fields in it, just the native title
  3. create a blog section with an article entry type containing the matrix field
  4. create an entry in the blog section (title: “root”), add one entry to the matrix (title: “test 1”) field; fully save each slideout and root entry;
  5. open the edit page for entry from step 4;
  6. change the title to “root 2”
  7. edit “test 1” (dbl-click)
  8. change the title to “test 1 edit”
  9. close the “test 1” slideout without saving
  10. reload the “root 2” page
  11. edit “test 1” (dbl-click)
  12. change the title again and notice that the autosave returns an error about the existing provisional draft.

Issue:
In step 8, the newly created provisional draft has its owner set to the canonical version of the root entry, not the provisional draft.

After ensuring that the nested element draft is owned by the owner provisional draft, the NestedElementManager->deleteNestedElements() needs to account for when we’re deleting an owner that’s a provisional draft. In that case, the nested elements that are also provisional drafts and only belong to the owner provisional draft also have to be deleted.

Huge thanks to @tommysvr for providing a video that made compiling the above steps so much easier.

Related issues

#16778

@i-just i-just requested a review from brandonkelly March 18, 2025 15:07
@brandonkelly brandonkelly force-pushed the bugfix/16778-provisional-draft-already-exists branch from a35b841 to f15e77c Compare March 18, 2025 23:01
@brandonkelly
Copy link
Copy Markdown
Member

There are still a couple lingering bugs we need to work through:

  • The fix didn’t work retroactively for existing nested provisional drafts.
  • If any nested elements were fully saved to duplicates of themselves, they were no longer getting deleted when the owner provisional draft was discarded.

So for now, just fixed this by making elements/save-draft stop throwing an exception if there’s an existing provisional draft. Instead it will log a warning and delete the previous provisional draft.

@brandonkelly brandonkelly merged commit 677ac26 into 5.x Mar 18, 2025
@brandonkelly brandonkelly deleted the bugfix/16778-provisional-draft-already-exists branch March 18, 2025 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants