Repository navigation
[6.x] Fix fieldtypes extending Replicator when adding sets - #15574
Merged
Merged
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.
This pull request fixes adding sets to custom fieldtypes that extend
Replicator. This worked in Statamic 5, where set defaults were preloaded byReplicator::preload()and inherited by subclasses. #13427 moved this to a request to this endpoint, and #13694 added the handle check that subclasses don't pass, so it has been broken since 6.0.0.ReplicatorSetControllerdecided whether a field was a replicator by comparing its handle againstbardandreplicator. A custom fieldtype extendingReplicatorhas its own handle, so it failed that check. The controller then treated the field as something else and threwUndefined array key. Adding a set returned a 500, both when the custom fieldtype was the target field and when the field path went through it to a replicator nested inside.The controller now resolves the fieldtype from its handle and checks
instanceof Replicator, which covers Bard, Replicator and any subclass. A handle with no registered fieldtype is treated as not a replicator, so the existing handling for custom fieldtypes with nestedfieldsstill works.