From aaf52989d4dead14fecb35f13450a7cd2ab7a8fa Mon Sep 17 00:00:00 2001 From: georggi Date: Mon, 21 Dec 2015 14:50:20 +0200 Subject: [PATCH] Import: Properly handle deleted usernames in XML dumps Fixed username being not shown at all when contributor is deleted Fixed text not being shown when contributor is deleted Bug: T121338 Change-Id: I981c326f61735ace1d1fba35428bfc25d127b544 --- includes/Import.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/Import.php b/includes/Import.php index ee1cab54ee..0999931839 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -861,9 +861,10 @@ class WikiImporter { } if ( isset( $revisionInfo['contributor']['ip'] ) ) { $revision->setUserIP( $revisionInfo['contributor']['ip'] ); - } - if ( isset( $revisionInfo['contributor']['username'] ) ) { + } elseif ( isset( $revisionInfo['contributor']['username'] ) ) { $revision->setUserName( $revisionInfo['contributor']['username'] ); + } else { + $revision->setUserName( 'Unknown user' ); } $revision->setNoUpdates( $this->mNoUpdates ); @@ -981,6 +982,9 @@ class WikiImporter { $fields = array( 'id', 'ip', 'username' ); $info = array(); + if ( $this->reader->isEmptyElement ) { + return $info; + } while ( $this->reader->read() ) { if ( $this->reader->nodeType == XMLReader::END_ELEMENT && $this->reader->localName == 'contributor' ) { -- 2.20.1