-
-
Notifications
You must be signed in to change notification settings - Fork 26
fix: warn and fallback for unsupported PHP versions #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9441473
5a169ae
204a5d1
09067ea
7ba970e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -214,13 +214,17 @@ exports.getPantheonCache = { | |
| * @param {string[]} [files=['pantheon.upstream.yml', 'pantheon.yml']] - YAML files to process | ||
| * @return {Object} Merged configuration object | ||
| */ | ||
| // PHP versions that have generation 5 images on Docker Hub | ||
| const SUPPORTED_PHP_VERSIONS = ['8.0', '8.1', '8.2', '8.3', '8.4']; | ||
| const DEFAULT_PHP_VERSION = '8.3'; | ||
|
|
||
| exports.getPantheonConfig = (files = ['pantheon.upstream.yml', 'pantheon.yml']) => _(files) | ||
| .filter(file => fs.existsSync(file)) | ||
| .map(file => yaml.load(fs.readFileSync(file))) | ||
| .thru(data => _.merge({}, ...data)) | ||
| .thru(data => { | ||
| // Set the php version | ||
| data.php = _.toString(_.get(data, 'php_version', '8.3')); | ||
| data.php = _.toString(_.get(data, 'php_version', DEFAULT_PHP_VERSION)); | ||
| // Set the webroot | ||
| data.webroot = (_.get(data, 'web_docroot', false)) ? 'web' : '.'; | ||
| // Set the drush version | ||
|
|
@@ -230,6 +234,15 @@ exports.getPantheonConfig = (files = ['pantheon.upstream.yml', 'pantheon.yml']) | |
| // @DEPRECATED: Pantheon php_runtime_generation: 1 is deprecated and will be removed April 2026. | ||
| const phpRuntimeGen = _.get(data, 'php_runtime_generation', 2); | ||
| data.generation = phpRuntimeGen === 1 ? '4' : '5'; | ||
| // Warn and fall back to generation 4 if the configured PHP version has no generation 5 image | ||
| if (data.generation === '5' && !SUPPORTED_PHP_VERSIONS.includes(data.php)) { | ||
| console.warn([ | ||
| `\n⚠️ WARNING: PHP ${data.php} does not have a generation 5 image.`, | ||
| ` Falling back to the generation 4 image (devwithlando/pantheon-appserver:${data.php}-4).`, | ||
| ` Consider updating php_version in your pantheon.yml to a supported version: ${SUPPORTED_PHP_VERSIONS.join(', ')}\n`, | ||
| ].join('\n')); | ||
| data.generation = '4'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fallback to generation 4 instead of PHP 8.3 failsHigh Severity When an unsupported PHP version (e.g. 7.1) is detected with generation 5, the code falls back to generation 4 while keeping the old PHP version. However, generation 4 images likely don't exist on Docker Hub either, so the user would still get a Additional Locations (1) |
||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. YAML-parsed PHP 8.0 incorrectly flagged as unsupportedHigh Severity When |
||
| // Set the tika version if specified in pantheon.yml | ||
| const tikaVersion = _.get(data, 'tika_version'); | ||
| if (tikaVersion !== undefined) { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated PHP version lists risk going out of sync
Medium Severity
The supported PHP version list is hardcoded identically in both
SUPPORTED_PHP_VERSIONS_GEN5inbuilders/pantheon-php.jsandSUPPORTED_PHP_VERSIONSinlib/utils.js. Sinceutilsis already imported in the builder file, exporting the constant fromutilsand reusing it would prevent the two lists from drifting apart when a new PHP version is added.Additional Locations (1)
lib/utils.js#L217-L218