-
Notifications
You must be signed in to change notification settings - Fork 53
Fixes and improvements for selecting WP version #1189
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
Conversation
|
|
||
| type Option = { label: string; value: string }; | ||
|
|
||
| export const addWpVersionToList = ( newOption: Option, options: Option[] ): Option[] => { |
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.
- I rewrote this function from mutability to immutability.
- Moved close to wpVersionsSelector, since it doesn';t make sense to keep it globally now, when we have only one pleace where we use it.
| @@ -0,0 +1,121 @@ | |||
| import { SelectControl, Icon } from '@wordpress/components'; | |||
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.
Now we have separate component which doesn't store any context, so it's already used in 2 places and can be easily reused in the future, w/o extra conditions.
Also now we have consistency with rendering it for creating/updating website, so it works the same way, we don't need to copy-paste etc.
| const { __ } = useI18n(); | ||
| const { updateSite, selectedSite, stopServer, startServer } = useSiteDetails(); | ||
| const [ isChangeWpError, setIsChangeWpError ] = useState( '' ); | ||
| const [ errorUpdatingWpVersion, setErrorUpdatingWpVersion ] = useState< string | null >( null ); |
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.
Just renamed, since it's not a predicate
|
|
||
| // Only add the auto-updates disabling plugin for non-latest WordPress versions | ||
| if ( options?.wordPressVersion && options.wordPressVersion !== 'latest' ) { | ||
| if ( ! options.isWpAutoUpdating ) { |
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.
Also good example of benefit from isWpAutoUpdating - the condition is much more simple.
|
|
||
| // We use SiteDetails for storing it in appdata-v1.json, so this meta was introduced for extra data which is not stored locally | ||
| type SiteServerMeta = { | ||
| wpVersion?: string; |
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.
@sejas This is only one point where I am not sure that it's the best approach. I am not very familiar with wpnow etc, so could you please take a look on my approach to say - is it good, or maybe it's better to go another way.
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.
I tested multiple cases of existing and new sites, and everything worked correctly. I'll give it a second pass tomorrow.
First, I like that we have a common component. We could rename the label Keep Latest Stable to Latest or Autoupdate Latest. Sites with older versions are marked as "Keep Latest Stable," which I believe is correct, as they will eventually be auto-updated.
For now, the edge case I'm uncertain about are Beta/Nightly versions. Existing sites with those versions are marked as Keep Latest Stable when they are not stable at all.
We add the version to the options, which is great. I think we should also mark that version as selected.
Additionally, I think we should continue auto-updating those beta versions, but it's not a strong opinion.
| </Tooltip> | ||
| </div> | ||
|
|
||
| <WPVersionSelector |
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.
Nice! A single component 💪
| }; | ||
| } | ||
|
|
||
| if ( newSite.wpVersion !== wpVersion ) { |
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.
Everything seems to be working correctly, creating new sites and editing sites.
So removing the test should update site with WordPress version after creation makes sense.
|
Can we display the actual version, e.g., "6.7.2 (latest)" instead of "Keep Latest Stable"?
I think those shouldn't be auto-updated, and the first one should be the only one that is getting auto-updated. Regarding the edit form, it seems there is a bug there as the "Keep Latest Stable" is displayed for each site. I think the currently used version should be preselected. |
|
All existing sites are auto-updated, so eventually if those sites are used they will get updated to the latest version. That's the logic behind the picker showing "Keep Latest Stable" and not the specific version. These existing sites are an edge case and any logic we add to handle them should be something "temporal". @nightnei, Maybe the first time Studio starts we could check the WP version in all existing sites and add
Cool!, let's keep them as "pinned" versions. |
@wojtekn regarding this point - I found it confusing to have both "6.7.2" and "6.7.2 latest", more details I descibed in this thread -p1744195024724019-slack-C04GESRBWKW. Also, I was talking with ChatGPT about it and even w/o providing my thoughts he said that it's not clear for users to understand the difference bethween these options, since in both cases 6.7.2 is indeed latest. So he recommended to flag that the first option keeps site wiuth latest WP version and in teh second it uses static version. Take a look please on the thread. |
@wojtekn @sejas I have teh same thoughts. Also, additionally, as @sejas mentioned before - we would have inconsistency with rendering this warning |
sejas
left a comment
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.
I didn't test it yet. I left a few comments in the new code. Let me know what you think.
c334dcd to
88f70be
Compare
e4e75d9 to
fad6c3d
Compare
wojtekn
left a comment
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.
Feature-wise works well.
sejas
left a comment
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.
Thanks for the changes.
I confirm new created sites work as expected and latest will be autoupdated, while betas and stables have "isWpAutoUpdating": false,
Existing sites are identified with the correct version too.
| text={ __( 'WordPress Core automatic updates will be disabled for this site.' ) } | ||
| placement="top" | ||
| > | ||
| <Icon icon={ warning } className="text-[#ae5c00]" size={ 16 } /> |
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.
|
I noticed the performance metrics is failing in this PR. I think we need to fix that before merging it. |



Followup to Add mu-plugin to prevent updates on selected WordPress versions #1120
Proposed Changes
Previously, users could select specific version for their WP site, but it worked incorrectly - it was still autoupdated to the latest. With this PR we give opportunity to select specific version and opportunity to keep always latest (with auto-updating it). Also This PR adds a few UI improvements and some refacrtoring:
wpVersioninside appdata-v1.json. It's an option, but there are a few disadvantages:2.1. With wpVersion were have 2 source of truth what is definitely not good. Much more reliable and stable to retrieve wp version from site instance, as we did it before.
2.2 If user selected
latestand we store it in appdata-v1.json, then to get specific version we always had to do soothing likewpVersions.find(iteam => item.version === 'latest'), what is not very nice.2.3 Folowing to 2.2 point above - even if we get the specific version with
item.value === 'latest', we can't be sure that it' exactly the version which is used on this specific wp instance, so this way we can bugs.2.4. Storing
isWpAutoUpdating: booleanmakes code much cleaner, as you can see in this PR, since we don't need to add extra condition and we can easily distinguish the version and auto-updating status, since it's 2 different things.Testing Instructions
I decided to record video, since there are a lot of testing instructions and video will simplify go through them.
Also, it will help you (the reviewer) to quickly understand how it works in all scenarios.
https://drive.google.com/file/d/1eXwUk_B8Gkd3-28cVIEj4Sg7YCV9t4Sq/view?usp=sharing