refactor: resolve the version switcher source and installer through filters - #568
Draft
lightbulbman wants to merge 11 commits into
Draft
lightbulbman wants to merge 11 commits into
lightbulbman wants to merge 11 commits into
Conversation
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.
Moves the two parts of the version switcher that an implementation may need to vary — where the list of available versions comes from, and how a package is written to disk — behind interfaces resolved through filters. Caching, the in-progress marker, capability and nonce checks, validation and rendering remain in
Version_Switch.Changes
Version_SourceandPackage_Installerinterfaces, withWordPress_Org_Version_SourceandUpgrader_Package_Installeras the defaults. No registration is required; the defaults apply unless thecode_snippets_version_sourceorcode_snippets_package_installerfilters supply a replacement.Version_Switchto resolve both services through those filters, cache the catalogue under the source's ownget_cache_key(), record the reason a catalogue request failed, and render the available, unavailable and in-progress states.initVersionSwitch()when the switcher configuration is absent, so the unavailable state renders as a notice with no controls.get_last_error_message().get_last_error_code()still reads the previous transient shape, which a site holds until it expires.Verification
tests/unit/Settings/Version_Switch_Test.phpadds 28 tests covering the cache key, uncached source errors, target validation, the install and cleanup paths on both success and failure, the filters replacing and restoring both services, and the markup rendered for a failed request, an empty catalogue, a populated catalogue and the floor notice.tests/unit/Core/Uninstaller_Test.phpcovers the transient removal.🤖 Generated with Claude Code