sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Unable to delete object - wrong request method #7229

Closed axzx closed 3 years ago

axzx commented 3 years ago

Environment

Sonata packages

show

``` $ composer show --latest 'sonata-project/*' sonata-project/admin-bundle dev-master 9683a1f dev-master 9683a1f The missing Symfony Admin Generator sonata-project/block-bundle 4.6.0 4.6.0 Symfony SonataBlockBundle sonata-project/cache 2.1.1 2.1.1 Cache library sonata-project/doctrine-extensions 1.12.0 1.12.0 Doctrine2 behavioral extensions sonata-project/doctrine-orm-admin-bundle dev-master 750ace9 dev-master 750ace9 Integrate Doctrine ORM into the SonataAdminBundle sonata-project/exporter 2.6.2 2.6.2 Lightweight Exporter library sonata-project/form-extensions 1.9.0 1.9.0 Symfony form extensions sonata-project/twig-extensions 1.6.0 1.6.0 Sonata twig extensions ```

Symfony packages

show

``` $ composer show --latest 'symfony/*' symfony/asset 5.4.x-dev 4659438 5.4.x-dev 4659438 Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files symfony/browser-kit 5.4.x-dev 4ec2553 5.4.x-dev 4ec2553 Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically symfony/cache 5.4.x-dev b602a62 5.4.x-dev b602a62 Provides an extended PSR-6, PSR-16 (and tags) implementation symfony/cache-contracts v2.4.0 v2.4.0 Generic abstractions related to caching symfony/config 5.4.x-dev db7f82e 5.4.x-dev db7f82e Helps you find, load, combine, autofill and validate configuration values of any kind symfony/console 5.4.x-dev 43b1284 5.4.x-dev 43b1284 Eases the creation of beautiful and testable command line interfaces symfony/css-selector 5.4.x-dev 5d5f978 5.4.x-dev 5d5f978 Converts CSS selectors to XPath expressions symfony/debug-bundle 5.4.x-dev ea0d473 5.x-dev b73833a Provides a tight integration of the Symfony Debug component into the Symfony full-stack framework symfony/dependency-injection 5.4.x-dev 32bc320 5.4.x-dev 32bc320 Allows you to standardize and centralize the way objects are constructed in your application symfony/deprecation-contracts v2.4.0 v2.4.0 A generic function and convention to trigger deprecation notices symfony/doctrine-bridge 5.4.x-dev 46ac30f 5.4.x-dev 46ac30f Provides integration for Doctrine with various Symfony components symfony/dom-crawler 5.4.x-dev 194246b 5.4.x-dev 194246b Eases DOM navigation for HTML and XML documents symfony/dotenv 5.4.x-dev 4ababad 5.4.x-dev 4ababad Registers environment variables from a .env file symfony/error-handler 5.4.x-dev f5ae1a4 5.4.x-dev f5ae1a4 Provides tools to manage errors and ease debugging PHP code symfony/event-dispatcher 5.4.x-dev aecf90f 5.4.x-dev aecf90f Provides tools that allow your application components to communicate with each other by dispatching events and listening to them symfony/event-dispatcher-contracts v2.4.0 v2.4.0 Generic abstractions related to dispatching event symfony/expression-language 5.4.x-dev 324a7c0 5.4.x-dev 324a7c0 Provides an engine that can compile and evaluate expressions symfony/filesystem 5.4.x-dev 3481163 5.4.x-dev 3481163 Provides basic utilities for the filesystem symfony/finder 5.4.x-dev ccccb9d 5.4.x-dev ccccb9d Finds files and directories via an intuitive fluent interface symfony/flex v1.13.3 v1.13.3 Composer plugin for Symfony symfony/form 5.4.x-dev 7804ddc 5.4.x-dev 7804ddc Allows to easily create, process and reuse HTML forms symfony/framework-bundle 5.4.x-dev 65f69e6 5.4.x-dev 65f69e6 Provides a tight integration between Symfony components and the Symfony full-stack framework symfony/http-client 5.4.x-dev abac7e0 5.4.x-dev abac7e0 Provides powerful methods to fetch HTTP resources synchronously or asynchronously symfony/http-client-contracts v2.4.0 v2.4.0 Generic abstractions related to HTTP clients symfony/http-foundation 5.4.x-dev 6058b19 5.4.x-dev 6058b19 Defines an object-oriented layer for the HTTP specification symfony/http-kernel 5.4.x-dev 2a6c5dd 5.4.x-dev 2a6c5dd Provides a structured process for converting a Request into a Response symfony/intl 5.4.x-dev bb7376e 5.4.x-dev bb7376e Provides a PHP replacement layer for the C intl extension that includes additional data from the ICU library symfony/mailer 5.4.x-dev 6dca77f 5.4.x-dev 6dca77f Helps sending emails symfony/maker-bundle v1.31.1 v1.31.1 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code. symfony/mime 5.4.x-dev 8210beb 5.4.x-dev 8210beb Allows manipulating MIME messages symfony/monolog-bridge 5.4.x-dev 9e336ff 5.4.x-dev 9e336ff Provides integration for Monolog with various Symfony components symfony/monolog-bundle v3.7.0 v3.7.0 Symfony MonologBundle symfony/notifier 5.4.x-dev 8720dfe 5.4.x-dev 8720dfe Sends notifications via one or more channels (email, SMS, ...) symfony/options-resolver 5.4.x-dev 162e886 5.4.x-dev 162e886 Provides an improved replacement for the array_replace PHP function symfony/password-hasher 5.4.x-dev 1e66f54 5.4.x-dev 1e66f54 Provides password hashing utilities symfony/phpunit-bridge v5.2.9 v5.2.9 Provides utilities for PHPUnit, especially user deprecation notices management symfony/polyfill-intl-grapheme v1.23.0 v1.23.0 Symfony polyfill for intl's grapheme_* functions symfony/polyfill-intl-icu v1.23.0 v1.23.0 Symfony polyfill for intl's ICU-related data and classes symfony/polyfill-intl-idn v1.23.0 v1.23.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions symfony/polyfill-intl-normalizer v1.23.0 v1.23.0 Symfony polyfill for intl's Normalizer class and related functions symfony/polyfill-mbstring v1.23.0 v1.23.0 Symfony polyfill for the Mbstring extension symfony/polyfill-php73 v1.23.0 v1.23.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions symfony/polyfill-php80 v1.23.0 v1.23.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions symfony/polyfill-php81 v1.23.0 v1.23.0 Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions symfony/process 5.4.x-dev 53e36cb 5.4.x-dev 53e36cb Executes commands in sub-processes symfony/property-access 5.4.x-dev fd89ef3 5.4.x-dev fd89ef3 Provides functions to read and write from/to an object or array using a simple string notation symfony/property-info 5.4.x-dev 03de253 5.4.x-dev 03de253 Extracts information about PHP class' properties using metadata of popular sources symfony/proxy-manager-bridge 5.4.x-dev a87444e 5.4.x-dev a87444e Provides integration for ProxyManager with various Symfony components symfony/routing 5.4.x-dev d9b66a0 5.4.x-dev d9b66a0 Maps an HTTP request to a set of configuration variables symfony/runtime 5.4.x-dev 02c710b 5.4.x-dev 02c710b Enables decoupling PHP applications from global state symfony/security-acl v3.1.2 v3.1.2 Symfony Security Component - ACL (Access Control List) symfony/security-bundle 5.4.x-dev a81625f 5.4.x-dev a81625f Provides a tight integration of the Security component into the Symfony full-stack framework symfony/security-core 5.4.x-dev 8c6734b 5.4.x-dev 8c6734b Symfony Security Component - Core Library symfony/security-csrf 5.4.x-dev 03010e7 5.4.x-dev 03010e7 Symfony Security Component - CSRF Library symfony/security-guard 5.4.x-dev 240c71e 5.4.x-dev 240c71e Symfony Security Component - Guard symfony/security-http 5.4.x-dev 26ebe6e 5.4.x-dev 26ebe6e Symfony Security Component - HTTP Integration symfony/serializer 5.4.x-dev c0375c4 5.4.x-dev c0375c4 Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON. symfony/service-contracts v2.4.0 v2.4.0 Generic abstractions related to writing services symfony/stopwatch 5.4.x-dev 8b99a52 5.4.x-dev 8b99a52 Provides a way to profile code symfony/string 5.4.x-dev 0741794 5.4.x-dev 0741794 Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way symfony/translation 5.4.x-dev f924722 5.4.x-dev f924722 Provides tools to internationalize your application symfony/translation-contracts v2.4.0 v2.4.0 Generic abstractions related to translation symfony/twig-bridge 5.4.x-dev 218a1ad 5.4.x-dev 218a1ad Provides integration for Twig with various Symfony components symfony/twig-bundle 5.4.x-dev 2aebe44 5.4.x-dev 2aebe44 Provides a tight integration of Twig into the Symfony full-stack framework symfony/validator 5.4.x-dev ddc698d 5.4.x-dev ddc698d Provides tools to validate values symfony/var-dumper 5.4.x-dev 173cf39 5.4.x-dev 173cf39 Provides mechanisms for walking through any arbitrary PHP variable symfony/var-exporter 5.4.x-dev 74b0c1b 5.4.x-dev 74b0c1b Allows exporting any serializable PHP data structure to plain PHP code symfony/web-link 5.4.x-dev f1e15f2 5.4.x-dev f1e15f2 Manages links between resources symfony/web-profiler-bundle 5.4.x-dev 06b5b3d 5.4.x-dev 06b5b3d Provides a development tool that gives detailed information about the execution of any request symfony/yaml 5.4.x-dev 55f55b0 5.4.x-dev 55f55b0 Loads and dumps YAML files ```

PHP version

$ php -v
PHP 7.4.16 (cli) (built: Mar 23 2021 16:15:03) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.16, Copyright (c), by Zend Technologies

Subject

Minimal repository with the bug

Steps to reproduce

simple admin with simply entity

Expected results

object removal

Actual results

the object is not removed, user remains on the same action

CRUDController line 193

dd($request->getMethod());
if (Request::METHOD_DELETE === $request->getMethod()) {

debug result: post

dmaicher commented 3 years ago

What is your configuration for HTTP method overwrite in Symfony?

see https://symfony.com/doc/current/reference/configuration/framework.html#http-method-override

I guess this must be enabled to work properly?

VincentLanglet commented 3 years ago

Did you have this issue in 3.x version @axzx ?

axzx commented 3 years ago

Did you have this issue in 3.x version @axzx ?

sonata-project/admin-bundle dev-master 9683a1f

axzx commented 3 years ago

What is your configuration for HTTP method overwrite in Symfony?

see https://symfony.com/doc/current/reference/configuration/framework.html#http-method-override

I guess this must be enabled to work properly?

Everything is default. I created a new Symfony 5.4 project

VincentLanglet commented 3 years ago

Did you have this issue in 3.x version @axzx ?

sonata-project/admin-bundle dev-master 9683a1f

I don't remember we works on the deleteAction in master branch, so I wondered if the bug could be reproduce in 3.x or if it's a regression.

For instance, the Delete action works fine on my project which use the last 3.x version. @dmaicher use the 4.x version and I assume the delete works fine for him.

So it would be nice to understand why you have this bug.

Everything is default. I created a new Symfony 5.4 project

Could it be related to Symfony 5.4 ?

We have the following code https://github.com/sonata-project/SonataAdminBundle/blob/master/src/Resources/views/CRUD/delete.html.twig#L37

axzx commented 3 years ago

I guess I know what's getting mixed up. apparently there is something wrong with Symfony 5.4

my public/index.php

<?php

use App\Kernel;

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (array $context) {
    return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};

It was generated automatically as I created a new project from Symfony website / skeleton.

For now, we can close this issue. Work on Symfony 5.4 is underway.

VincentLanglet commented 3 years ago

For now, we can close this issue. Work on Symfony 5.4 is underway.

Sure, but maybe you have something to report on Symfony (?)