Handle missing titles and usernames when importing log items
[lhc/web/wiklou.git] / maintenance / importDump.php
index bf59495..6b7cfb6 100644 (file)
@@ -119,7 +119,8 @@ TEXT;
 
        private function getNsIndex( $namespace ) {
                global $wgContLang;
-               if ( ( $result = $wgContLang->getNsIndex( $namespace ) ) !== false ) {
+               $result = $wgContLang->getNsIndex( $namespace );
+               if ( $result !== false ) {
                        return $result;
                }
                $ns = intval( $namespace );
@@ -134,16 +135,24 @@ TEXT;
         * @return bool
         */
        private function skippedNamespace( $obj ) {
+               $title = null;
                if ( $obj instanceof Title ) {
-                       $ns = $obj->getNamespace();
+                       $title = $obj;
                } elseif ( $obj instanceof Revision ) {
-                       $ns = $obj->getTitle()->getNamespace();
+                       $title = $obj->getTitle();
                } elseif ( $obj instanceof WikiRevision ) {
-                       $ns = $obj->title->getNamespace();
+                       $title = $obj->title;
                } else {
                        throw new MWException( "Cannot get namespace of object in " . __METHOD__ );
                }
 
+               if ( is_null( $title ) ) {
+                       // Probably a log entry
+                       return false;
+               }
+
+               $ns = $title->getNamespace();
+
                return is_array( $this->nsFilter ) && !in_array( $ns, $this->nsFilter );
        }