KnpLabs / KnpMenuBundle

Object Oriented menus for your Symfony project.
http://knplabs.com
MIT License
1.4k stars 203 forks source link

Circular reference issue makes composer install fail #366

Closed compains closed 6 years ago

compains commented 6 years ago

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.26.0 3.27.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.7.0  3.7.0  Symfony SonataBlockBundle
sonata-project/cache                     1.0.7  1.0.7  Cache library
sonata-project/core-bundle               3.6.0  3.7.0  Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.3.0  2.3.0  Symfony SonataDatagridBundle
sonata-project/doctrine-orm-admin-bundle 3.1.7  3.1.7  Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  1.7.1  1.7.1  Lightweight Exporter library
sonata-project/formatter-bundle          3.2.3  3.2.3  Symfony SonataFormatterBundle

Symfony packages

$ composer show --latest 'symfony/*'
symfony/assetic-bundle     v2.6.1  v2.8.2  Integrates Assetic into Symfony2
symfony/monolog-bundle     v2.3.0  v3.1.2  Symfony MonologBundle
symfony/polyfill-apcu      v1.6.0  v1.6.0  Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu  v1.6.0  v1.6.0  Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.6.0  v1.6.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php54     v1.6.0  v1.6.0  Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55     v1.6.0  v1.6.0  Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/polyfill-php56     v1.6.0  v1.6.0  Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.6.0  v1.6.0  Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.6.0  v1.6.0  Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.0  v3.0.0  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.3.12 v3.1.6  Symfony SwiftmailerBundle
symfony/symfony            v2.8.13 v3.3.13 The Symfony PHP framework

PHP version

$ php -v
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

Subject

Steps to reproduce

Run composer install

Expected results

Normal install process

Actual results

Circular reference detected for service "knp_menu.matcher", path: "knp_menu.matcher -> sonata.admin.menu.matcher.voter.children -> knp_menu.matcher".

Quick workarroud

Intsall "knplabs/knp-menu-bundle": "2.1.3" even when I not use that bundle. So it seems it could be a knp-menu-bundle issue

This issue is a copy of this one as I'm not sure about the real cause of it.

stof commented 6 years ago

It looks like SonataAdminBundle injects the matcher inside the voter, thus creating a circular reference. The fact that it was working in 2.1.3 was pure luck (there was still a circular reference, but as it was involving setters and not constructors, it was working).

The good news is that sonata.admin.menu.matcher.voter.children should actually not exist for their need, and https://github.com/sonata-project/SonataAdminBundle/pull/4639 is refactoring the code dealing with it, which would fix the issue.

The workaround in the meantime is to stay on the 2.1 version of the bundle.

stof commented 6 years ago

Note that projects using Symfony 3.3+ should not be affected by this issue btw, due to the lazy-loading of voters.

stof commented 6 years ago

Issue was fixed by https://github.com/sonata-project/SonataAdminBundle/pull/4806 (not released yet, but merged in the dev version), so I'm closing this issue).