feat: allow duplicate registry values #7988
Merged
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.
The basics
The details
Resolves
Fixes #7924
Proposed Changes
Does not throw an error if you attempt to register the same object twice (under the same type and case-insensitive name)
Reason for Changes
This is similar to #7983. The difference in behavior is subtle:
In this PR: If you try to register the same
TestObject
twice, first under the nametest
and second under the nameTest
, then we'll allow you to register the object without throwing an error and we'll also update the cased name to beTest
, which only matters if you later callgetAllItems(type, true)
where we give you the most-recently used cased version of the name. This is consistent with how it works if you pass a different object, same name, and pass theopt_allowOverrides
parameter: we'll update the case of the stored name.In #7983: If you try to register the same
TestObject
twice, first under the nametest
and second under the nameTest
, then we'll allow you to register the object without throwing an error. But we won't update the most-recently-cased version of the name. This is inconsistent with how it works if you pass a different object, same name, and pass theopt_allowOverrides
. It's also a behavior change where previously, you could register the same object and intentionally change the case by passing theopt_allowOverrides
flag.I think maintaining consistency with how the overrides flag works is better, and it makes it easier to explain the "last used case" part of the registry that keeps track of the case-sensitive name you registered an item under. That's why I think this PR should be merged instead of #7983 (or #7982)
Test Coverage
Added unit test for this case.
Documentation
Maybe? We don't really explain the registry anywhere. The most likely place this gets explained is in the documentation about how installing fields/blocks plugins works.
Additional Information
See #7924 and #7987 for related discussion.