Skip to content

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

@mmikkel

Description

@mmikkel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions