-
Notifications
You must be signed in to change notification settings - Fork 20
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
Pick right PHP version for sites created before introducing the PHP selector #262
Conversation
We ensure when loading sites from user data that the PHP version will be populated.
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.
The code change looks clear and the feature works as expected.
type RecursivePartial< T > = { | ||
[ P in keyof T ]?: T[ P ] extends ( infer U )[] | ||
? RecursivePartial< U >[] | ||
: T[ P ] extends object | undefined | ||
? RecursivePartial< T[ P ] > | ||
: T[ P ]; | ||
}; |
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.
@fluiddot alright, I'm going to "bite." 😄 What is this doing and why is it necessary? 😆
Joking aside, I'd love to understand this logic. It's a bit cryptic to me. Would you be willing to share any insight you have? Thanks! 🙇🏻
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.
@dcalhoun I'm glad you asked about this 😃 .
This type is basically an extension of Partial's TypeScript utility type to make all nested properties optional. Partial
only sets as optional the root ones. As an example, here's the UserData
type:
export interface UserData {
sites: SiteDetails[];
snapshots: Snapshot[];
devToolsOpen?: boolean;
authToken?: StoredToken;
onboardingCompleted?: boolean;
lastBumpStats?: {
[ group: string ]: {
[ stat: string ]: number;
};
};
promptWindowsSpeedUpResult?: PromptWindowsSpeedUpResult;
}
If you make Partial<UserData>
, all the above properties will be optional:
{
sites?: SiteDetails[] | undefined;
snapshots?: Snapshot[] | undefined;
devToolsOpen?: boolean | undefined;
authToken?: StoredToken | undefined;
onboardingCompleted?: boolean | undefined;
lastBumpStats?: {
...;
} | undefined;
promptWindowsSpeedUpResult?: PromptWindowsSpeedUpResult | undefined;
}
However, for instance, the nested properties of SiteDetails
like SiteDetails.id
won't be optional. I found this situation while writing this unit test, and needed to mock the persisted user data. In my case, I only wanted to define part of the site details. That's why I introduced this extra utility type. I presume that we might need it in the future in similar cases, mostly when adding unit tests.
Related to #240 (comment) and #225.
Proposed Changes
8.0
, as it was the default version used before Bump default PHP version to8.1
#240 got merged.Testing Instructions
New sites
8.1
.wp-admin/site-health.php?tab=debug
.8.1
.Old sites
~/Library/Application\ Support/Studio/appdata-v1.json
and removephpVersion
property from sites.8.0
.8.0
is selected.Pre-merge Checklist