diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93bbe7e4..1901bfab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/pantheon.upstream.yml b/pantheon.upstream.yml index 7c2d1219..337f906e 100644 --- a/pantheon.upstream.yml +++ b/pantheon.upstream.yml @@ -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: diff --git a/upstream-configuration/scripts/ComposerScripts.php b/upstream-configuration/scripts/ComposerScripts.php index bd093bc4..07cb923e 100644 --- a/upstream-configuration/scripts/ComposerScripts.php +++ b/upstream-configuration/scripts/ComposerScripts.php @@ -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("Setting require.php from '$requirePhpVersion' to '>=$pantheonPhpVersion' to conform to pantheon php version."); + $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 @@ -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. */