Skip to content

ref: use composer to get installed modules#1900

Merged
Litarnus merged 6 commits into
5.xfrom
modules-integration
Sep 15, 2025
Merged

ref: use composer to get installed modules#1900
Litarnus merged 6 commits into
5.xfrom
modules-integration

Conversation

@Litarnus

@Litarnus Litarnus commented Sep 12, 2025

Copy link
Copy Markdown
Contributor

Retrieves package versions directly from composer, which supports getting pretty versions without needing an extra package. Closes #1897

@Litarnus Litarnus self-assigned this Sep 12, 2025
@Litarnus Litarnus added the 5.0 label Sep 12, 2025
@Litarnus Litarnus linked an issue Sep 15, 2025 that may be closed by this pull request
@Litarnus Litarnus marked this pull request as ready for review September 15, 2025 07:00
@Litarnus Litarnus requested a review from cleptric September 15, 2025 07:00
cursor[bot]

This comment was marked as outdated.

Comment on lines +47 to 51
foreach (InstalledVersions::getInstalledPackages() as $package) {
$version = InstalledVersions::getPrettyVersion($package);
if ($version !== null) {
self::$packages[$package] = $version;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Potential bug: The code directly uses the Composer\InstalledVersions class without a fallback, causing a fatal "Class not found" error on systems running Composer 1.x.
  • Description: The code was updated to use Composer\InstalledVersions, a class only available in Composer 2.0 and later. However, the previous implementation contained explicit fallback logic to support Composer 1.x, which has now been removed. The project's composer.json does not enforce a Composer 2.0 requirement by including "composer-runtime-api": "^2.0". Consequently, on systems still using Composer 1.x, any call to ModulesIntegration::getComposerPackages() will result in a fatal "Class 'Composer\InstalledVersions' not found" error, causing the application to crash during Sentry event processing.

  • Suggested fix: To restore backward compatibility, reintroduce a check like class_exists(InstalledVersions::class) before using the class and provide a fallback for older environments. Alternatively, if dropping Composer 1.x support is intended, add "composer-runtime-api": "^2.0" to the require section of composer.json to prevent installation on incompatible systems.
    severity: 0.85, confidence: 0.98

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to revert these changes

cursor[bot]

This comment was marked as outdated.

Comment thread src/Integration/ModulesIntegration.php
@Litarnus Litarnus merged commit 9ddc68f into 5.x Sep 15, 2025
38 checks passed
@Litarnus Litarnus deleted the modules-integration branch September 15, 2025 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[5.x] Remove jean85/pretty-package-versions

3 participants