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

Sonata 4 - Cannot delete anything #7346

Closed Fl0ux closed 3 years ago

Fl0ux commented 3 years ago

Environment

Sonata packages

show

``` sonata-project/admin-bundle dev-master b9b03b6 dev-master b9b03b6 The missing Symfony Ad... 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.13.1 1.13.1 Doctrine2 behavioral e... sonata-project/doctrine-orm-admin-bundle dev-master 3938ce6 dev-master 3938ce6 Integrate Doctrine ORM... sonata-project/exporter 2.7.0 2.7.0 Lightweight Exporter l... sonata-project/form-extensions 1.9.0 1.9.0 Symfony form extensions sonata-project/twig-extensions 1.7.0 1.7.0 Sonata twig extensions ```

Symfony packages

show

``` symfony/asset v5.3.2 v5.3.2 Manages URL generation and versioning of web asset... symfony/browser-kit v5.3.0 v5.3.0 Simulates the behavior of a web browser, allowing ... symfony/cache v5.3.3 v5.3.3 Provides an extended PSR-6, PSR-16 (and tags) impl... symfony/cache-contracts v2.4.0 v2.4.0 Generic abstractions related to caching symfony/config v5.3.3 v5.3.3 Helps you find, load, combine, autofill and valida... symfony/console v5.3.2 v5.3.2 Eases the creation of beautiful and testable comma... symfony/css-selector v5.3.0 v5.3.0 Converts CSS selectors to XPath expressions symfony/debug-bundle v5.3.0 v5.3.0 Provides a tight integration of the Symfony Debug ... symfony/dependency-injection v5.3.3 v5.3.3 Allows you to standardize and centralize the way o... symfony/deprecation-contracts v2.4.0 v2.4.0 A generic function and convention to trigger depre... symfony/doctrine-bridge v5.3.3 v5.3.3 Provides integration for Doctrine with various Sym... symfony/dom-crawler v5.3.0 v5.3.0 Eases DOM navigation for HTML and XML documents symfony/dotenv v5.3.0 v5.3.0 Registers environment variables from a .env file symfony/error-handler v5.3.3 v5.3.3 Provides tools to manage errors and ease debugging... symfony/event-dispatcher v5.3.0 v5.3.0 Provides tools that allow your application compone... symfony/event-dispatcher-contracts v2.4.0 v2.4.0 Generic abstractions related to dispatching event symfony/expression-language v5.3.0 v5.3.0 Provides an engine that can compile and evaluate e... symfony/filesystem v5.3.3 v5.3.3 Provides basic utilities for the filesystem symfony/finder v5.3.0 v5.3.0 Finds files and directories via an intuitive fluen... symfony/flex v1.13.3 v1.13.3 Composer plugin for Symfony symfony/form v5.3.3 v5.3.3 Allows to easily create, process and reuse HTML forms symfony/framework-bundle v5.3.3 v5.3.3 Provides a tight integration between Symfony compo... symfony/http-client v5.3.3 v5.3.3 Provides powerful methods to fetch HTTP resources ... symfony/http-client-contracts v2.4.0 v2.4.0 Generic abstractions related to HTTP clients symfony/http-foundation v5.3.3 v5.3.3 Defines an object-oriented layer for the HTTP spec... symfony/http-kernel v5.3.3 v5.3.3 Provides a structured process for converting a Req... symfony/intl v5.3.0 v5.3.0 Provides a PHP replacement layer for the C intl ex... symfony/mailer v5.3.3 v5.3.3 Helps sending emails symfony/maker-bundle v1.33.0 v1.33.0 Symfony Maker helps you create empty commands, con... symfony/mime v5.3.2 v5.3.2 Allows manipulating MIME messages symfony/monolog-bridge v5.3.3 v5.3.3 Provides integration for Monolog with various Symf... symfony/monolog-bundle v3.7.0 v3.7.0 Symfony MonologBundle symfony/notifier v5.3.3 v5.3.3 Sends notifications via one or more channels (emai... symfony/options-resolver v5.3.0 v5.3.0 Provides an improved replacement for the array_rep... symfony/password-hasher v5.3.3 v5.3.3 Provides password hashing utilities symfony/phpunit-bridge v5.3.3 v5.3.3 Provides utilities for PHPUnit, especially user de... 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 c... symfony/polyfill-intl-idn v1.23.0 v1.23.0 Symfony polyfill for intl's idn_to_ascii and idn_t... symfony/polyfill-intl-normalizer v1.23.0 v1.23.0 Symfony polyfill for intl's Normalizer class and r... 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+ feature... symfony/polyfill-php80 v1.23.0 v1.23.0 Symfony polyfill backporting some PHP 8.0+ feature... symfony/polyfill-php81 v1.23.0 v1.23.0 Symfony polyfill backporting some PHP 8.1+ feature... symfony/process v5.3.2 v5.3.2 Executes commands in sub-processes symfony/property-access v5.3.0 v5.3.0 Provides functions to read and write from/to an ob... symfony/property-info v5.3.1 v5.3.1 Extracts information about PHP class' properties u... symfony/proxy-manager-bridge v5.3.0 v5.3.0 Provides integration for ProxyManager with various... symfony/routing v5.3.0 v5.3.0 Maps an HTTP request to a set of configuration var... symfony/runtime v5.3.3 v5.3.3 Enables decoupling PHP applications from global state symfony/security-acl v3.2.0 v3.2.0 Symfony Security Component - ACL (Access Control L... symfony/security-bundle v5.3.3 v5.3.3 Provides a tight integration of the Security compo... symfony/security-core v5.3.3 v5.3.3 Symfony Security Component - Core Library symfony/security-csrf v5.3.3 v5.3.3 Symfony Security Component - CSRF Library symfony/security-guard v5.3.0 v5.3.0 Symfony Security Component - Guard symfony/security-http v5.3.3 v5.3.3 Symfony Security Component - HTTP Integration symfony/serializer v5.3.2 v5.3.2 Handles serializing and deserializing data structu... symfony/service-contracts v2.4.0 v2.4.0 Generic abstractions related to writing services symfony/stopwatch v5.3.0 v5.3.0 Provides a way to profile code symfony/string v5.3.3 v5.3.3 Provides an object-oriented API to strings and dea... symfony/translation v5.3.3 v5.3.3 Provides tools to internationalize your application symfony/translation-contracts v2.4.0 v2.4.0 Generic abstractions related to translation symfony/twig-bridge v5.3.3 v5.3.3 Provides integration for Twig with various Symfony... symfony/twig-bundle v5.3.3 v5.3.3 Provides a tight integration of Twig into the Symf... symfony/validator v5.3.3 v5.3.3 Provides tools to validate values symfony/var-dumper v5.3.3 v5.3.3 Provides mechanisms for walking through any arbitr... symfony/var-exporter v5.3.3 v5.3.3 Allows exporting any serializable PHP data structu... symfony/web-link v5.3.3 v5.3.3 Manages links between resources symfony/web-profiler-bundle v5.3.2 v5.3.2 Provides a development tool that gives detailed in... symfony/yaml v5.3.3 v5.3.3 Loads and dumps YAML files ```

PHP version

PHP 8.0.8 (cli) (built: Jun 29 2021 16:09:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.8, Copyright (c) Zend Technologies

Subject

If you try to delete an entity in Sonata admin, pressing the "Yes, delete" button, it will do nothing. The page reloads every time I it this button without deleting the entity.

I can reproduce this bug in our production application and in a fresh minimal test project.

VincentLanglet commented 3 years ago

Hi, thanks for the report ! If you can reproduce this bug on a fresh minimal test project, can you give the repository to debug ?

Also, did you try some older commit in order to find where the regression come from ?

VincentLanglet commented 3 years ago

Also you may debug your vendor.

Maybe you're not entering in the following if https://github.com/sonata-project/SonataAdminBundle/blob/master/src/Controller/CRUDController.php#L190

This issue makes me think to https://github.com/sonata-project/SonataAdminBundle/issues/7229

Fl0ux commented 3 years ago

Yep it is the same bug. The solution is to set this options to "true", which is "false" by default

http_method_override: true

Maybe it should be documented in the installation process or something.

VincentLanglet commented 3 years ago

It seems to be true by default in the doc https://symfony.com/doc/current/reference/configuration/framework.html#http-method-override

I don't know why it was done like this, but wouldn't it be better to use a Symfony form for this https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Resources/views/CRUD/delete.html.twig#L36-L48

And in the controller, we'll do

if ($form->isSubmitted() && $form->isValid()) {
}

cc @sonata-project/contributors

Fl0ux commented 3 years ago

When creating a new project with this command, it is set to "false"

symfony new my_project_name --full
jordisala1991 commented 3 years ago

Fixed