Describe the Bug
For an upload enabled collection with drafts enabled, replacing a published file and saving as a draft incorrectly overwrites the main collection document, flipping its _status from "published" to "draft". The document then appears unpublished in the admin UI and to any API query.
Note: This only happens when the file itself is reuploaded.
Expected behaviour: "Save draft" should never mutate the main collection document. The main document should remain _status: "published" and continue to reference the previously published file.
Link to the code that reproduces this issue
https://github.com/LimChorngUan/payload/blob/media-reupload-bug/test/_community/collections/Media/index.ts
Reproduction Steps
Prerequisites:
- Enabled drafts (
versions: { drafts: true }) on media collection
- Enabled s3storage plugin
- On media collection, create a new media document, upload an image, and click Publish. => The main media document has _status: "published".
- On that same document, remove the existing image, upload a different image, and click Save draft (do not publish).
=> Observe the main media collection document directly in the database or API tab, that the _status has changed to "draft" => acts like unpublish.
Which area(s) are affected?
area: core
Environment Info
Describe the Bug
For an upload enabled collection with drafts enabled, replacing a published file and saving as a draft incorrectly overwrites the main collection document, flipping its _status from "published" to "draft". The document then appears unpublished in the admin UI and to any API query.
Note: This only happens when the file itself is reuploaded.
Expected behaviour: "Save draft" should never mutate the main collection document. The main document should remain _status: "published" and continue to reference the previously published file.
Link to the code that reproduces this issue
https://github.com/LimChorngUan/payload/blob/media-reupload-bug/test/_community/collections/Media/index.ts
Reproduction Steps
Prerequisites:
versions: { drafts: true }) on media collection=> Observe the main media collection document directly in the database or API tab, that the _status has changed to "draft" => acts like unpublish.
Which area(s) are affected?
area: core
Environment Info