Skip to content

Commit

Permalink
Bump PHP version to 8.2 and DB version to 10.6 (#133)
Browse files Browse the repository at this point in the history
* bump php version to 8.2

* bump db version to 10.6

* update the required PHP version in the composer file to 8.1 at minimum
8.1 is the minimum required version for Bedrock.

* drop the php 8.0 tests
since we're requiring a higher version now

* roll back to php 8.0 for composer.json to avoid conflicts

* update require.php to pantheon.yml version

* only update the require PHP version if it's < 8.1
the minimum required by bedrock is 8.1
  • Loading branch information
jazzsequence authored Jun 27, 2024
1 parent 40f32a8 commit 74d44cf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.0', '8.1', '8.2', '8.3']
php-version: ['8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions pantheon.upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ api_version: 1
web_docroot: true
# See https://pantheon.io/docs/pantheon-yml/#enforce-https--hsts for valid values.
enforce_https: transitional
php_version: 8.1
php_version: 8.2
database:
version: 10.4
version: 10.6
build_step: true
filemount: /app/uploads
protected_web_paths:
Expand Down
23 changes: 23 additions & 0 deletions upstream-configuration/scripts/ComposerScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ public static function applyComposerJsonUpdates(Event $event)
$composerJson['config']['platform']['php'] = $updatedPlatformPhpVersion;
}

// Check to see if the PHP version in the require section of composer.json matches the pantheon.yml PHP version.
// If it does not, update it to match the PHP version defined in pantheon.yml.
$requirePhpVersion = static::getCurrentRequirePhp($composerJson);
if ($requirePhpVersion && false === stripos($requirePhpVersion, $pantheonPhpVersion)) {
$strippedRequirePhpVersion = str_replace( '>=', '', $requirePhpVersion);
if (version_compare($strippedRequirePhpVersion, '8.1', '<')) {
$io->write("<info>Setting require.php from '$requirePhpVersion' to '>=$pantheonPhpVersion' to conform to pantheon php version.</info>");
$composerJson['require']['php'] = ">=$pantheonPhpVersion";
}
}

// add our post-update-cmd hook if it's not already present
$our_hook = 'WordPressComposerManaged\\ComposerScripts::postUpdate';
// if does not exist, add as an empty arry
Expand Down Expand Up @@ -123,6 +134,18 @@ public static function jsonEncodePretty(array $data)
return $prettyContents;
}

/**
* Get the current require.php value.
*/
private static function getCurrentRequirePhp($composerJson)
{
$require = $composerJson['require'];
if (isset($require['php'])) {
return $require['php'];
}
return null;
}

/**
* Get current platform.php value.
*/
Expand Down

0 comments on commit 74d44cf

Please sign in to comment.