ref: use composer to get installed modules#1900
Conversation
| foreach (InstalledVersions::getInstalledPackages() as $package) { | ||
| $version = InstalledVersions::getPrettyVersion($package); | ||
| if ($version !== null) { | ||
| self::$packages[$package] = $version; | ||
| } |
There was a problem hiding this comment.
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'scomposer.jsondoes not enforce a Composer 2.0 requirement by including"composer-runtime-api": "^2.0". Consequently, on systems still using Composer 1.x, any call toModulesIntegration::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 therequiresection ofcomposer.jsonto prevent installation on incompatible systems.
severity: 0.85, confidence: 0.98
Did we get this right? 👍 / 👎 to inform future reviews.
Retrieves package versions directly from composer, which supports getting pretty versions without needing an extra package. Closes #1897