-
-
Notifications
You must be signed in to change notification settings - Fork 921
Disable put and delete operations support for elastic item data provider #3073
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
Disable put and delete operations support for elastic item data provider #3073
Conversation
PATCH should also be disabled |
@@ -56,6 +56,10 @@ public function __construct(Client $client, DocumentMetadataFactoryInterface $do | |||
*/ | |||
public function supports(string $resourceClass, ?string $operationName = null, array $context = []): bool | |||
{ | |||
if (\in_array($operationName, ['put', 'delete'], true)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can relate on the operation name here as the route method can be different from the operation name no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point. I can just rename the operation to "put2" via annotations for example and the fix won't work already.
Option #2
Use item operation "method" attribute in the resource metadata. It's a bit better, but we can't rely on it either, since it's possible to omit it. You can just set "route_name" and there won't be "method" property.
Option #3
Another option would be to directly check current request method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh yeah you're right about option 2... @teohhanhui what would you do?
Agree. Then probably it makes sense to support only "GET" operations, not just exclude "put", "patch", "delete". |
Can we just make sure that no default |
I guess our best shot then to just check whether it's a Updated the pull request. |
I enabled elasticsearch support for one entity and everything worked fine until I made a put request. New entity was about to be created instead of updating existing one.
It appears that when elasticsearch support is turned on even on put and delete requests entities are loaded from elastic and denormalized from the payload - as a result doctrine see them as detached entities. This leads to a new entity create on
put
operation and 500 error ondelete
.I think elasticsearch item data provider shouldn't support either
put
ordelete
operations. Or is there a better way to fix this issue?