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

[4.x] Fix URI validation error when collection route uses entry IDs #9035

Merged

Conversation

duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Nov 20, 2023

This pull request fixes an issue when creating a new entry, where the collection's route uses the entry ID, like this: /members/{id} or simply /{id}.

Previously, when creating an entry, no ID would exist so the URI would be simplified to /members so if you had an existing entry at /members, it would cause a validation error.

This PR attempts to fix this by always passing an ID into the UrlBuilder if the entry doesn't already have one set.

Fixes #5500.

Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might break Eloquent since then it will try having a UUID as the ID when it should really generate an ID when it's inserted.

Maybe you can tweak validateUniqueUri to check for $entry->id() being null?

@duncanmcclean duncanmcclean marked this pull request as draft November 21, 2023 15:10
@duncanmcclean duncanmcclean marked this pull request as ready for review November 21, 2023 16:00
@jasonvarga jasonvarga merged commit 4350f94 into 4.x Nov 21, 2023
36 checks passed
@jasonvarga jasonvarga deleted the fix/url-validation-error-when-collection-route-uses-ids branch November 21, 2023 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"The given data was invalid" / "This URI has already been taken." when using /{id} as route
2 participants