Problem/Motivation

The recent update to PHP 8.1.5 has caused ComposerHooksTest to break on 10.0.x because also included is an update to the local Composer exectuable.

Steps to reproduce

Locally update your composer to the latest version
Run ./vendor/bin/phpunit -v core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php --filter testComposerHooks

Proposed resolution

Change fixtures/drupal-assets-fixture:dev-master to fixtures/drupal-assets-fixture:dev-main in ComposerHookTest.php.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott created an issue. See original summary.

alexpott’s picture

The attached patch fixes this on composer 2.3.6 and also it is not broken on 2.3.2 - I think this was broken by the changes to 2.3.3 - see https://github.com/composer/composer/blob/main/CHANGELOG.md

Yep - if I run head with composer 2.3.2 it passes but with 2.3.3 it fails. Patch attached passes on both.

bircher’s picture

Status: Needs review » Reviewed & tested by the community

I think our tests would also be broken with composer 2.2.11 since the alias has also been removed there.

alexpott’s picture

https://dispatcher.drupalci.org/job/drupal8_core_regression_tests/56336/... shows that head is broken - so we need to land this ASAP.

alexpott’s picture

I suspect we have the same issue on PHP 8.1 on 9.4.x and 9.5.x. Also I think this should be backported to 9.3.x in case of a security release.

  • catch committed 77702ce on 10.0.x
    Issue #3283795 by alexpott, bircher: ComposerHooksTest is broken on...
  • catch committed 5cd00fc on 9.4.x
    Issue #3283795 by alexpott, bircher: ComposerHooksTest is broken on...
  • catch committed 2ebeaa5 on 9.5.x
    Issue #3283795 by alexpott, bircher: ComposerHooksTest is broken on...
catch’s picture

Version: 10.0.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
Issue tags: +Needs release manager review

Committed/pushed to 10.0.x, cherry-picked to 9.5.x and 9.4.x

Leaving this patch to be ported for 9.3.x and tagging needs release manager review - because we always branch off the tag for security releases, committing to 9.3.x doesn't automatically help, but maybe we can tag an extra release or combine this change with the first security release... or something.

benjifisher’s picture

Issue summary: View changes

Here are the results from https://www.drupal.org/pift-ci-job/2395338:

Testing Drupal\Tests\Composer\Plugin\Scaffold\Functional\ComposerHookTest
E.                                                                  2 / 2 (100%)

Time: 00:03.128, Memory: 4.00 MB

There was 1 error:

1) Drupal\Tests\Composer\Plugin\Scaffold\Functional\ComposerHookTest::testComposerHooks
RuntimeException: Exit code: 2

For additional security you should declare the allow-plugins config with a list of packages names that are allowed to run code. See https://getcomposer.org/allow-plugins
You have until July 2022 to add the setting. Composer will then switch the default behavior to disallow all plugins.
./composer.json has been updated
Running composer update fixtures/drupal-assets-fixture fixtures/scaffold-override-fixture
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires fixtures/drupal-assets-fixture dev-master, found fixtures/drupal-assets-fixture[dev-main] but it does not match the constraint. Perhaps dev-master was renamed to dev-main?
  Problem 2
    - Root composer.json requires fixtures/scaffold-override-fixture dev-master, found fixtures/scaffold-override-fixture[dev-main] but it does not match the constraint. Perhaps dev-master was renamed to dev-main?
  Problem 3
    - Root composer.json requires fixtures/drupal-core-fixture * -> satisfiable by fixtures/drupal-core-fixture[dev-main].
    - fixtures/drupal-core-fixture dev-main requires fixtures/drupal-assets-fixture * -> found fixtures/drupal-assets-fixture[dev-main] but it conflicts with your root composer.json require (dev-master).

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

It looks as though the problem is a result of renaming master to main ... in the fixtures? The patch in #2 updates the test to use main, which seems like the right fix.

I do not see how this relates to the composer or PHP version. Did composer previously guess at this renaming or is the composer version a red herring? I get the same results (with and without the patch) locally with composer 2.3.5 and PHP 8.1.5.

+1 for RTBC, although I still have questions.

alexpott’s picture

@benjifisher

I get the same results (with and without the patch) locally with composer 2.3.5 and PHP 8.1.5.

Are you absolutely sure about that? I don't get the same results at all. On 94b5d57502 (the commit prior to the fix) with the latest composer (2.3.6) running ./vendor/bin/phpunit -v core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php --filter testComposerHooks fails and on HEAD 10.0.x it does not.

This fail was caused by updating the DrupalCI PHP 8.1 container... that resulted in composer that is part of the build being updated. If you run the test on 94b5d57502 with composer 2.3.2 it will pass. The breaking change occurs in 2.3.3.

benjifisher’s picture

@alexpott:

I think I was ambiguous:

I get the same results (with and without the patch) locally with composer 2.3.5 and PHP 8.1.5.

What I meant was:

  • With the patch, I get the same results locally (with composer 2.3.5 and PHP 8.1.5) as the testbot.
  • Without the patch, I get the same results locally (with composer 2.3.5 and PHP 8.1.5) as the testbot.

All good?

benjifisher’s picture

Just for fun (since DDev makes it so easy) I installed composer 2.3.2 and confirmed that the test passes with 94b5d57502.

Earlier, I looked at the link in #2, but I missed that it was a change introduced in 2.3.3. I assume it is this one:

Removed dev-master=>dev-main alias from #10372 as it does not work when reloading from lock file and extracting dev deps (#10651)

  • catch committed 44f5b27 on 9.3.x
    Issue #3283795 by alexpott, bircher: ComposerHooksTest is broken on...
catch’s picture

Status: Patch (to be ported) » Fixed
Issue tags: -Needs release manager review

Discussed the @xjm, last time we left the commit on the dev branch and included it in the release, so normal backporting is useful after all. Cherry-picked to 9.3.x too.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.