doctrine-extensions / DoctrineExtensions

Doctrine2 behavioral extensions, Translatable, Sluggable, Tree-NestedSet, Timestampable, Loggable, Sortable
MIT License
4.03k stars 1.27k forks source link

Library is not compatible with doctrine/dbal ^4 #2809

Closed ramsey closed 4 months ago

ramsey commented 4 months ago

Environment

Package

show

``` $ composer show --latest gedmo/doctrine-extensions name : gedmo/doctrine-extensions descrip. : Doctrine behavioral extensions keywords : Blameable, behaviors, doctrine, extensions, gedmo, loggable, nestedset, odm, orm, sluggable, sortable, timestampable, translatable, tree, uploadable versions : * v3.14.0 released : 2023-12-03, 5 months ago latest : v3.15.0 released 2024-02-12, 3 months ago type : library license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText homepage : http://gediminasm.org/ source : [git] https://github.com/doctrine-extensions/DoctrineExtensions.git 3b5b5cba476b4ae32a55ef69ef2e59d64d5893cf dist : [zip] https://api.github.com/repos/doctrine-extensions/DoctrineExtensions/zipball/3b5b5cba476b4ae32a55ef69ef2e59d64d5893cf 3b5b5cba476b4ae32a55ef69ef2e59d64d5893cf path : /Users/ramsey/Developer/Repos/ramsey/my-website/vendor/gedmo/doctrine-extensions names : gedmo/doctrine-extensions support email : gediminas.morkevicius@gmail.com issues : https://github.com/doctrine-extensions/DoctrineExtensions/issues source : https://github.com/doctrine-extensions/DoctrineExtensions/tree/v3.14.0 wiki : https://github.com/Atlantic18/DoctrineExtensions/tree/main/doc autoload psr-4 Gedmo\ => src/ requires behat/transliterator ^1.2 doctrine/annotations ^1.13 || ^2.0 doctrine/collections ^1.2 || ^2.0 doctrine/common ^2.13 || ^3.0 doctrine/event-manager ^1.2 || ^2.0 doctrine/persistence ^2.2 || ^3.0 php ^7.4 || ^8.0 psr/cache ^1 || ^2 || ^3 symfony/cache ^5.4 || ^6.0 || ^7.0 symfony/deprecation-contracts ^2.1 || ^3.0 requires (dev) doctrine/cache ^1.11 || ^2.0 doctrine/dbal ^3.2 doctrine/doctrine-bundle ^2.3 doctrine/mongodb-odm ^2.3 doctrine/orm ^2.14.0 friendsofphp/php-cs-fixer ^3.14.0 nesbot/carbon ^2.71 || 3.x-dev as 3.0 phpstan/phpstan ^1.10.2 phpstan/phpstan-doctrine ^1.0 phpstan/phpstan-phpunit ^1.0 phpunit/phpunit ^9.6 rector/rector ^0.18 symfony/console ^5.4 || ^6.0 || ^7.0 symfony/phpunit-bridge ^6.0 || ^7.0 symfony/yaml ^5.4 || ^6.0 || ^7.0 suggests doctrine/mongodb-odm to use the extensions with the MongoDB ODM doctrine/orm to use the extensions with the ORM conflicts doctrine/dbal <3.2 doctrine/mongodb-odm <2.3 doctrine/orm <2.14.0 || 2.16.0 || 2.16.1 sebastian/comparator <2.0 ```

Doctrine packages

show

``` $ composer show --latest 'doctrine/*' Color legend: - patch or minor release available - update recommended - major release available - update possible - up to date version Direct dependencies required in composer.json: doctrine/dbal 4.0.2 4.0.2 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management. doctrine/doctrine-bundle 2.12.0 2.12.0 Symfony DoctrineBundle doctrine/doctrine-migrations-bundle 3.3.1 3.3.1 Symfony DoctrineMigrationsBundle doctrine/orm 3.2.0 3.2.0 Object-Relational-Mapper for PHP Transitive dependencies not required in composer.json: doctrine/annotations 2.0.1 2.0.1 Docblock Annotations Parser doctrine/cache 2.2.0 2.2.0 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others. doctrine/collections 2.2.2 2.2.2 PHP Doctrine Collections library that adds additional functionality on top of PHP arrays. doctrine/common 3.4.4 3.4.4 PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, proxies and much more. doctrine/deprecations 1.1.3 1.1.3 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages. doctrine/event-manager 2.0.1 2.0.1 The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects. doctrine/inflector 2.0.10 2.0.10 PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words. doctrine/instantiator 2.0.0 2.0.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors doctrine/lexer 3.0.1 3.0.1 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers. doctrine/migrations 3.7.4 3.7.4 PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very ea... doctrine/persistence 3.3.2 3.3.2 The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share. doctrine/sql-formatter 1.4.0 1.4.0 a PHP SQL highlighting library ```

PHP version

$ php -v
PHP 8.3.4 (cli) (built: Mar 16 2024 22:18:14) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.4, Copyright (c), by Zend Technologies
    with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans

Subject

While attempting to use gedmo/doctrine-extensions in a project, specifically for Timestampable, I encountered an error that revealed gedmo/doctrine-extensions depends on doctrine/dbal but does not declare it in require in composer.json (it is only declared in require-dev for version ^3.2).

My project uses doctrine/dbal ^4, which defines Doctrine\DBAL\Driver::getDatabasePlatform() as requiring one argument: Doctrine\DBAL\ServerVersionProvider $versionProvider (see the source code for v4.0.2 here).

gedmo/doctrine-extensions calls this method in the following classes but does not provide an argument:

Minimal repository with the bug

n/a

Steps to reproduce

If necessary, I can create a separate repository to reproduce this bug and show it working. However, I'm not sure that's needed, since I'm able to point out what's causing the bug.

The bug is caused by use of doctrine/dbal version 4 with gedmo/doctrine-extensions version 3 and is the result of a changed interface between versions 3 and 4 of doctrine/dbal.

Expected results

gedmo/doctrine-extensions should disallow installation with doctrine/dbal version 4.

In other words, gedmo/doctrine-extensions should move "doctrine/dbal": "^3.2" from require-dev to require in its composer.json.

Alternately, gedmo/doctrine-extensions should update its code to work with both versions of doctrine/dbal, but in either case, doctrine/dbal should be promoted to the require list for the package (instead of remaining in require-dev).

Actual results

When responding to a Doctrine event:

Too few arguments to function Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware::getDatabasePlatform(), 0 pa  
  ssed in /path/to/my-website/vendor/gedmo/doctrine-extensions/src/Timestampable/Mapping/  
  Event/Adapter/ORM.php on line 33 and exactly 1 expected     
greg0ire commented 4 months ago

it is only declared in require-dev for version ^3.2

It is also defined in conflict: https://github.com/doctrine-extensions/DoctrineExtensions/blob/8d658b4d22977e3b72f02bfe4e68b2df0ba586aa/composer.json#L74, which is a common pattern to define constraints for optional dependencies.

However, in your first copy / paste, we can see :thinking:

conflicts
doctrine/dbal <3.2
doctrine/mongodb-odm <2.3
doctrine/orm <2.14.0 || 2.16.0 || 2.16.1
sebastian/comparator <2.0

The bug can be reproduced with composer require doctrine/dbal gedmo/doctrine-extensions, but I can't help but notice how both you and me ended up with 3.14. I think the bug is already fixed and that you won't be able to install 3.15 and dbal 4.

greg0ire commented 4 months ago

Fixed by https://github.com/doctrine-extensions/DoctrineExtensions/pull/2759

ramsey commented 4 months ago

Oh, I see. v3.14 doesn't have that conflict definition: https://github.com/doctrine-extensions/DoctrineExtensions/blob/3b5b5cba476b4ae32a55ef69ef2e59d64d5893cf/composer.json#L72

So, since v3.15 defines >=4.0 as being in conflict, Composer chooses to use v3.14 because it has no conflict.

I don't think there's a way to fix this without deleting the v3.14.0 tag and creating it again with the conflict corrected in composer.json, which I wouldn't recommend.

Closing, since I don't think there's anything you can do. In the meantime, I've removed gedmo/doctrine-extensions. I'll reinstall it when there's a version that will work with doctrine/dbal version 4. 😃

mbabker commented 4 months ago

I'll reinstall it when there's a version that will work with doctrine/dbal version 4. 😃

Yeah, unfortunately, there is a lot of legacy stuff that either wasn't cleaned up fast enough (not having high version conflicts on the ORM and DBAL long before the new major versions were released) or has user data-related changes (https://github.com/doctrine-extensions/DoctrineExtensions/issues/2502) which is going to make that a longer process to see through 😅