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).