Import: Properly handle deleted usernames in XML dumps
authorgeorggi <bmp2558@gmail.com>
Mon, 21 Dec 2015 12:50:20 +0000 (14:50 +0200)
committerTTO <at.light@live.com.au>
Mon, 21 Dec 2015 12:52:58 +0000 (12:52 +0000)
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

index ee1cab5..0999931 100644 (file)
@@ -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' ) {