Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: "Invalid draft ID" exception when editing entries in slideouts, if the slideout entry does not exist in the currently requested site #15798

Closed
mmikkel opened this issue Sep 26, 2024 · 2 comments
Labels

Comments

@mmikkel
Copy link
Contributor

mmikkel commented Sep 26, 2024

What happened?

Description

Certain actions in entry slideouts will fail with a BadRequestHttpException "Invalid draft ID", if the entry being edited in the slideout does not exist for the currently requested site. Stack trace here: https://pastebin.com/6jndVcMx

For one, attempting to discard unsaved changes from the slideout will fail w/ the above error. I suspect this might be because there is no site ID passed to the delete-draft action; likely making Craft fall back to the currently requested site ('norwegian', in this case), in which the slideout entry doesn't exist?

CleanShot 2024-09-26 at 16 31 25@2x

Similarly, attempting to add a nested entry in a CK Editor field on the slideout entry will also fail with the same exception, causing a blank slideout for the attempted new nested entry. Again, the request (this time to elements/edit) is missing a site ID param:

CleanShot 2024-09-26 at 16 29 28@2x

CleanShot.2024-09-26.at.17.08.11.mp4

^ Attempting to add a nested entry in a CK Editor field for an entry that doesn't exist in the currently requested site

Saving changes in the slideout does work (both in terms of auto-saving the provisional draft and actually clicking "Save" in the slideout); presumably because these requests include the slideout entry's site ID as a param:

CleanShot 2024-09-26 at 16 31 55@2x

Steps to reproduce

  1. Create two sites, "Site A" and "Site B"
  2. Create two sections, "Section A" and "Section B". Make sure that "Section B" is only enabled for "Site B".
  3. Create an entry in Section B (Site B).
  4. Create an Entries field, and select "Section B" as the only source. Enable the "Show the site menu" setting.
  5. Add the Entries field to Section A.
  6. Create an entry in Section A, Site A. Add the entry from Section B (Site B) to the field.
  7. Double-click the selected Site B entry in the entries field to have it open in a slideout. Make some changes. After the auto-draft completes saving, click the "Discard changes" button in the slideout.

Expected behavior

Editing entries in relational fields' slideouts should work, even if the entry doesn't exist for the currently requested site.

Actual behavior

Saving content changes via slideouts for entries that doesn't exist in the currently requested site works, but other actions such as adding nested entries or discarding changes doesn't.

Craft CMS version

5.4.5.1 (Solo)

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

  • None, although I tested editing nested entries using CK Editor
@brandonkelly
Copy link
Member

Thanks for reporting that! The “Discard changes” bug is fixed now in Craft 4.12.5 and 5.4.6. We’ll look into the CKEditor bug separately.

@brandonkelly
Copy link
Member

CKEditor 4.3.0 is out now with the other fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants