Skip to content

Commit 3e51107

Browse files
Merge pull request #68 from creative-commoners/pulls/1.9/phpversions
FIX Update phpversions
2 parents e38a142 + 32e2b6d commit 3e51107

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

consts.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
'8.1',
2828
'8.2',
2929
],
30+
'5.1' => [
31+
'8.1',
32+
'8.2',
33+
],
3034
'5' => [
3135
'8.1',
3236
'8.2',
@@ -59,6 +63,17 @@
5963
'recipe-blog',
6064
];
6165

66+
// lockstepped repos that are "three less" e.g. silverstripe/admin 1 is for CMS 4
67+
const LOCKSTEPPED_REPOS_VERSION_IS_THREE_LESS = [
68+
'silverstripe-admin',
69+
'silverstripe-asset-admin',
70+
'silverstripe-assets',
71+
'silverstripe-campaign-admin',
72+
'silverstripe-errorpage',
73+
'silverstripe-versioned',
74+
'silverstripe-versioned-admin',
75+
];
76+
6277
// Repositories that do not require silverstripe/installer to be explicitly added as a dependency for testing
6378
const NO_INSTALLER_LOCKSTEPPED_REPOS = [
6479
// these are/include recipe-cms or recipe-core, so we don't want to composer require installer

job_creator.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,25 @@ public function getInstallerVersion(): string
5656
}
5757
}
5858
}
59+
// has a lockstepped .x-dev requirement in composer.json
60+
if (file_exists($this->composerJsonPath)) {
61+
$json = json_decode(file_get_contents($this->composerJsonPath));
62+
foreach (LOCKSTEPPED_REPOS as $lockedSteppedRepo) {
63+
$composerRepo = 'silverstripe/' . str_replace('silverstripe-', '', $lockedSteppedRepo);
64+
if (isset($json->require->{$composerRepo})) {
65+
$version = $json->require->{$composerRepo};
66+
if (preg_match('#^([0-9\.]+)\.x\-dev$#', $version, $matches)) {
67+
$versionNumber = $matches[1];
68+
// If the lockstepped dependency is "three less" (e.g. silverstripe/admin is 3 major
69+
// versions behind silverstripe/installer), account for that here.
70+
if (in_array($lockedSteppedRepo, LOCKSTEPPED_REPOS_VERSION_IS_THREE_LESS)) {
71+
$versionNumber += 3;
72+
}
73+
return $versionNumber . '.x-dev';
74+
}
75+
}
76+
}
77+
}
5978
// fallback to use the next-minor or latest-minor version of installer
6079
$installerVersions = array_keys(INSTALLER_TO_PHP_VERSIONS);
6180
$installerVersions = array_filter($installerVersions, fn($version) => substr($version, 0, 1) === $cmsMajor);

tests/JobCreatorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,11 @@ public function provideGetInstallerVersionCMS5FromComposer(): array
673673
['myaccount/silverstripe-framework', '5', [], '5.x-dev'],
674674
['myaccount/silverstripe-framework', '5.10', [], '5.10.x-dev'],
675675
// fallback to looking at deps in composer.json, use current minor of installer .x-dev
676-
['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '5.x-dev'], '5.0.x-dev'],
676+
['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '5.x-dev'], '5.x-dev'],
677677
['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '5.0.x-dev'], '5.0.x-dev'],
678-
['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '^5'], '5.0.x-dev'],
679-
['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/cms' => '^5'], '5.0.x-dev'],
680-
['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/admin' => '^2'], '5.0.x-dev'],
678+
['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '^5'], '5.1.x-dev'],
679+
['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/cms' => '^5'], '5.1.x-dev'],
680+
['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/admin' => '^2'], '5.1.x-dev'],
681681
['myaccount/silverstripe-somemodule', '3', ['silverstripe/framework' => '^5'], '5.x-dev'],
682682
];
683683
}

0 commit comments

Comments
 (0)