Fix handling PHP version from Jetpack backup meta file - #1024
Merged
Conversation
ivan-ottinger
approved these changes
Mar 7, 2025
ivan-ottinger
left a comment
Contributor
There was a problem hiding this comment.
The proposed changes look great.
- I couldn't reproduce the https://github.com/Automattic/dotcom-forge/issues/10577 issue anymore.
- The Jetpack imports are working correctly - setting the PHP version as expected (based on value in
meta.json). If the PHP version is not supported, Studio uses the default PHP version.
Thank you for including helpful testing instructions. It made it easier to test.
Comment on lines
+210
to
+222
| protected parsePhpVersion( version: string | undefined ): string { | ||
| if ( ! version ) { | ||
| return DEFAULT_PHP_VERSION; | ||
| } | ||
| const phpVersion = semver.coerce( version ); | ||
| if ( ! phpVersion ) { | ||
| return DEFAULT_PHP_VERSION; | ||
| } | ||
|
|
||
| const parsedVersion = `${ phpVersion.major }.${ phpVersion.minor }`; | ||
|
|
||
| return SupportedPHPVersionsList.includes( parsedVersion ) ? parsedVersion : DEFAULT_PHP_VERSION; | ||
| } |
Contributor
There was a problem hiding this comment.
I appreciate moving out the logic into parsePhpVersion. 👌🏼
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
Proposed Changes
Recently, Jetpack Backup files started including correct
meta.json. It looks like Studio doesn't validate the PHP version correctly, so user who imports such site gets an error.I propose to add PHP version detection support for Jetpack backups. When importing a Jetpack backup, Studio will now properly detect and use the PHP version from the backup's
meta.jsonfile, falling back to the default PHP version if the detected version is not supported.Changes
Testing Instructions
You can find a sample meta.json structure in a Jetpack backup:
Pre-merge Checklist