Page MenuHomePhabricator

Add methods to remove Statements from a StatementList
Closed, ResolvedPublic

Description

We need a remove method on StatementList in several places in Wikibase Repository.

Item has a setStatements method but there is no guarantee that every other entity class will have such a method. Entity doesn't provide such a method either (and we are perhaps dropping that class anyways).

StatementListProvider does only have a method to obtain a StatementList, not to set one (which makes sense as it is a provider).

Therefore, we have to add a removeStatement method to StatementList to be able not only to add, but also to remove statements from such a list.

There is a patch on Github already: https://github.com/wmde/WikibaseDataModel/pull/470

The need for such a method can be seen well in https://gerrit.wikimedia.org/r/#/c/204511/, where there are ugly workarounds, just to remove a statement. These hacks include using Item::setStatements or Property::setStatements after some instanceof Item/Property checks. This indicates a wrong coding style and can easily be solved by adding a removeStatement method to StatementList.

Event Timeline

Bene raised the priority of this task from to Needs Triage.
Bene updated the task description. (Show Details)
Bene subscribed.
Bene renamed this task from Add methods to remove Statements a StatementList to Add methods to remove Statements from a StatementList.May 5 2015, 1:58 PM
Bene claimed this task.
Bene updated the task description. (Show Details)
Bene set Security to None.
Bene moved this task from Backlog to Review on the Wikidata-Sprint-2015-04-21 board.
thiemowmde subscribed.

I disagree that "we need" such a method. None of the proposed changes does solve the underlying issue we want to solve. They only work around the issue in a single place, in the remove claim change op.

https://gerrit.wikimedia.org/r/#/c/204511/ does not introduce any new issue that needs to be solved now.

Also this is a duplicate of T78299. Both tickets do have the same problem: They propose what they think is a solution without fully understanding the problem. That's why I closed my ticket.

I actually guess I understand the problem and the issue is described in this task very clear.

Bene raised the priority of this task from Low to Medium.May 5 2015, 2:55 PM
Bene moved this task from Review to Done on the Wikidata-Sprint-2015-04-21 board.
Bene removed a project: Patch-For-Review.

You realize that the proposed remove method can not be used in https://gerrit.wikimedia.org/r/#/c/204511/?