Page MenuHomePhabricator

ErrorException from WikiPage.php during Special:Import of Translations page, bad title passed to beforeImportPage().
Closed, ResolvedPublic

Description

I tried to Special:Import mediawiki.org's API:Main_page to another wiki, including all templates and versions.

Every time I get a fatal error:

/w/index.php?title=Special:Import&action=submit \
   ErrorException from line 126 of /srv/vagrant/mediawiki/includes/page/WikiPage.php: \
   PHP Error: Argument 1 passed to WikiPage::factory() must be an instance of Title, null given
#0 /srv/vagrant/mediawiki/includes/page/WikiPage.php(126): MWExceptionHandler::handleError()
#1 /srv/vagrant/mediawiki/includes/Import.php(313): WikiPage::factory()
#2 /srv/vagrant/mediawiki/includes/Import.php(445): WikiImporter->beforeImportPage()
#3 /srv/vagrant/mediawiki/includes/Import.php(736): WikiImporter->pageCallback() 
#4 /srv/vagrant/mediawiki/includes/Import.php(566): WikiImporter->handlePage()

The title passed to the factory is $titleAndForeignTitle[0] in beforeImportPage(). I dumped it out and found after successfully passing an array for "Module:Template translation: to the factory, on the next invocation $titleAndForeignTitle is false, so $titleAndForeignTitle[0] is NULL and that's not a Title so the factory blows up.

I think the page failing to import is "Translations:API:Cross-site requests/Page display title/en". Trying to import that page alone from mediawikiwiki leads to the same error. Note this translated page is normally managed by Special:Translate.

WikiImporter's handlePage() detects a bad title, but proceeds to call beforeImportPage() anyway, and crash:

if ( !$title ) {
    $badTitle = true;
    $skip = true;
}                           
                
$this->pageCallback( $title );

I think the code needs to skip the beforeImportPage() callback if $badTitle, and maybe Special:Translate needs to interpose on handling import/export of its NS_TRANSLATIONS namespace.

Event Timeline

Spage raised the priority of this task from to Needs Triage.
Spage updated the task description. (Show Details)
Spage added a subscriber: Spage.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 10 2015, 1:25 AM
aude added a subscriber: aude.Sep 8 2015, 1:45 PM

can reproduce this...

Catchable fatal error: Argument 1 passed to WikiPage::factory() must be an instance of Title, null given in /var/www/wiki/w/includes/page/WikiPage.php on line 126

Change 236784 had a related patch set (by Aude) published:
Fix exception in Import, when import of a revision fails

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

Change 236784 merged by jenkins-bot:
Fix exception in Import, when import of a revision fails

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

Change 263202 had a related patch set uploaded (by TTO):
Fix exception in Import, when import of a revision fails

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

Restricted Application added a subscriber: StudiesWorld. · View Herald TranscriptJan 10 2016, 2:00 AM

Change 263205 had a related patch set uploaded (by TTO):
Fix exception in Import, when import of a revision fails

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

Change 263202 merged by jenkins-bot:
Fix exception in Import, when import of a revision fails

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

Change 263205 merged by jenkins-bot:
Fix exception in Import, when import of a revision fails

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

TTO reassigned this task from TTO to aude.Oct 27 2018, 9:48 PM
TTO added a subscriber: TTO.