Page MenuHomePhabricator

Error undeleting only files
Closed, ResolvedPublicPRODUCTION ERROR

Description

Go to a deleted file, and try to undelete only the file without undeleting any wikitext revisions. It produces an error:

2023-08-26 02:10:10.183854 [58e3a38d-ed07-445e-84f9-43b4aee87468] mw-web.eqiad.main-7f65fbb9c8-lwhwj mediawikiwiki 1.41.0-wmf.23 exception ERROR: [58e3a38d-ed07-445e-84f9-43b4aee87468] /w/index.php?action=submit&title=Special:Undelete   TypeError: Argument 4 passed to MediaWiki\HookContainer\HookRunner::onPageUndeleteComplete() must be an instance of MediaWiki\Revision\RevisionRecord, null given, called in /srv/mediawiki/php-1.41.0-wmf.23/includes/page/UndeletePage.php on line 371 {"exception_url":"/w/index.php?action=submit&title=Special:Undelete","reqId":"58e3a38d-ed07-445e-84f9-43b4aee87468","caught_by":"entrypoint"} 
[Error TypeError] (/srv/mediawiki/php-1.41.0-wmf.23/includes/HookContainer/HookRunner.php:2801) Argument 4 passed to MediaWiki\HookContainer\HookRunner::onPageUndeleteComplete() must be an instance of MediaWiki\Revision\RevisionRecord, null given, called in /srv/mediawiki/php-1.41.0-wmf.23/includes/page/UndeletePage.php on line 371
  #0 /srv/mediawiki/php-1.41.0-wmf.23/includes/page/UndeletePage.php(371): MediaWiki\HookContainer\HookRunner->onPageUndeleteComplete(WikiFilePage, User, string, NULL, ManualLogEntry, integer, boolean, array)
  #1 /srv/mediawiki/php-1.41.0-wmf.23/includes/page/UndeletePage.php(259): MediaWiki\Page\UndeletePage->undeleteUnsafe(string)
  #2 /srv/mediawiki/php-1.41.0-wmf.23/includes/specials/SpecialUndelete.php(1535): MediaWiki\Page\UndeletePage->undeleteIfAllowed(string)
  #3 /srv/mediawiki/php-1.41.0-wmf.23/includes/specials/SpecialUndelete.php(368): SpecialUndelete->undelete()
  #4 /srv/mediawiki/php-1.41.0-wmf.23/includes/specialpage/SpecialPage.php(701): SpecialUndelete->execute(NULL)
  #5 /srv/mediawiki/php-1.41.0-wmf.23/includes/specialpage/SpecialPageFactory.php(1565): SpecialPage->run(NULL)
  #6 /srv/mediawiki/php-1.41.0-wmf.23/includes/MediaWiki.php(344): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
  #7 /srv/mediawiki/php-1.41.0-wmf.23/includes/MediaWiki.php(942): MediaWiki->performRequest()
  #8 /srv/mediawiki/php-1.41.0-wmf.23/includes/MediaWiki.php(591): MediaWiki->main()
  #9 /srv/mediawiki/php-1.41.0-wmf.23/index.php(50): MediaWiki->run()
  #10 /srv/mediawiki/php-1.41.0-wmf.23/index.php(46): wfIndexMain()
  #11 /srv/mediawiki/w/index.php(3): require(string)
  #12 {main}

Event Timeline

Was this a undeletion where no file page exists? That seems not useful at all.
Undeletion of an old version where the file page exists could be a valid use case. But without the null revision this could look wrong in the history as well.

TypeError: MediaWiki\HookContainer\HookRunner::onPageUndeleteComplete(): Argument #4 ($restoredRev) must be of type MediaWiki\Revision\RevisionRecord, null given, called in includes\page\UndeletePage.php on line 370

It's new code https://gerrit.wikimedia.org/r/c/mediawiki/core/+/876374 / T321412, as no page is undeleted, the revision is missing.

I'm experiencing this same issue at File:Donald Trump mug shot.jpg on enwiki (also see its talk page). The file still has all the description pages.

What I was trying to do was history split a file, moving some image revisions of one file page to another, and the image revisions were uploaded with no corresponding text changes (and thus, the text content of the null revision for the uploads I was splitting contained text related to the original upload). My plan was to create a wikitext page for the new file after doing the undelete, and I acknowledge I could have done it in the other order, but still I should have gotten a better error message than a traceback.

If I remember correctly, I did then create a description and tried the undelete again, which worked but didn't properly generate an undelete log entry and displayed a broken success page.

Undeletion of an old version where the file page exists could be a valid use case. But without the null revision this could look wrong in the history as well.

Perhaps. But still the software should assume admins know what they are doing, unless there's some good technical reason to prohibit it.

Change 953341 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/core@master] page: Run PageUndeleteComplete hook only on undeletion of text

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

Change 953341 merged by jenkins-bot:

[mediawiki/core@master] page: Run PageUndeleteComplete hook only on undeletion of text

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