Jeroen De Dauw has uploaded a new change for review. https://gerrit.wikimedia.org/r/60872
Change subject: Fix issues in Entity::patch ...................................................................... Fix issues in Entity::patch * The base claim list passed in did not have claim guids as keys * The MapPatcher comparison behaviour was not altered to behave correctly for Claim objects This change depends on https://gerrit.wikimedia.org/r/#/c/60870/ Change-Id: I86d158e9653724c36575d93952da9317fca0f349 --- M DataModel/DataModel/Entity/Entity.php 1 file changed, 17 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/72/60872/1 diff --git a/DataModel/DataModel/Entity/Entity.php b/DataModel/DataModel/Entity/Entity.php index 0bc0a71..032800b 100644 --- a/DataModel/DataModel/Entity/Entity.php +++ b/DataModel/DataModel/Entity/Entity.php @@ -2,7 +2,9 @@ namespace Wikibase; +use Diff\Comparer\CallbackComparer; use Diff\Differ; +use Diff\MapPatcher; use Diff\Patcher; use MWException; use Wikibase\Lib\GuidGenerator; @@ -851,18 +853,27 @@ * @since 0.4 * * @param EntityDiff $patch - * @param Patcher|null $patcher The patcher with which to apply the diff */ - public final function patch( EntityDiff $patch, Patcher $patcher = null ) { - if ( $patcher === null ) { - $patcher = new \Diff\MapPatcher(); - } + public final function patch( EntityDiff $patch ) { + $patcher = new MapPatcher(); + + $patcher->setValueComparer( new CallbackComparer( + function( Claim $firstClaim, Claim $secondClaim ) { + return $firstClaim->getHash() === $secondClaim->getHash(); + } + ) ); $this->setLabels( $patcher->patch( $this->getLabels(), $patch->getLabelsDiff() ) ); $this->setDescriptions( $patcher->patch( $this->getDescriptions(), $patch->getDescriptionsDiff() ) ); $this->setAllAliases( $patcher->patch( $this->getAllAliases(), $patch->getAliasesDiff() ) ); - $claims = $patcher->patch( $this->getClaims(), $patch->getClaimsDiff() ); + $claims = array(); + + foreach ( $this->getClaims() as $claim ) { + $claims[$claim->getGuid()] = $claim; + } + + $claims = $patcher->patch( $claims, $patch->getClaimsDiff() ); $this->setClaims( new Claims( $claims ) ); -- To view, visit https://gerrit.wikimedia.org/r/60872 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I86d158e9653724c36575d93952da9317fca0f349 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
