Page MenuHomePhabricator

Fix Undefined index: id & timestamp in MediaWiki's Import.php
Closed, ResolvedPublic

Description

Notice: Undefined index: id in C:\SMWPLUS\htdocs\mediawiki\includes\Import.php on line 548

Notice: Undefined index: timestamp in C:\SMWPLUS\htdocs\mediawiki\includes\Import.php on line 551

these messages above are generated with a very simple <page> element one without an <id> or <timestamp> child element.


Version: unspecified
Severity: normal

Details

Reference
bz32876

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:05 AM
bzimport set Reference to bz32876.

I have strict errror reporting turned on.

Could you provide a sample file to produce the E_STRICT errors?

I have had a similar experience with:
php importDump.php ukwikimedia-20130608-pages-logging.xml.gz
(...)
5397 (370.49 revs/sec)
5398 (370.50 revs/sec)
5399 (370.52 revs/sec)
PHP Notice: Undefined index: params in /var/www/wiki/w/includes/Import.php on line 545
PHP Notice: Undefined index: logtitle in /var/www/wiki/w/includes/Import.php on line 546
WikiRevision given a null title in import. You may need to adjust $wgLegalTitleChars.
Backtrace:
#0 /var/www/wiki/w/includes/Import.php(546): WikiRevision->setTitle(NULL)
#1 /var/www/wiki/w/includes/Import.php(528): WikiImporter->processLogItem(Array)
#2 /var/www/wiki/w/includes/Import.php(466): WikiImporter->handleLogItem()
#3 /var/www/wiki/w/maintenance/importDump.php(286): WikiImporter->doImport()
#4 /var/www/wiki/w/maintenance/importDump.php(245): BackupReader->importFromHandle(Resource id #75)
#5 /var/www/wiki/w/maintenance/importDump.php(95): BackupReader->importFromFile('/tmp/ukwikimedi...')
#6 /var/www/wiki/w/maintenance/doMaintenance.php(110): BackupReader->execute()
#7 /var/www/wiki/w/maintenance/importDump.php(291): require_once('/var/www/wiki/w...')
#8 {main}

In my case, it seems the XML file has an entry (corrupted?) with a NULL title. To workaround this, I just return if non title in ImportDump.php

private function processLogItem( $logInfo ) {

if ( ! $logInfo['logtitle'] ) {
   return;
}

They aren't corrupted, they're gone:

 <logitem>
  <id>5406</id>
  <timestamp>2013-02-01T16:58:20Z</timestamp>
  <contributor>
    <username>Andrew Gray</username>
    <id>370</id>
  </contributor>
  <type>delete</type>
  <action>revision</action>
  <text deleted="deleted" />
</logitem>
<logitem>
  <id>5407</id>
  <timestamp>2013-02-01T17:03:42Z</timestamp>
  <contributor>
    <username>Andrew Gray</username>
    <id>370</id>
  </contributor>
  <type>delete</type>
  <action>delete</action>
  <text deleted="deleted" />
</logitem>
<logitem>
  <id>5408</id>
  <timestamp>2013-02-01T17:03:51Z</timestamp>
  <contributor>
    <username>Andrew Gray</username>
    <id>370</id>
  </contributor>
  <comment>1 revision restored</comment>
  <type>delete</type>
  <action>restore</action>
  <text deleted="deleted" />
</logitem>

Obviously the failure to handle these gracefully is a bug.

TTO added a comment.Jul 28 2014, 11:57 AM

WikiImporter doesn't know the meaning of grace...

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 18 2015, 10:28 AM
Aklapper renamed this task from Undefined index: id & timestamp to Fix Undefined index: id & timestamp in MediaWiki's Import.php.Dec 3 2015, 5:39 PM
Aklapper set Security to None.
TTO removed TTO as the assignee of this task.Dec 6 2015, 11:39 AM

I'll try working on this!

TTO added a subscriber: Georggi199.Jan 24 2016, 2:58 PM

Georggi did some work on this, but I can't remember why it isn't linked to this task.

@Pranavmk98: It would be worth testing whether there is actually anything left to fix here :)

All right; how do I reproduce the error?

Yup, just found @Georggi199's patch: https://gerrit.wikimedia.org/r/#/c/259987/
I guess it's fixed already :)

Georggi199 added a comment.EditedJan 24 2016, 3:05 PM

I think it was fixed in these pathes https://gerrit.wikimedia.org/r/#/c/259987/ https://gerrit.wikimedia.org/r/#/c/260349/
P.s. I am too slow:D

Aklapper closed this task as Resolved.Mar 10 2016, 1:02 PM
Aklapper claimed this task.