Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-existent service "sonata.admin.audit.manager" #7590

Closed
Hanmac opened this issue Nov 5, 2021 · 7 comments
Closed

non-existent service "sonata.admin.audit.manager" #7590

Hanmac opened this issue Nov 5, 2021 · 7 comments
Assignees

Comments

@Hanmac
Copy link
Contributor

Hanmac commented Nov 5, 2021

Environment

Sonata packages

show

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              4.2.1  4.2.1  The missing Symfony Admin Generator
sonata-project/block-bundle              4.8.0  4.8.0  Symfony SonataBlockBundle
sonata-project/cache                     2.2.0  2.2.0  Cache library
sonata-project/doctrine-extensions       1.14.0 1.14.0 Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 4.1.0  4.1.0  Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  2.8.0  2.8.0  Lightweight Exporter library
sonata-project/form-extensions           1.12.1 1.12.1 Symfony form extensions
sonata-project/twig-extensions           1.9.0  1.9.0  Sonata twig extensions

Symfony packages

show

$ composer show --latest 'symfony/*'
symfony/asset                      v5.3.4  v5.3.4  Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files
symfony/cache                      v5.3.10 v5.3.10 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                     v5.3.10 v5.3.10 Helps you find, load, combine, autofill and validate configuration values of any kind
symfony/console                    v5.3.10 v5.3.10 Eases the creation of beautiful and testable command line interfaces
symfony/dependency-injection       v5.3.10 v5.3.10 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            v5.3.8  v5.3.8  Provides integration for Doctrine with various Symfony components
symfony/dotenv                     v5.3.10 v5.3.10 Registers environment variables from a .env file
symfony/error-handler              v5.3.7  v5.3.7  Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher           v5.3.7  v5.3.7  Provides tools that allow your application components to communicate with each other by dispatching events and li...
symfony/event-dispatcher-contracts v2.4.0  v2.4.0  Generic abstractions related to dispatching event
symfony/expression-language        v5.3.7  v5.3.7  Provides an engine that can compile and evaluate expressions
symfony/filesystem                 v5.3.4  v5.3.4  Provides basic utilities for the filesystem
symfony/finder                     v5.3.7  v5.3.7  Finds files and directories via an intuitive fluent interface
symfony/flex                       v1.17.2 v1.17.2 Composer plugin for Symfony
symfony/form                       v5.3.10 v5.3.10 Allows to easily create, process and reuse HTML forms
symfony/framework-bundle           v5.3.10 v5.3.10 Provides a tight integration between Symfony components and the Symfony full-stack framework
symfony/http-client                v5.3.10 v5.3.10 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            v5.3.10 v5.3.10 Defines an object-oriented layer for the HTTP specification
symfony/http-kernel                v5.3.10 v5.3.10 Provides a structured process for converting a Request into a Response
symfony/mailer                     v5.3.9  v5.3.9  Helps sending emails
symfony/mime                       v5.3.8  v5.3.8  Allows manipulating MIME messages
symfony/monolog-bridge             v5.3.7  v5.3.7  Provides integration for Monolog with various Symfony components
symfony/monolog-bundle             v3.7.1  v3.7.1  Symfony MonologBundle
symfony/options-resolver           v5.3.7  v5.3.7  Provides an improved replacement for the array_replace PHP function
symfony/password-hasher            v5.3.8  v5.3.8  Provides password hashing utilities
symfony/polyfill-intl-grapheme     v1.23.1 v1.23.1 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.1 v1.23.1 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.1 v1.23.1 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/property-access            v5.3.8  v5.3.8  Provides functions to read and write from/to an object or array using a simple string notation
symfony/property-info              v5.3.8  v5.3.8  Extracts information about PHP class' properties using metadata of popular sources
symfony/proxy-manager-bridge       v5.3.4  v5.3.4  Provides integration for ProxyManager with various Symfony components
symfony/routing                    v5.3.7  v5.3.7  Maps an HTTP request to a set of configuration variables
symfony/runtime                    v5.3.10 v5.3.10 Enables decoupling PHP applications from global state
symfony/security-acl               v3.2.0  v3.2.0  Symfony Security Component - ACL (Access Control List)
symfony/security-bundle            v5.3.8  v5.3.8  Provides a tight integration of the Security component into the Symfony full-stack framework
symfony/security-core              v5.3.10 v5.3.10 Symfony Security Component - Core Library
symfony/security-csrf              v5.3.4  v5.3.4  Symfony Security Component - CSRF Library
symfony/security-guard             v5.3.7  v5.3.7  Symfony Security Component - Guard
symfony/security-http              v5.3.10 v5.3.10 Symfony Security Component - HTTP Integration
symfony/serializer                 v5.3.10 v5.3.10 Handles serializing and deserializing data structures, including object graphs, into array structures or other fo...
symfony/service-contracts          v2.4.0  v2.4.0  Generic abstractions related to writing services
symfony/stopwatch                  v5.3.4  v5.3.4  Provides a way to profile code
symfony/string                     v5.3.10 v5.3.10 Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a uni...
symfony/translation                v5.3.10 v5.3.10 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.7  v5.3.7  Provides integration for Twig with various Symfony components
symfony/twig-bundle                v5.3.10 v5.3.10 Provides a tight integration of Twig into the Symfony full-stack framework
symfony/validator                  v5.3.10 v5.3.10 Provides tools to validate values
symfony/var-dumper                 v5.3.10 v5.3.10 Provides mechanisms for walking through any arbitrary PHP variable
symfony/var-exporter               v5.3.8  v5.3.8  Allows exporting any serializable PHP data structure to plain PHP code
symfony/webpack-encore-bundle      v1.12.0 v1.12.0 Integration with your Symfony app & Webpack Encore!
symfony/yaml                       v5.3.6  v5.3.6  Loads and dumps YAML files

Bundles

show

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
    Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
    Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
    Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
    FOS\RestBundle\FOSRestBundle::class => ['all' => true],
    Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
    Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],

    Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],

    Sonata\Twig\Bridge\Symfony\SonataTwigBundle::class => ['all' => true],
    Sonata\Form\Bridge\Symfony\SonataFormBundle::class => ['all' => true],
    Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],
    Sonata\AdminBundle\SonataAdminBundle::class => ['all' => true],
    //Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
    Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle::class => ['all' => true],
    Sonata\Doctrine\Bridge\Symfony\SonataDoctrineBundle::class => ['all' => true],
    Sonata\Exporter\Bridge\Symfony\SonataExporterBundle::class => ['all' => true],

    Setono\CronExpressionBundle\SetonoCronExpressionBundle::class => ['all' => true],

    Nucleos\UserBundle\NucleosUserBundle::class => ['all' => true],
    Nucleos\UserAdminBundle\NucleosUserAdminBundle::class => ['all' => true],
];

PHP version

$ php -v
PHP 8.0.8 (cli) (built: Jul 22 2021 02:26:57) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.8, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.8, Copyright (c), by Zend Technologies
    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

Subject

it looks like somewhere the code isn't checking correctly if the service "sonata.admin.audit.manager" should exist or not.
it should work without EntityAuditBundle, right?

The Problem is somewhat related to CRUDController.
I don't have own CRUDController yet.

When i enable NucleosUserAdminBundle, which defines a CRUDController, the error appears.
When its disabled, its a success, because the audit.manager is added to 'removed-ids'

Minimal repository with the bug

Link: https://github.com/Hanmac/sonata_test_case

  • Fresh installed from Symfony 5.3:
symfony new .
composer require "nucleos/user-admin-bundle"
composer require "sonata-project/doctrine-orm-admin-bundle"

set the db_driver to orm:

nucleos_user:
    db_driver: orm

Steps to reproduce

 php bin/console cache:clear -vvvv

Expected results

Success or different Error

Actual results


In ContainerBuilder.php line 979:

  [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
  You have requested a non-existent service "sonata.admin.audit.manager".


Exception trace:
  at /var/www/tkonnekt_sf5/vendor/symfony/dependency-injection/ContainerBuilder.php:979
 Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition() at /var/www/tkonnekt_sf5/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:1803
 Symfony\Component\DependencyInjection\Dumper\PhpDumper->dumpValue() at /var/www/tkonnekt_sf5/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:1131
 Symfony\Component\DependencyInjection\Dumper\PhpDumper->addNewInstance() at /var/www/tkonnekt_sf5/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:1841
 Symfony\Component\DependencyInjection\Dumper\PhpDumper->dumpValue() at /var/www/tkonnekt_sf5/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:1152
 Symfony\Component\DependencyInjection\Dumper\PhpDumper->addNewInstance() at /var/www/tkonnekt_sf5/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:1841
 Symfony\Component\DependencyInjection\Dumper\PhpDumper->dumpValue() at /var/www/tkonnekt_sf5/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:743
 Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServiceMethodCalls() at /var/www/tkonnekt_sf5/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:1068
 Symfony\Component\DependencyInjection\Dumper\PhpDumper->addInlineService() at /var/www/tkonnekt_sf5/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:923
 Symfony\Component\DependencyInjection\Dumper\PhpDumper->addService() at /var/www/tkonnekt_sf5/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:1086
 Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServices() at /var/www/tkonnekt_sf5/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:223
 Symfony\Component\DependencyInjection\Dumper\PhpDumper->dump() at /var/www/tkonnekt_sf5/vendor/symfony/http-kernel/Kernel.php:733
 Symfony\Component\HttpKernel\Kernel->dumpContainer() at /var/www/tkonnekt_sf5/vendor/symfony/http-kernel/Kernel.php:555
 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /var/www/tkonnekt_sf5/vendor/symfony/http-kernel/Kernel.php:786
 Symfony\Component\HttpKernel\Kernel->preBoot() at /var/www/tkonnekt_sf5/vendor/symfony/http-kernel/Kernel.php:125
 Symfony\Component\HttpKernel\Kernel->boot() at /var/www/tkonnekt_sf5/vendor/symfony/framework-bundle/Console/Application.php:168
 Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() at /var/www/tkonnekt_sf5/vendor/symfony/framework-bundle/Console/Application.php:74
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/tkonnekt_sf5/vendor/symfony/console/Application.php:167
 Symfony\Component\Console\Application->run() at /var/www/tkonnekt_sf5/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:56
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /var/www/tkonnekt_sf5/vendor/autoload_runtime.php:35
 require_once() at /var/www/tkonnekt_sf5/bin/console:11
@Hanmac
Copy link
Contributor Author

Hanmac commented Nov 8, 2021

@core23 as Nucleos Developer, can you point me out what i might did wrong?
outside of setting orm, i didn't even configure something yet

@core23 core23 self-assigned this Nov 8, 2021
@Hanmac
Copy link
Contributor Author

Hanmac commented Nov 8, 2021

Also for some unknown reason when i grep for audit.mananger i get this:

var/cache/dev/App_KernelDevDebugContainerCompiler.log:
Symfony\Component\DependencyInjection\Compiler\InlineServiceDefinitionsPass: Inlined service "sonata.admin.audit.manager" to "twig".

i don't know why its getting inlined to twig? Is that just a faulty log line or is something more wrong there?

@core23
Copy link
Member

core23 commented Nov 8, 2021

@core23 as Nucleos Developer, can you point me out what i might did wrong?
outside of setting orm, i didn't even configure something yet

I wonder why this is related to the nucleos package, because there is nothing audit specific in it. I never used the audit component for any of my projects, so it must be an sonata problem.

@Hanmac
Copy link
Contributor Author

Hanmac commented Nov 9, 2021

@core23 as Nucleos Developer, can you point me out what i might did wrong?
outside of setting orm, i didn't even configure something yet

I wonder why this is related to the nucleos package, because there is nothing audit specific in it. I never used the audit component for any of my projects, so it must be an sonata problem.

it seems the problem is caused when i have something that needs the CRUDController, might be a Admin module or something else. (my current tests doesn't have any admin or different controller yet)

enabling nucleos user admin bundle by/and setting the db_driver: orm causes it to add an admin service or have an extra CRUDController as service. Which seems to have been the easiest way to trigger the problem.

i don't know yet what exactly causes this problem, at first i thought that maybe the bundles might have been in wrong order.

@Hanmac
Copy link
Contributor Author

Hanmac commented Nov 9, 2021

i created a test project to reproduce the problem: https://github.com/Hanmac/sonata_test_case

there is no database connected to it, so it shouldn't be a problem

@Hanmac
Copy link
Contributor Author

Hanmac commented Nov 9, 2021

@core23 because of some reason in the company i needed to do the symfony version 4.4 too.

for this i got a different but similar problem: symfony/symfony#43980

like again the problem can be triggered by just enabling db_driver: orm

i will make a test case for symfony version 4.4 too

@Hanmac
Copy link
Contributor Author

Hanmac commented Nov 12, 2021

this might be fixed by symfony/symfony#44012 i will need to see until its applied into releases for 4.* or 5.*

tested it with 4.* and the patch fixes the problem.

@Hanmac Hanmac closed this as completed Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants