symfony-cmf / block-bundle

Extends the SonataBlockBundle to integrate with PHPCR ODM
https://cmf.symfony.com
20 stars 51 forks source link

Dependencies resolving to an incompatible set (out of sync interfaces) #301

Closed fabriciojs closed 5 years ago

fabriciojs commented 5 years ago

Environment

Upgrading a CMF application from Symfony 2.8 top 3.4.

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle                3.45.2 3.45.2 The missing Symfony Admin Generator
sonata-project/block-bundle                3.14.0 3.15.0 Symfony SonataBlockBundle
sonata-project/cache                       2.0.1  2.0.1  Cache library
sonata-project/cache-bundle                3.0.1  3.0.1  This bundle provides caching services
sonata-project/core-bundle                 3.16.1 3.16.1 Symfony SonataCoreBundle
sonata-project/datagrid-bundle             2.4.0  2.4.0  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions         1.1.5  1.1.5  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle   3.8.3  3.8.3  Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/doctrine-phpcr-admin-bundle 2.2.0  2.2.0  Symfony Sonata / Integrate Doctrine PHPCR into the SonataAdminBundle
sonata-project/exporter                    2.0.1  2.0.1  Lightweight Exporter library
sonata-project/formatter-bundle            4.1.2  4.1.2  Symfony SonataFormatterBundle
sonata-project/jquery-bundle               1.10.2 1.10.2 Symfony SonatajQueryBundle
Package sonata-project/jquery-bundle is abandoned, you should avoid using it. No replacement was suggested.
sonata-project/seo-bundle                  2.7.0  2.7.0  Symfony SonataSeoBundle

Symfony packages

$ composer show --latest 'symfony/*'
symfony/assetic-bundle     v2.8.2  v2.8.2  Integrates Assetic into Symfony2
Package symfony/assetic-bundle is abandoned, you should avoid using it. Use symfony/webpack-encore-pack instead.
symfony/monolog-bundle     v3.3.1  v3.3.1  Symfony MonologBundle
symfony/phpunit-bridge     v3.4.22 v4.2.4  Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.10.0 v1.10.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-ctype     v1.10.0 v1.10.0 Symfony polyfill for ctype functions
symfony/polyfill-intl-icu  v1.10.0 v1.10.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.10.0 v1.10.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.10.0 v1.10.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.10.0 v1.10.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.10.0 v1.10.0 Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.1  v3.0.1  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.7  v3.2.5  Symfony SwiftmailerBundle
symfony/symfony            v3.4.22 v4.2.4  The Symfony PHP framework

PHP version

$ php -v
PHP 7.2.14-1+ubuntu16.04.1+deb.sury.org+1

Subject

With the given set of dependencies properly installed via composer, I get a mismatch on the Sonata\Cache\CacheAdapterInterface interface - which does not belong to this project, but the dependencies resolution allowed it to be installed along, which I believe should be fixed upon this bug report.

Steps to reproduce

Installing a Symfony 3.4 application and requesting all the packages listed above, ended up with a mismatch on the sonata/cache package version that added a BC by changing such interface.

Expected results

Should either install a locked/earlier version, or just conflict and say that it cannot install due to conflicting versions.

Actual results

$ php bin/console debug:container -vvv
PHP Fatal error:  Declaration of Symfony\Cmf\Bundle\BlockBundle\Cache\BlockJsCache::get(array $keys) must be compatible with Sonata\Cache\CacheAdapterInterface::get(array $keys
): Sonata\Cache\CacheElementInterface in /var/www/sms_new_site/current/vendor/symfony-cmf/block-bundle/src/Cache/BlockJsCache.php on line 26

In BlockJsCache.php line 26:

  [Symfony\Component\Debug\Exception\FatalErrorException]                                                                                                                      
  Compile Error: Declaration of Symfony\Cmf\Bundle\BlockBundle\Cache\BlockJsCache::get(array $keys) must be compatible with Sonata\Cache\CacheAdapterInterface::get(array $ke  
  ys): Sonata\Cache\CacheElementInterface                                                                                                                                      
fabriciojs commented 5 years ago

This is the same issue here https://github.com/symfony-cmf/block-bundle/issues/289 .

@dbu said:

could you do a pull request to add a conflicts section for cache >2.99 that we can put into 2.1? and if you have the time, prepare a pull request to upgrade the cacheintegration to sonata 3?

I will try providing such PRs today. Looking at https://github.com/symfony-cmf/block-bundle/blob/2.x/src/Cache/BlockJsCache.php on branch 2.x I see it still does not comply with the new interface (missing the type hints). I believe the target branch should be that one, then when merged could generate release 2.2?

Let me know if I should go anyway differently about this. Thanks!

ElectricMaxxx commented 5 years ago

Yes that is is an issue. But the issue was in one our two minor versions of sonata-project/block-bundle, where they introduced BC breaks instead of the deprecation notices. If you want to get a really save sonata version you should use block-bundle from ^3.15.0, cause there also a strictness fix is included.

So how to solve:

either move the broken versions (3.12 and 3.13 from my POV) to your own conflicts or we should do it on block-bundle and release a patch. I also prepare a new minor version, where I dropped all smaler block-bundle-versions: #298

And the caching thing is an other issue. There i would recommend to move "sonata-project/cache": "<1.1.1" into conflicts and require "sonata-project/cache-bundle": "2.4.*". The 3.x versions there are not compatible atm. The got the BC-Breaks you currently see.

fabriciojs commented 5 years ago

@ElectricMaxxx thanks for the quick response!

I have managed it to work with the suggested requirement changes:

-        "sonata-project/cache-bundle": "^3.0",
+        "sonata-project/block-bundle": "^3.15.0",
+        "sonata-project/cache": "^1.0",
+        "sonata-project/cache-bundle": "2.4.*",

Thanks a lot!

A thought though: should the block-bundle error out and not install, due to the known mismatched versions? By changing the conflict section as suggested by David a while back like:

image