craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.27k stars 635 forks source link

Saving an entry after searching/filtering assets causes "Entry not found" error #5254

Closed jordanmoore closed 4 years ago

jordanmoore commented 4 years ago

Description

This is happening in production and locally on the latest Craft install. Any time I want to create an entry or update an existing entry after searching for assets via the asset modal window, the entry fails to save.

Demo video

It may be worth mentioning that our assets are in Object Storage via Fortrabbit. Not sure if that's relevant to the issue. Also worth mentioning that it works fine when you don't search in the assets modal.

Steps to reproduce

  1. Click New Entry
  2. Search for an asset
  3. Click Save Entry

Additional info

brandonkelly commented 4 years ago

I’m not able to reproduce this locally. Do me a favor…

  1. Create a new entry and select an asset without searching.
  2. In your JS console, run this:
    Craft.cp.$primaryForm.serialize().replace(/&/g, "\n")
  3. Copy the output to a text file
  4. Submit the form; verify that it saves successfully.
  5. Create a new entry and select the same asset after searching for it.
  6. In your JS console, run that same command again.
  7. Copy the output into a new text file.
  8. Email both text files to support@craftcms.com, indicating which is which and referencing this GitHub issue URL.
jordanmoore commented 4 years ago

Cheers Brandon. Email sent!

LouisCuvelier commented 4 years ago

@brandonkelly I'm facing the same issue. But, to add a bit more context and maybe a clue to debug this, I identified something.

When I click "New entry", Craft add params to the URL, like this : /<id>/?draftId=<id>&fresh=<id>. But, when I search an entry on an asset field or entry field, from the first character I type in the search bar, Craft removes the parameters from the URL, to only this /<id>/.

So without the params, when I save, It says "Entry not found".

brandonkelly commented 4 years ago

@LouisCuvelier Thanks, I just fixed that behavior (ff1186c974652e47be5bad88b68168b99da73f1f). Not exactly sure how it would result in the Entry Not Found error, but can you please test to see if it resolves it?

To test, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop#ff1186c974652e47be5bad88b68168b99da73f1f as 3.3.17",
  "...": "..."
}

Then run composer update.

LouisCuvelier commented 4 years ago

It's working like a charm. Problem solved. Thanks @brandonkelly !

jordanmoore commented 4 years ago

Good catch @LouisCuvelier and thank you @brandonkelly, I can confirm the fix works for me also!

brandonkelly commented 4 years ago

Great, thanks for checking @LouisCuvelier and @jordanmoore!