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

Fix for "delete" action not working with Sf2.2 #1184

Merged
merged 1 commit into from
Mar 27, 2013
Merged

Fix for "delete" action not working with Sf2.2 #1184

merged 1 commit into from
Mar 27, 2013

Conversation

mweimerskirch
Copy link
Contributor

This is an alternative to #1157 and #1176

@@ -211,7 +211,8 @@ public function deleteAction($id)
throw new AccessDeniedException();
}

if ($this->getRequest()->getMethod() == 'DELETE') {
$request = $this->getRequest();
if ($request->getMethod() == 'DELETE' || $request->getHttpMethodParameterOverride() == false && $request->getMethod() == 'POST') {
Copy link
Member

Choose a reason for hiding this comment

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

Can you create a method getHttpMethod() which return the correct REST Verb ?

@rande
Copy link
Member

rande commented Mar 6, 2013

@mweimerskirch ping

@mweimerskirch
Copy link
Contributor Author

@rande: Sorry, had a project launch this morning. I'll work on the patch this afternoon.

@mweimerskirch
Copy link
Contributor Author

@rande: Here you go. Is this the implementation you meant?

*/
protected function getHttpMethod() {
$request = $this->getRequest();
if($request->getHttpMethodParameterOverride()) {
Copy link
Member

Choose a reason for hiding this comment

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

it is a static method

@mweimerskirch
Copy link
Contributor Author

I removed the else and collapsed it into the first if + changed the method call to static

*
* @return string HTTP method, either
*/
protected function getHttpMethod() {
Copy link
Member

Choose a reason for hiding this comment

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

Can you rename it getRestMethod() ? sorry I didn't spot it at first

Copy link
Member

Choose a reason for hiding this comment

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

and put a new line before the {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@rande
Copy link
Member

rande commented Mar 6, 2013

@mweimerskirch are you sure about the PUT/POST action too ? do need to change the code ?

@mweimerskirch
Copy link
Contributor Author

No, I'm not sure :-(
But on my setup (that is in production since a few days) I haven't run into any other issues with the AdminBundle running on sf 2.2 so far.

@rande
Copy link
Member

rande commented Mar 6, 2013

good to know ;) There is no issue with form ?

@mweimerskirch
Copy link
Contributor Author

I'm probably not using all the field types and I also applied this for my project: sonata-project/SonataDoctrineORMAdminBundle#167 (only the first commit).
Also, there are a few deprecation notices though. I'll see when I get the time to patch those as well.
But apart from that the form works fine.

@mweimerskirch
Copy link
Contributor Author

Related patch: symfony/symfony#7202 (unfortunately pulled only into master and not into 2.2)

@sstok
Copy link
Contributor

sstok commented Mar 10, 2013

How about checking for both DELETE and POST?

Btw. for using POST I would recommend adding an CSRF token (configurable) for better security.

rande added a commit that referenced this pull request Mar 27, 2013
Fix for "delete" action not working with Sf2.2
@rande rande merged commit bf3a584 into sonata-project:master Mar 27, 2013
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.

3 participants