payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
27.66k stars 1.72k forks source link

fix: unable to load documents with non-standard ids #9407

Closed JarrodMFlesch closed 18 hours ago

JarrodMFlesch commented 18 hours ago

What?

Non-standard ids caused an issue when finding the document on the server.

This is an odd regression, in 2.0 we were fetching the document on the client so the request would handle decoding the url. Now we are fetching the document on the server and need to do this manually when reading id from route params.

Why?

The slug pulled out of the url for an id of id 1 would equate to id%201 which would fail in the payload.find call since there is not an id stored as id%201 but instead id 1.

How?

Wherever we are calling payload.find in the views and querying by id it gets ran through a helper function that decodes it properly.

Fixes #9373