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

[admin 4.22.4] checkParentChildAssociation fails when parentAssociationMapping is null #8199

Closed piero-hgt closed 1 day ago

piero-hgt commented 3 months ago

Environment

Sonata packages

show

``` $ composer show --latest 'sonata-project/*' Direct dependencies required in composer.json: sonata-project/admin-bundle 4.22.4 4.22.4 The missing Symfony Admin Generator sonata-project/doctrine-extensions 1.18.1 1.18.1 Doctrine2 behavioral extensions sonata-project/doctrine-orm-admin-bundle 4.9.1 4.9.1 Integrate Doctrine ORM into the SonataAdminBundle sonata-project/entity-audit-bundle 1.3.2 1.12.0 Audit for Doctrine Entities sonata-project/exporter 2.14.0 2.14.0 Lightweight Exporter library sonata-project/form-extensions 1.18.0 1.18.0 Symfony form extensions sonata-project/intl-bundle 2.14.1 2.14.1 Symfony SonataIntlBundle sonata-project/translation-bundle 3.1.0 3.1.0 SonataTranslationBundle sonata-project/twig-extensions 1.12.0 1.12.0 Sonata twig extensions Transitive dependencies not required in composer.json: sonata-project/block-bundle 4.19.0 4.19.0 Symfony SonataBlockBundle sonata-project/cache 2.2.0 2.2.0 Cache library ```

Symfony packages

show

``` $ composer show --latest 'symfony/*' Direct dependencies required in composer.json: symfony/asset v4.4.46 v5.4.40 Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files symfony/browser-kit v4.4.44 v5.4.40 Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically symfony/css-selector v4.4.44 v5.4.40 Converts CSS selectors to XPath expressions symfony/debug-bundle v4.4.37 v5.4.40 Provides a tight integration of the Symfony VarDumper component and the ServerLogCommand from MonologBridge into the Symfony full-stack framework symfony/dotenv v4.4.37 v5.4.42 Registers environment variables from a .env file symfony/filesystem v5.4.41 v5.4.41 Provides basic utilities for the filesystem symfony/flex v1.21.6 v1.21.7 Composer plugin for Symfony symfony/form v4.4.48 v5.4.40 Allows to easily create, process and reuse HTML forms symfony/framework-bundle v4.4.51 v5.4.42 Provides a tight integration between Symfony components and the Symfony full-stack framework symfony/http-client v4.4.51 v5.4.42 Provides powerful methods to fetch HTTP resources synchronously or asynchronously symfony/lock v4.4.46 v5.4.40 Creates and manages locks, a mechanism to provide exclusive access to a shared resource symfony/mailer v4.4.49 v5.4.41 Helps sending emails symfony/maker-bundle v1.39.1 v1.43.0 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code. symfony/messenger v4.4.49 v5.4.42 Helps applications send and receive messages to/from other applications or via message queues symfony/monolog-bundle v3.5.0 v3.10.0 Symfony MonologBundle symfony/phpunit-bridge v6.4.6 v7.1.3 Provides utilities for PHPUnit, especially user deprecation notices management symfony/polyfill-apcu v1.30.0 v1.30.0 Symfony polyfill backporting apcu_* functions to lower PHP versions symfony/routing v4.4.44 v5.4.42 Maps an HTTP request to a set of configuration variables symfony/security-bundle v4.4.50 v5.4.41 Provides a tight integration of the Security component into the Symfony full-stack framework symfony/serializer v4.4.47 v5.4.42 Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON. symfony/stopwatch v4.4.46 v5.4.40 Provides a way to profile code symfony/translation v4.4.47 v5.4.42 Provides tools to internationalize your application symfony/validator v4.4.48 v5.4.42 Provides tools to validate values symfony/web-link v4.4.37 v5.4.40 Manages links between resources symfony/web-profiler-bundle v4.4.47 v5.4.40 Provides a development tool that gives detailed information about the execution of any request symfony/webpack-encore-bundle v1.17.2 v1.17.2 Integration with your Symfony app & Webpack Encore! symfony/workflow v4.4.44 v5.4.40 Provides tools for managing a workflow or finite state machine symfony/yaml v4.4.45 v5.4.40 Loads and dumps YAML files ```

PHP version

$ php -v
PHP 7.4.33 (cli) (built: Nov 15 2022 03:43:02) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
    with Xdebug v3.1.6, Copyright (c) 2002-2022, by Derick Rethans

Subject

Hello everyone, I'm reporting a bug in sonata admin 4.22.4 (last version for php 7.4) which is fixed in 4.24.0 (php8).

In 4.22.4: https://github.com/sonata-project/SonataAdminBundle/blob/e3a845e9c9bdb3848fa896ed106f1645b6336005/src/Controller/CRUDController.php#L1465-L1468

In 4.24.0: https://github.com/sonata-project/SonataAdminBundle/blob/81646330df74474c68812d32e2e489bf4ba751fb/src/Controller/CRUDController.php#L1455-L1458

I have a Admin (UserAdmin). with a childAdmin (ThreadAdmin) without direct relation, so I'm adding it with $parentAssociationMapping = null.

But then the checkParentChildAssociation fails instead of returning silently.

Could it be possible to have this fix applied on 4.22.4 ? I can make a PR.

Thanks !

Minimal repository with the bug

Steps to reproduce

Expected results

Actual results

VincentLanglet commented 1 day ago

Sorry we only support the latest version of Sonata, and php 7.4 is far EOL.

I recommend you to fork it if you want to add extra fix on old version.