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

BC Break in 3.77 when declaring groups in dashboard without admin #6505

Closed franmomu closed 4 years ago

franmomu commented 4 years ago

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle                  3.77.0 3.77.0 The missing Symfony Admin Generator
sonata-project/block-bundle                  3.21.0 4.4.0  Symfony SonataBlockBundle
sonata-project/cache                         2.0.1  2.0.1  Cache library
sonata-project/doctrine-extensions           1.9.1  1.9.1  Doctrine2 behavioral extensions
sonata-project/doctrine-mongodb-admin-bundle 3.5.0  3.5.0  Symfony Sonata / Integrate Doctrine MongoDB ODM into the SonataAdminBundle
sonata-project/doctrine-orm-admin-bundle     3.24   3.24   Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                      2.4.1  2.4.1  Lightweight Exporter library
sonata-project/form-extensions               1.6.0  1.6.0  Symfony form extensions
sonata-project/translation-bundle            2.6.0  2.6.0  SonataTranslationBundle
sonata-project/twig-extensions               1.4.1  1.4.1  Sonata twig extensions

Symfony packages

$ composer show --latest 'symfony/*'
symfony/amazon-mailer              v4.4.15 v4.4.15 Symfony Amazon Mailer Bridge
symfony/asset                      v4.4.15 v4.4.15 Symfony Asset Component
symfony/browser-kit                v4.4.15 v4.4.15 Symfony BrowserKit Component
symfony/cache                      v4.4.15 v4.4.15 Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts            v2.2.0  v2.2.0  Generic abstractions related to caching
symfony/config                     v4.4.15 v4.4.15 Symfony Config Component
symfony/console                    v4.4.15 v4.4.15 Symfony Console Component
symfony/css-selector               v4.4.15 v4.4.15 Symfony CssSelector Component
symfony/debug                      v4.4.15 v4.4.15 Symfony Debug Component
symfony/debug-bundle               v4.4.15 v4.4.15 Symfony DebugBundle
symfony/debug-pack                 v1.0.8  v1.0.8  A debug pack for Symfony projects
symfony/dependency-injection       v4.4.15 v4.4.15 Symfony DependencyInjection Component
symfony/deprecation-contracts      v2.2.0  v2.2.0  A generic function and convention to trigger deprecation notices
symfony/doctrine-bridge            v4.4.15 v4.4.15 Symfony Doctrine Bridge
symfony/dom-crawler                v4.4.15 v4.4.15 Symfony DomCrawler Component
symfony/dotenv                     v4.4.15 v4.4.15 Registers environment variables from a .env file
symfony/error-handler              v4.4.15 v4.4.15 Symfony ErrorHandler Component
symfony/event-dispatcher           v4.4.15 v4.4.15 Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v1.1.9  v2.2.0  Generic abstractions related to dispatching event
symfony/expression-language        v4.4.15 v4.4.15 Symfony ExpressionLanguage Component
symfony/filesystem                 v4.4.15 v4.4.15 Symfony Filesystem Component
symfony/finder                     v4.4.15 v4.4.15 Symfony Finder Component
symfony/flex                       v1.9.10 v1.9.10 Composer plugin for Symfony
symfony/form                       v4.4.15 v4.4.15 Symfony Form Component
symfony/framework-bundle           v4.4.15 v4.4.15 Symfony FrameworkBundle
symfony/http-client                v4.4.15 v4.4.15 Symfony HttpClient component
symfony/http-client-contracts      v2.3.1  v2.3.1  Generic abstractions related to HTTP clients
symfony/http-foundation            v4.4.15 v4.4.15 Symfony HttpFoundation Component
symfony/http-kernel                v4.4.15 v4.4.15 Symfony HttpKernel Component
symfony/inflector                  v4.4.15 v4.4.15 Symfony Inflector Component
symfony/intl                       v4.4.15 v4.4.15 A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/mailer                     v4.4.15 v4.4.15 Symfony Mailer Component
symfony/maker-bundle               v1.21.1 v1.21.1 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.15 v4.4.15 Symfony Messenger Component
symfony/mime                       v4.4.15 v4.4.15 A library to manipulate MIME messages
symfony/monolog-bridge             v4.4.15 v4.4.15 Symfony Monolog Bridge
symfony/monolog-bundle             v3.6.0  v3.6.0  Symfony MonologBundle
symfony/options-resolver           v4.4.15 v4.4.15 Symfony OptionsResolver Component
symfony/phpunit-bridge             v5.1.7  v5.1.7  Symfony PHPUnit Bridge
symfony/polyfill-apcu              v1.18.1 v1.18.1 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-grapheme     v1.18.1 v1.18.1 Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-icu          v1.18.1 v1.18.1 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn          v1.18.1 v1.18.1 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer   v1.18.1 v1.18.1 Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring          v1.18.1 v1.18.1 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72             v1.18.1 v1.18.1 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73             v1.18.1 v1.18.1 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80             v1.18.1 v1.18.1 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-uuid              v1.18.1 v1.18.1 Symfony polyfill for uuid functions
symfony/process                    v4.4.15 v4.4.15 Symfony Process Component
symfony/profiler-pack              v1.0.5  v1.0.5  A pack for the Symfony web profiler
symfony/property-access            v4.4.15 v4.4.15 Symfony PropertyAccess Component
symfony/property-info              v4.4.15 v4.4.15 Symfony Property Info Component
symfony/proxy-manager-bridge       v4.4.15 v4.4.15 Symfony ProxyManager Bridge
symfony/routing                    v4.4.15 v4.4.15 Symfony Routing Component
symfony/security-acl               v3.1.0  v3.1.0  Symfony Security Component - ACL (Access Control List)
symfony/security-bundle            v4.4.15 v4.4.15 Symfony SecurityBundle
symfony/security-core              v4.4.15 v4.4.15 Symfony Security Component - Core Library
symfony/security-csrf              v4.4.15 v4.4.15 Symfony Security Component - CSRF Library
symfony/security-guard             v4.4.15 v4.4.15 Symfony Security Component - Guard
symfony/security-http              v4.4.15 v4.4.15 Symfony Security Component - HTTP Integration
symfony/serializer                 v4.4.15 v4.4.15 Symfony Serializer Component
symfony/service-contracts          v2.2.0  v2.2.0  Generic abstractions related to writing services
symfony/stopwatch                  v4.4.15 v4.4.15 Symfony Stopwatch Component
symfony/string                     v5.1.7  v5.1.7  Symfony String component
symfony/templating                 v4.4.15 v4.4.15 Symfony Templating Component
symfony/test-pack                  v1.0.7  v1.0.7  A pack for functional and end-to-end testing within a Symfony app
symfony/translation                v4.4.15 v4.4.15 Symfony Translation Component
symfony/translation-contracts      v2.3.0  v2.3.0  Generic abstractions related to translation
symfony/twig-bridge                v4.4.15 v4.4.15 Symfony Twig Bridge
symfony/twig-bundle                v4.4.15 v4.4.15 Symfony TwigBundle
symfony/validator                  v4.4.15 v4.4.15 Symfony Validator Component
symfony/var-dumper                 v4.4.15 v4.4.15 Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter               v4.4.15 v4.4.15 A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-link                   v4.4.15 v4.4.15 Symfony WebLink Component
symfony/web-profiler-bundle        v4.4.15 v4.4.15 Symfony WebProfilerBundle
symfony/yaml                       v4.4.15 v4.4.15 Symfony Yaml Component

PHP version

$ php -v
PHP 7.4.5 (cli) (built: Apr 23 2020 02:25:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.5, Copyright (c), by Zend Technologies
    with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
    with blackfire v1.33.0~mac-x64-non_zts74, https://blackfire.io, by Blackfire

Subject

https://github.com/sonata-project/SonataAdminBundle/pull/6350 introduce a BC break when declaring items without an admin associated.

It throws an exception in every page:

An exception has been thrown during the rendering of a template ("Notice: Undefined index: admin"). in

https://github.com/sonata-project/SonataAdminBundle/blob/59a79fbbc0165741922fb0e531cc6b645d47e7f6/src/Admin/Pool.php#L145

Looks like it was removed from tests:

https://github.com/sonata-project/SonataAdminBundle/pull/6350/files#diff-22868865c09d35595552692a0533888fa6750899222a4b8a616347cba6c3fcb3L181

Steps to reproduce

Declare:

sonata_admin:
    dashboard:
        groups:
            my_group:
                label: My Label
                items:
                    - route: my_route
                      label: My route label

Expected results

To show groups on the side bar

Actual results

An exception has been thrown during the rendering of a template ("Notice: Undefined index: admin").

VincentLanglet commented 4 years ago

I thought it was only used here: https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Menu/Provider/GroupMenuProvider.php#L167

And there was a check isset($item['admin']) && !empty($item['admin']).

You quote https://github.com/sonata-project/SonataAdminBundle/blob/59a79fbbc0165741922fb0e531cc6b645d47e7f6/src/Admin/Pool.php#L145 IMHO, the same check should be done.

VincentLanglet commented 4 years ago

@franmomu I opened https://github.com/sonata-project/SonataAdminBundle/pull/6507