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

[4.22.0] AssertionError #7997

Closed haivala closed 1 year ago

haivala commented 1 year ago

Environment

Sonata packages

show

``` $ composer show --latest 'sonata-project/*' Direct dependencies required in composer.json: sonata-project/admin-bundle 4.22.0 4.22.0 The missing Symfony Admin Generator sonata-project/classification-bundle 4.3.0 4.3.0 Symfony SonataClassificationBundle sonata-project/doctrine-orm-admin-bundle 4.9.1 4.9.1 Integrate Doctrine ORM into the SonataAdminBundle sonata-project/entity-audit-bundle 1.9.0 1.9.0 Audit for Doctrine Entities sonata-project/formatter-bundle 5.0.1 5.0.1 Symfony SonataFormatterBundle sonata-project/media-bundle 4.5.1 4.5.1 Symfony SonataMediaBundle sonata-project/page-bundle 4.0.0 4.0.0 This bundle provides a Site and Page management through container and block services sonata-project/seo-bundle 3.5.0 3.5.0 Symfony SonataSeoBundle 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 Package sonata-project/cache is abandoned, you should avoid using it. No replacement was suggested. sonata-project/doctrine-extensions 2.1.0 2.1.0 Doctrine2 behavioral extensions sonata-project/exporter 3.1.1 3.1.1 Lightweight Exporter library sonata-project/form-extensions 1.18.0 1.18.0 Symfony form extensions sonata-project/twig-extensions 2.0.0 2.0.0 Sonata twig extensions ```

Symfony packages

show

``` $ composer show --latest 'symfony/*' Direct dependencies required in composer.json: symfony/console v5.4.17 v6.2.3 Eases the creation of beautiful and testable command line interfaces symfony/debug-bundle v5.4.11 v6.2.1 Provides a tight integration of the Symfony VarDumper component and the ServerLogComma... symfony/dotenv v5.4.5 v6.2.0 Registers environment variables from a .env file symfony/flex v2.2.4 v2.2.4 Composer plugin for Symfony symfony/framework-bundle v5.4.17 v6.2.3 Provides a tight integration between Symfony components and the Symfony full-stack fra... symfony/http-client v5.4.17 v6.2.2 Provides powerful methods to fetch HTTP resources synchronously or asynchronously symfony/mailer v5.4.17 v6.2.2 Helps sending emails symfony/maker-bundle v1.48.0 v1.48.0 Symfony Maker helps you create empty commands, controllers, form classes, tests and mo... symfony/monolog-bridge v5.4.17 v6.2.2 Provides integration for Monolog with various Symfony components symfony/monolog-bundle v3.8.0 v3.8.0 Symfony MonologBundle symfony/stopwatch v5.4.13 v6.2.0 Provides a way to profile code symfony/ux-turbo v2.6.1 v2.6.1 Hotwire Turbo integration for Symfony symfony/web-profiler-bundle v5.4.17 v6.2.4 Provides a development tool that gives detailed information about the execution of any... symfony/webpack-encore-bundle v1.16.0 v1.16.0 Integration with your Symfony app & Webpack Encore! symfony/yaml v5.4.17 v6.2.2 Loads and dumps YAML files Transitive dependencies not required in composer.json: symfony/asset v5.4.13 v6.2.0 Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScrip... symfony/cache v5.4.18 v6.2.4 Provides extended PSR-6, PSR-16 (and tags) implementations symfony/cache-contracts v2.5.2 v3.2.0 Generic abstractions related to caching symfony/config v5.4.11 v6.2.0 Helps you find, load, combine, autofill and validate configuration values of any kind symfony/dependency-injection v5.4.17 v6.2.3 Allows you to standardize and centralize the way objects are constructed in your appli... symfony/deprecation-contracts v3.2.0 v3.2.0 A generic function and convention to trigger deprecation notices symfony/doctrine-bridge v5.4.17 v6.2.3 Provides integration for Doctrine with various Symfony components symfony/error-handler v5.4.17 v6.2.3 Provides tools to manage errors and ease debugging PHP code symfony/event-dispatcher v5.4.17 v6.2.2 Provides tools that allow your application components to communicate with each other b... symfony/event-dispatcher-contracts v3.2.0 v3.2.0 Generic abstractions related to dispatching event symfony/expression-language v5.4.14 v6.2.2 Provides an engine that can compile and evaluate expressions symfony/filesystem v5.4.13 v6.2.0 Provides basic utilities for the filesystem symfony/finder v5.4.17 v6.2.3 Finds files and directories via an intuitive fluent interface symfony/form v5.4.17 v6.2.3 Allows to easily create, process and reuse HTML forms symfony/http-client-contracts v2.5.2 v3.1.1 Generic abstractions related to HTTP clients symfony/http-foundation v5.4.17 v6.2.2 Defines an object-oriented layer for the HTTP specification symfony/http-kernel v5.4.18 v6.2.4 Provides a structured process for converting a Request into a Response symfony/intl v5.4.15 v6.2.0 Provides a PHP replacement layer for the C intl extension that includes additional dat... symfony/mime v5.4.17 v6.2.2 Allows manipulating MIME messages symfony/options-resolver v5.4.11 v6.2.0 Provides an improved replacement for the array_replace PHP function symfony/password-hasher v5.4.11 v6.2.0 Provides password hashing utilities symfony/polyfill-ctype v1.27.0 v1.27.0 Symfony polyfill for ctype functions symfony/polyfill-intl-grapheme v1.27.0 v1.27.0 Symfony polyfill for intl's grapheme_* functions symfony/polyfill-intl-icu v1.27.0 v1.27.0 Symfony polyfill for intl's ICU-related data and classes symfony/polyfill-intl-idn v1.27.0 v1.27.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions symfony/polyfill-intl-normalizer v1.27.0 v1.27.0 Symfony polyfill for intl's Normalizer class and related functions symfony/polyfill-mbstring v1.27.0 v1.27.0 Symfony polyfill for the Mbstring extension symfony/polyfill-php72 v1.27.0 v1.27.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions symfony/polyfill-php73 v1.27.0 v1.27.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions symfony/polyfill-php80 v1.27.0 v1.27.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions symfony/polyfill-php81 v1.27.0 v1.27.0 Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions symfony/process v5.4.11 v6.2.0 Executes commands in sub-processes symfony/property-access v5.4.15 v6.2.3 Provides functions to read and write from/to an object or array using a simple string ... symfony/property-info v5.4.17 v6.2.3 Extracts information about PHP class' properties using metadata of popular sources symfony/psr-http-message-bridge v2.1.4 v2.1.4 PSR HTTP message bridge symfony/routing v5.4.17 v6.2.3 Maps an HTTP request to a set of configuration variables symfony/security-acl v3.3.2 v3.3.2 Symfony Security Component - ACL (Access Control List) symfony/security-bundle v5.4.17 v6.2.3 Provides a tight integration of the Security component into the Symfony full-stack fra... symfony/security-core v5.4.15 v6.2.2 Symfony Security Component - Core Library symfony/security-csrf v5.4.11 v6.2.0 Symfony Security Component - CSRF Library symfony/security-guard v5.4.13 v5.4.13 Symfony Security Component - Guard symfony/security-http v5.4.17 v6.2.2 Symfony Security Component - HTTP Integration symfony/serializer v5.4.17 v6.2.3 Handles serializing and deserializing data structures, including object graphs, into a... symfony/service-contracts v2.5.2 v3.2.0 Generic abstractions related to writing services symfony/string v5.4.17 v6.2.2 Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and... symfony/translation v5.4.14 v6.2.3 Provides tools to internationalize your application symfony/translation-contracts v2.5.2 v3.2.0 Generic abstractions related to translation symfony/twig-bridge v5.4.17 v6.2.3 Provides integration for Twig with various Symfony components symfony/twig-bundle v5.4.17 v6.2.3 Provides a tight integration of Twig into the Symfony full-stack framework symfony/validator v5.4.17 v6.2.3 Provides tools to validate values symfony/var-dumper v5.4.17 v6.2.3 Provides mechanisms for walking through any arbitrary PHP variable symfony/var-exporter v5.4.17 v6.2.3 Allows exporting any serializable PHP data structure to plain PHP code ```

PHP version

$ php -v
PHP 8.2.0 (cli) (built: Dec  8 2022 20:06:26) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.0, Copyright (c), by Zend Technologies

Subject

Updated to 4.22.0 and I'm getting this error

AssertionError:
assert(class_exists($adminClass))

  at /var/www/symfony/vendor/sonata-project/admin-bundle/src/DependencyInjection/Compiler/ExtensionCompilerPass.php:108
  at assert(false, 'assert(class_exists($adminClass))')
     (/var/www/symfony/vendor/sonata-project/admin-bundle/src/DependencyInjection/Compiler/ExtensionCompilerPass.php:108)
  at Sonata\AdminBundle\DependencyInjection\Compiler\ExtensionCompilerPass->process(object(ContainerBuilder))
     (/var/www/symfony/vendor/symfony/dependency-injection/Compiler/Compiler.php:82)
  at Symfony\Component\DependencyInjection\Compiler\Compiler->compile(object(ContainerBuilder))
     (/var/www/symfony/vendor/symfony/dependency-injection/ContainerBuilder.php:757)
  at Symfony\Component\DependencyInjection\ContainerBuilder->compile()
     (/var/www/symfony/vendor/symfony/http-kernel/Kernel.php:546)
  at Symfony\Component\HttpKernel\Kernel->initializeContainer()
     (/var/www/symfony/vendor/symfony/http-kernel/Kernel.php:787)
  at Symfony\Component\HttpKernel\Kernel->preBoot()
     (/var/www/symfony/vendor/symfony/http-kernel/Kernel.php:190)
  at Symfony\Component\HttpKernel\Kernel->handle(object(SiteRequest))
     (/var/www/symfony/public/index.php:22)                

Downgraded to 4.21 and everything works again.

VincentLanglet commented 1 year ago

Hi, what is the value of $adminClass ?

haivala commented 1 year ago

I don't know as this error breaks everything.

Trying to run console or any console command produces this. Same for any url visit. It does not write anything to logs

VincentLanglet commented 1 year ago

I don't know as this error breaks everything.

Trying to run console or any console command produces this. Same for any url visit. It does not write anything to logs

Can't you add a dd($adminClass) in the vendor right before the assert ? Or a throw new \Exception($adminClass).

haivala commented 1 year ago

ah true, hmm, It says "App\Admin\ItemAdmin"

VincentLanglet commented 1 year ago

ah true, hmm, It says "App\Admin\ItemAdmin"

Kinda weird. I assume this class exists in your project.

Maybe you should write

if (!class_exists($adminClass)) {
     dd($adminClass);
}

to know the one throwing an error.

haivala commented 1 year ago

for that it says "%sonata.classification.admin.category.class%"

VincentLanglet commented 1 year ago

I see, the issue is that we need to resolve the parameter.

Can you try https://github.com/sonata-project/SonataAdminBundle/pull/7998 ?

haivala commented 1 year ago

Same error

VincentLanglet commented 1 year ago

Same error

I don't have a lot of time to debug this. I'm not against some help. Can you try again https://github.com/sonata-project/SonataAdminBundle/pull/7998 ? I forgot to trim the %.

If not,

if (!class_exists($adminClass)) {
     dump($container->hasParameter($adminClass));
     dump($container->getParameter($adminClass));
     dd($adminClass);
}

could help.

haivala commented 1 year ago

Sorry, but you can imagine that I'm busy too :) I'm helping as much as I can!

Seems like #7998 is working!

haivala commented 1 year ago

Thank you @VincentLanglet !

VincentLanglet commented 1 year ago

Released in 4.22.1