Skip to content

Composer 2.1 and 2.2 incompatibility #18

@yuriysklyarenko

Description

@yuriysklyarenko

We want to use the plugin on the Magento2 application, which officially supports only composer 2.2 for the fresh versions, however, the plugin throws an exception on composer versions < 2.3:

$ composer integrity

+--------+-------------------------------------------------------------------+-----------+------------------+------------------+------------+---------+
| Status | Package                                                           | Version   | Package ID       | Checksum         | Percentage | Patched |
+--------+-------------------------------------------------------------------+-----------+------------------+------------------+------------+---------+
|   ✓    | 2tvenom/cborencode                                                | 1.0.2     | 5F99DF3AE163D0FC | 7EB6DBC42A758CF7 |    98%     |   No    |
|   ✓    | allure-framework/allure-codeception                               | 1.5.2     | BCAC10B18DEB1505 | BD1D6052672950F5 |    100%    |   No    |
...
|   ✓    | wikimedia/less.php                                                | v3.1.0    | 21EB7FA165C2EF34 | 12455C57A421EF6E |    96%     |   No    |
+--------+-------------------------------------------------------------------+-----------+------------------+------------------+------------+---------+

PHP Fatal error:  Uncaught Error: Undefined constant Symfony\Component\Console\Command\Command::SUCCESS in ..vendor/sansec/composer-integrity-plugin/src/IntegrityCommand.php:77
Stack trace:
#0 phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php(245): Sansec\Integrity\IntegrityCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Sansec\Integrity\ComposerIntegrityCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(327): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(128): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 phar:///usr/local/bin/composer/bin/composer(73): Composer\Console\Application->run()
#7 /usr/local/bin/composer(29): require('phar:///usr/loc...')
#8 {main}
  thrown in ../vendor/sansec/composer-integrity-plugin/src/IntegrityCommand.php on line 77

It works fine on composer 2.3:

$ composer -V
Composer 2.3.0 2022-03-30 11:15:36

However composer 2.2.21 and for example 2.1.14 do not work with the message above (we can see the output but due to non-zero return code it is impossible to use the plugin as a part of CICD process).

I used PHP 8.1.20:

$ php -v
PHP 8.1.20 (cli) (built: Jun  8 2023 19:55:40) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.20, Copyright (c) Zend Technologies
    with Xdebug v3.2.0, Copyright (c) 2002-2022, by Derick Rethans
    with Zend OPcache v8.1.20, Copyright (c), by Zend Technologies

Is it possible to make it compatible with composer 2.1-2.2?
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions