Page MenuHomePhabricator

support statements on properties in changeops
Closed, ResolvedPublic

Description

While https://gerrit.wikimedia.org/r/#/c/170576/ addresses this issue in ChangeOpClaim, we have use of $entity->getClaims() in other ChangeOp classes:

./ChangeOpClaimRemove.php: $claims = new Claims( $entity->getClaims() );
./ChangeOpMainSnak.php: $claims = new Claims( $entity->getClaims() );
./ChangeOpQualifier.php: $claims = new Claims( $entity->getClaims() );
./ChangeOpQualifierRemove.php: $claims = new Claims( $entity->getClaims() );
./ChangeOpReference.php: $claims = new Claims( $entity->getClaims() );
./ChangeOpReferenceRemove.php: $claims = new Claims( $entity->getClaims() );
./ChangeOpsMerge.php: foreach ( $this->fromItem->getClaims() as $fromClaim ) {
./ChangeOpsMerge.php: foreach ( $this->toItem->getClaims() as $claim ) {
./ChangeOpStatementRank.php: $claims = new Claims( $entity->getClaims() );

For an Item, that returns claims. For Property, getClaims() is not implemented so uses Entity::getClaims which returns an empty array!

This is going to be problematic for statements on properties, as well as perhaps other issues in ChangeOps. (and simply the confusion about Claims vs. Statements, since the api modules are called things like 'wbsetclaim')


Version: unspecified
Severity: major
Whiteboard: u=dev c=backend p=0

Details

Reference
bz72879

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:57 AM
bzimport set Reference to bz72879.
bzimport added a subscriber: Unknown Object (MLST).

Jeroen: Can you please look into this? The changes in the new data model are causing issues here and it seems we said we would always use statements and get rid of modeling for claims. This separation now is breaking things like this.

Lydia: the issue here is not in the DataModel, it's in the usage of deprecated code. This code got deprecated quite some time ago, and the implications have been discussed already several times. This includes the not type hinting against Entity, which appears to be happening in the posted code. We have many such places, and it's a task for the whole team to fix this and not introduce new such cases.

Demonstration of how the pressing issue can be resolved: https://gerrit.wikimedia.org/r/#/c/171845/

Commit description also points to the two remaining issues there, one of which is the code not being able to deal with new types of entities as described in https://lists.wikimedia.org/pipermail/wikidata-tech/2014-June/000489.html

Lydia_Pintscher removed a subscriber: Unknown Object (MLST).
Lydia_Pintscher removed a subscriber: Unknown Object (MLST).Dec 1 2014, 2:33 PM
aude set Security to None.

resolved by having getClaims() etc implemented for properties and adding StatementListProvider in data model