SCON-460: Expose update_version via Feature_Resource#32
Open
pauloiankoski wants to merge 7 commits intomainfrom
Open
SCON-460: Expose update_version via Feature_Resource#32pauloiankoski wants to merge 7 commits intomainfrom
pauloiankoski wants to merge 7 commits intomainfrom
Conversation
has_update was a naive catalog vs installed version comparison stored on the feature object. It is now computed inline inside get_update_data() using the Catalog_Feature parameter, keeping it as an internal transient injection detail without leaking it through the feature's attribute bag. Removes has_update() from the Installable interface and both Plugin and Theme types. Updates tests to reflect that to_array() no longer includes the key.
Feature_Resource decorates a resolved Feature and reads the WordPress update transient (update_plugins or update_themes) to expose an update_version field. This is the authoritative signal for whether an update is available, because Plugin_Handler and Theme_Handler gate transient injection on license availability and dot-org exclusion — conditions that the naive catalog vs installed comparison in has_update did not account for. Safe to call after Feature_Repository has cached its results: the transient filter chain re-enters the repository through the warm cache, so there is no circular resolution.
All Feature_Controller response sites now wrap the resolved feature in Feature_Resource before serializing, merging the transient-sourced update_version into the response payload. Replaces has_update (naive catalog comparison) with update_version (authoritative WP transient value) in the REST schema. update_version is null when the feature is not in the transient — which covers dot-org plugins, unlicensed features, and features that are not installed.
Replaces has_update (naive boolean) with update_version (version string or null) in the TS types and VersionDisplay component. VersionDisplay now shows the update version from the WP transient rather than the catalog version, so the displayed target version matches what WordPress will actually install.
Collection previously implemented Iterator using PHP's internal array pointer, which is shared mutable state. Re-entrant foreach loops over the same cached instance (e.g. triggered by get_site_transient firing the update filter mid-loop) would corrupt the outer cursor, causing get_items() to return only the first feature. Switch to IteratorAggregate so getIterator() returns a fresh ArrayIterator on each foreach, giving every loop its own independent cursor. Also reverts the defensive foreach ($this->items) workaround in Feature_Collection now that the root cause is fixed.
- Remove unused Cast import from Feature_Resource - Add missing generic type annotations to Collection constructor
4d79a6f to
78ba71c
Compare
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.
Resolves SCON-460
Summary
has_updatefrom feature types and replaces it withupdate_version— a nullable string read from the WordPress update transient after resolution is completeFeature_Resourceto decorate resolved features with transient-sourced update data before serialization in the REST APICollection: callingget_site_transient()mid-loop fired the update filter, which iterated the same cached collection and corrupted the outer cursor; switchedCollectionfromIteratortoIteratorAggregateso eachforeachgets its own independentArrayIterator