Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility with composer v2.4+ #6503

Merged

Conversation

stefangr
Copy link
Contributor

When running the dependabot-script with DEBUG_HELPERS=true I saw this error:

PHP Deprecated:  Installer::setIgnorePlatformRequirements is deprecated since Composer 2.2, use setPlatformRequirementFilter instead. in /opt/composer/v2/vendor/composer/composer/src/Composer/Installer.php on line 1289

In this PR I work around the deprecations (there was one more, which was not verbose) and also added a forward compatible change to disable the audit.

Applied changes:

@stefangr stefangr requested a review from a team as a code owner January 23, 2023 21:20
Copy link
Member

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh perfect timing, I was planning to work on #5720 / #6385 / #6385 (comment) later this week!

I suspect life is simpler if we just keep on the latest composer and don't worry about backwards compatibility for options... I assume most folks run dependabot within the context of our bundled dependabot-core image, so they'll be using whatever version of composer is bundled with that. If you think differently for some reason, please let me know.

For simplicity of working across timezones / PR rebases, does the following sound reasonable?

  1. Merge this
  2. Rebase the Dependabot PR to bump composer to 2.5.x
  3. Add a commit remove the optional checks, such that setAudit is always called.
  4. Merge... so hopefully we'll be back up to composer latest by EOD 👍

// For all potential options, see UpdateCommand in composer
$install
->setUpdate(true)
->setInstall(false)
->setDevMode(true)
->setUpdateAllowTransitiveDependencies(Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS)
->setDumpAutoloader(false)
->setRunScripts(false)
->setIgnorePlatformRequirements(false);
->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList(false));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍 for fixing this, as a non-PHP expert, I would have muddled for a while before realizing it needed another import...

- Use `eventDispatcher::setRunScripts` instead of deprecated `Installer::setRunScripts`
- Use `Installer::setPlatformRequirementFilter` instead of deprecated `Installer::setIgnorePlatformRequirements`
- Use `setAudit(false)` if Installer has that method
@jeffwidman jeffwidman force-pushed the add-compatibility-with-composer-v2.4-v2.5 branch from 83376ae to 5b89b08 Compare January 23, 2023 22:02
@jeffwidman jeffwidman enabled auto-merge (squash) January 23, 2023 22:03
@jeffwidman jeffwidman enabled auto-merge (squash) January 23, 2023 22:06
@jeffwidman jeffwidman merged commit b6bc363 into dependabot:main Jan 23, 2023
@stefangr
Copy link
Contributor Author

For simplicity of working across timezones / PR rebases, does the following sound reasonable?

1. Merge this

2. Rebase the Dependabot PR to bump `composer` to `2.5.x`

3. Add a commit remove the optional checks, such that `setAudit` is always called.

4. Merge... so hopefully we'll be back up to `composer` `latest` by EOD +1

That sounds completely reasonable. 👍

@stefangr stefangr deleted the add-compatibility-with-composer-v2.4-v2.5 branch January 24, 2023 07:38
alcere pushed a commit that referenced this pull request Feb 20, 2023
When running the dependabot-script with `DEBUG_HELPERS=true` I saw this error:
```
PHP Deprecated:  Installer::setIgnorePlatformRequirements is deprecated since Composer 2.2, use setPlatformRequirementFilter instead. in /opt/composer/v2/vendor/composer/composer/src/Composer/Installer.php on line 1289
```

So this commit resolves the deprecations and also added a forward compatible change to [disable the audit](#6385 (comment)).

Applied changes:
- Use `eventDispatcher::setRunScripts` instead of [deprecated `Installer::setRunScripts`](https://github.com/composer/composer/blob/2.5.1/src/Composer/Installer.php#L1241)
- Use `Installer::setPlatformRequirementFilter` instead of [deprecated `Installer::setIgnorePlatformRequirements`](https://github.com/composer/composer/blob/2.5.1/src/Composer/Installer.php#L1297)
- Use `setAudit(false)` if Installer has that method

Co-authored-by: Stefan Grootscholten <stefan.grootscholten@tripolis.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants