[6.x] Fix global variables being lost when migrated alongside addon update scripts#14963
Merged
Conversation
Writing the variables file directly with File::put left the Stache holding the empty variables created by the global set's save, so anything saving those variables later in the same process (like an addon update script) would clobber the migrated data. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
This pull request fixes an issue where global variables could be lost when updating to v6 and an addon in one go, when the addon's own update script saves global variables (eg. Peak SEO's
AddRobotsscript).This was happening because the
UpdateGlobalVariablesupdate script wrote the migrated variables directly to disk usingFile::put, after$globalSet->save()had already created an empty variables localization through the repository. This left the Stache holding empty variables, so when an addon's update script saved global variables later in the same process, it would overwrite the migrated data on disk with only its own changes.This PR fixes it by saving the migrated data through the
GlobalVariablesrepository instead, keeping the Stache in sync with what's on disk.Caused by #11585