New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up entity patching code #196
Conversation
@WMDE-Fisch @Benestar FYI |
* @throws InvalidArgumentException | ||
* @throws RuntimeException | ||
*/ | ||
public function patchEntity( EntityDocument $entity, EntityDiff $patch ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wtf?? Guess I need to file a fifth PhpStorm 8.0 bug then!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or not. Added in 186fbd7, so guess @WMDE-Fisch does not have his IDE set to tabs. Heresy! :)
Let's do some bets :)
Edit: found you can cheat by checking https://scrutinizer-ci.com/g/wmde/WikibaseDataModel/inspections/3c5ffa61-9677-4995-8a9d-7bc119f0e878
|
@addshore For great rating! :) |
$patchedEntity = $item->copy(); | ||
$patcher->patchEntity( $patchedEntity, new ItemDiff() ); | ||
|
||
$this->assertEquals( $item, $patchedEntity ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still indentation issues
This also drops the usage of the deprecated term related methods defined in Entity
a8b92f1
to
5a3cc3c
Compare
|
||
$item->setStatements( $this->statementListPatcher->getPatchedStatementList( | ||
$item->getStatements(), | ||
$patch->getClaimsDiff() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a problem of this patch but we have to remember that this isn't very sane. EntityDiff
should not know about claims.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should also not know about fingerprints. And the "claims" in the names here should be changed to "statements". That's an EntityDiff
problem though, which is for another time.
-1 for the Statement/Claim confusion |
Removed now |
* @licence GNU GPL v2+ | ||
* @author Jeroen De Dauw < jeroendedauw@gmail.com > | ||
*/ | ||
interface EntityPatcherStrategy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the benefit of this interface. EntityDocument
is only about ids and the ids will never get patched because they are immutable. Therefore we will also most likely kill the EntityDiff
class entirely because it contains now EntityStuff
but only stuff specific for fingerprints or claims/statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason we have this interface is so that we can have EntityPatcher
, or rather the functionality EntityPatcher
provides. The users of DataModel have places where they have something of type Entity
and need to patch it. In many cases having something of an unknown Entity
types is bad, but still DM needs to support its current users. This dispatcher + strategy approach allows DM to support this without itself having any patching logic that deals with entities of unknown type.
TL;DR: split patching code from Entity and did the same with its tests
Done: