mw.Upload.BookletLayout: Don't explode when the API call fails with 'exception'
[lhc/web/wiklou.git] / 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' ) {