Uh oh!
There was an error while loading. Please reload this page.
Add index parameter to StatementList::addStatement - #664
Merged
Conversation
JeroenDeDauw
commented
Apr 28, 2016
Contributor
Seems reasonable enough. Reminds me of how Claims got messed up, lets be careful to not repeat that |
thiemowmde
commented
Apr 29, 2016
ContributorAuthor
Totally agree. See #666 for a possible deprecation in this class. |
adrianheine
commented
May 9, 2016
Contributor
Ok. I think I would have preferred a new method |
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 freeto 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.
I'm proposing this as the most simple fix to get rid of StatementListHolder. This is currently not possible because there is no way to re-implement the index feature in ChangeOpStatement without having an
Entity::setStatementsor at leastStatementList:cleanmethod.clearmethod we do not want for good reasons, see Add clear to list classes #649, or by calling the existingremoveStatementsWithGuidin a loop, which qualifies as a hack). The StatementList can then be re-filled by re-adding all statements in the new order. Again, this is more "a hack on top of a hack" than a clean solution.You may wonder why this is the only StatementList method that exposes this index. Don't be fooled:
toArrayexposes the indexes. Whatever a user wants to know about an index (e.g. find statements by index or query for an index by GUID, main snak or property ID), I propose to not implement all this as StatementList methods. Instead, let the user iterate the array. The only guaranteetoArraymust give then (and already gives, see #466) is that the array keys correctly reflect the indexes.This new index parameter fits, in my opinion, perfectly fine in the overall contract of the class: It's thin wrapper around a numerically index array of statements, not ordered or grouped in any way.
This is identical to
ReferenceList::addReference.Bug: T133853