Skip to content

Commit 1504875

Browse files
committed
handle non-symantic version strings
1 parent b7f8193 commit 1504875

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Set default `composer` version to `2.8.1`
55
* Set default `composer` version to `2.2.24` for PHP 5.3-7.2
66
* Set default `composer` version to `1.10.27` for PHP <= 5.2
7+
* Fixed bug causing `composer` 2.2.x to be installed when `composer_version` was set to a single digit version such as `1`
78

89
## v1.6.0 - [October 25, 2024](https://github.com/lando/php/releases/tag/v1.6.0)
910

builders/php.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ const addBuildStep = require('./../utils/add-build-step');
99
/**
1010
* Get the appropriate Composer version based on the PHP version.
1111
* @param {string} phpVersion - The PHP version.
12-
* @return {string} - The Composer version.
12+
* @return {string|boolean} - The Composer version or false if we cannot parse the version.
1313
*/
1414
const getDefaultComposerVersion = phpVersion => {
15-
if (semver.lt(semver.coerce(phpVersion), '5.3.2')) {
15+
phpVersion = semver.coerce(phpVersion);
16+
// Don't set a default composer version if we cannot
17+
// parse the version such as with `custom`.
18+
if (!phpVersion) return false;
19+
20+
if (semver.lt(phpVersion, '5.3.2')) {
1621
// Use Composer 1 for PHP < 5.3.2
1722
return '1';
18-
} else if (semver.lt(semver.coerce(phpVersion), '7.3.0')) {
23+
} else if (semver.lt(phpVersion, '7.3.0')) {
1924
// Use Composer 2.2 LTS for PHP < 7.3
2025
return '2.2.24';
2126
} else {

examples/5.6/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ lando exec defaults -- curl http://localhost/path_info.php/a/b.php | grep SCRIPT
112112
# Should allow cli services to specify a boot up command
113113
lando info -s cliworker --deep | grep Cmd | grep sleep | grep infinity
114114

115-
# Should install the latest composer 2.2.x by default.
116-
lando exec cliworker -- composer --version --no-ansi | tee >(cat 1>&2) | grep -q "Composer version 2.2."
115+
# Should use preinstalled composer 1.x when composer_version is false
116+
lando exec cliworker -- composer --version --no-ansi | tee >(cat 1>&2) | grep -q "Composer version 1."
117117
```
118118

119119
## Destroy tests

0 commit comments

Comments
 (0)