Page MenuHomePhabricator

Fatal error when restoring Lexeme "merge" revision: Argument passed to Lexeme::setLexicalCategory() must be an instance of Wikibase\DataModel\Entity\ItemId
Closed, ResolvedPublic8 Story Points

Description

To reproduce

  • Create a lexeme
  • Merge it into another lexeme
  • Restore the previous (non-merged) version of the (source) lexeme
  • Try to restore the merged/redirected version again
TypeError from line 241 of …/extensions/WikibaseLexeme/src/DataModel/Lexeme.php: Argument 1 passed to Wikibase\Lexeme\DataModel\Lexeme::setLexicalCategory() must be an instance of Wikibase\DataModel\Entity\ItemId, null given, called in …/extensions/WikibaseLexeme/src/DataModel/Services/Diff/LexemePatcher.php on line 83

Backtrace:

#0 …/extensions/WikibaseLexeme/src/DataModel/Services/Diff/LexemePatcher.php(83): Wikibase\Lexeme\DataModel\Lexeme->setLexicalCategory(NULL)
#1 …/extensions/WikibaseLexeme/vendor/wikibase/data-model-services/src/Diff/EntityPatcher.php(40): Wikibase\Lexeme\DataModel\Services\Diff\LexemePatcher->patchEntity(Wikibase\Lexeme\DataModel\Lexeme, Wikibase\Lexeme\DataModel\Services\Diff\LexemeDiff)
#2 …/extensions/Wikibase/repo/includes/Content/EntityContent.php(595): Wikibase\DataModel\Services\Diff\EntityPatcher->patchEntity(Wikibase\Lexeme\DataModel\Lexeme, Wikibase\Lexeme\DataModel\Services\Diff\LexemeDiff)
#3 …/extensions/Wikibase/repo/includes/Actions/SubmitEntityAction.php(160): Wikibase\EntityContent->getPatchedCopy(Wikibase\Repo\Content\EntityContentDiff)
#4 …/extensions/Wikibase/repo/includes/Actions/SubmitEntityAction.php(113): Wikibase\SubmitEntityAction->getPatchContent(Revision, Revision, Revision)
#5 …/extensions/Wikibase/repo/includes/Actions/SubmitEntityAction.php(66): Wikibase\SubmitEntityAction->undo()
#6 …/includes/MediaWiki.php(501): Wikibase\SubmitEntityAction->show()
#7 …/includes/MediaWiki.php(294): MediaWiki->performAction(Article, Title)
#8 …/includes/MediaWiki.php(868): MediaWiki->performRequest()
#9 …/includes/MediaWiki.php(525): MediaWiki->main()
#10 …/index.php(42): MediaWiki->run()
#11 {main}

It looks like the diff between the previous revision and the redirected revision results in a DiffOpRemove for the lexical category, in which case LexemePatcher::getPatchedItemId returns null, but LexemePatcher::patchEntity doesn’t expect this. (The same presumably applies to the language as well.)

You can try this out on test.wikidata.org with L104 (restore link).

Event Timeline

Krinkle renamed this task from Error when restoring merge revision of lexeme to Fatal error when restoring Lexeme "merge" revision: Argument passed to Lexeme::setLexicalCategory() must be an instance of Wikibase\DataModel\Entity\ItemId.Oct 27 2018, 6:32 PM
Restricted Application added a project: User-Addshore. · View Herald TranscriptJan 9 2019, 1:57 PM

Can reproduce locally

[8780cea5a9da1132dc103722] /mediawiki/index.php?title=Lexeme:L1&action=submit&restore=15 TypeError from line 235 of /var/www/mediawiki/extensions/WikibaseLexeme/src/Domain/Model/Lexeme.php: Argument 1 passed to Wikibase\Lexeme\Domain\Model\Lexeme::setLexicalCategory() must be an instance of Wikibase\DataModel\Entity\ItemId, null given, called in /var/www/mediawiki/extensions/WikibaseLexeme/src/Domain/Diff/LexemePatcher.php on line 83

Backtrace:

#0 /var/www/mediawiki/extensions/WikibaseLexeme/src/Domain/Diff/LexemePatcher.php(83): Wikibase\Lexeme\Domain\Model\Lexeme->setLexicalCategory(NULL)
#1 /var/www/mediawiki/vendor/wikibase/data-model-services/src/Diff/EntityPatcher.php(40): Wikibase\Lexeme\Domain\Diff\LexemePatcher->patchEntity(Wikibase\Lexeme\Domain\Model\Lexeme, Wikibase\Lexeme\Domain\Diff\LexemeDiff)
#2 /var/www/mediawiki/extensions/Wikibase/repo/includes/Content/EntityContent.php(590): Wikibase\DataModel\Services\Diff\EntityPatcher->patchEntity(Wikibase\Lexeme\Domain\Model\Lexeme, Wikibase\Lexeme\Domain\Diff\LexemeDiff)
#3 /var/www/mediawiki/extensions/Wikibase/repo/includes/Actions/SubmitEntityAction.php(160): Wikibase\EntityContent->getPatchedCopy(Wikibase\Repo\Content\EntityContentDiff)
#4 /var/www/mediawiki/extensions/Wikibase/repo/includes/Actions/SubmitEntityAction.php(113): Wikibase\SubmitEntityAction->getPatchContent(Revision, Revision, Revision)
#5 /var/www/mediawiki/extensions/Wikibase/repo/includes/Actions/SubmitEntityAction.php(66): Wikibase\SubmitEntityAction->undo()
#6 /var/www/mediawiki/includes/MediaWiki.php(501): Wikibase\SubmitEntityAction->show()
#7 /var/www/mediawiki/includes/MediaWiki.php(294): MediaWiki->performAction(Article, Title)
#8 /var/www/mediawiki/includes/MediaWiki.php(862): MediaWiki->performRequest()
#9 /var/www/mediawiki/includes/MediaWiki.php(517): MediaWiki->main()
#10 /var/www/mediawiki/index.php(42): MediaWiki->run()
#11 {main}

Change 483195 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/extensions/WikibaseLexeme@master] Allow setting Lexeme language and lex category to null

https://gerrit.wikimedia.org/r/483195

Change 483419 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/extensions/Wikibase@master] EntityContent, factor patchCopyWithEntityDiff out of getPatchedCopy

https://gerrit.wikimedia.org/r/483419

Change 483419 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] EntityContent, factor patchCopyWithEntityDiff out of getPatchedCopy

https://gerrit.wikimedia.org/r/483419

Change 484224 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/extensions/Wikibase@master] Revert "EntityContent, factor patchCopyWithEntityDiff out of getPatchedCopy"

https://gerrit.wikimedia.org/r/484224

Change 483195 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Allow setting Lexeme language and lex category to null

https://gerrit.wikimedia.org/r/483195

Change 484224 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Revert "EntityContent, factor patchCopyWithEntityDiff out of getPatchedCopy"

https://gerrit.wikimedia.org/r/484224