Drop "left in" debugging var_dump from WikiImporter
[lhc/web/wiklou.git] / includes / Import.php
index 6150ae1..3880e25 100644 (file)
@@ -40,12 +40,14 @@ class WikiImporter {
 
        /**
         * Creates an ImportXMLReader drawing from the source provided
-        * @param $source
+        * @param ImportStreamSource $source
         */
-       function __construct( $source ) {
+       function __construct( ImportStreamSource $source ) {
                $this->reader = new XMLReader();
 
-               stream_wrapper_register( 'uploadsource', 'UploadSourceAdapter' );
+               if ( !in_array( 'uploadsource', stream_get_wrappers() ) ) {
+                       stream_wrapper_register( 'uploadsource', 'UploadSourceAdapter' );
+               }
                $id = UploadSourceAdapter::registerSource( $source );
                if ( defined( 'LIBXML_PARSEHUGE' ) ) {
                        $this->reader->open( "uploadsource://$id", null, LIBXML_PARSEHUGE );
@@ -60,22 +62,29 @@ class WikiImporter {
                $this->setPageOutCallback( array( $this, 'finishImportPage' ) );
        }
 
-       private function throwXmlError( $err ) {
+       /**
+        * @return null|XMLReader
+        */
+       public function getReader() {
+               return $this->reader;
+       }
+
+       public function throwXmlError( $err ) {
                $this->debug( "FAILURE: $err" );
                wfDebug( "WikiImporter XML error: $err\n" );
        }
 
-       private function debug( $data ) {
+       public function debug( $data ) {
                if ( $this->mDebug ) {
                        wfDebug( "IMPORT: $data\n" );
                }
        }
 
-       private function warn( $data ) {
+       public function warn( $data ) {
                wfDebug( "IMPORT: $data\n" );
        }
 
-       private function notice( $msg /*, $param, ...*/ ) {
+       public function notice( $msg /*, $param, ...*/ ) {
                $params = func_get_args();
                array_shift( $params );
 
@@ -88,7 +97,7 @@ class WikiImporter {
 
        /**
         * Set debug mode...
-        * @param $debug bool
+        * @param bool $debug
         */
        function setDebug( $debug ) {
                $this->mDebug = $debug;
@@ -96,7 +105,7 @@ class WikiImporter {
 
        /**
         * Set 'no updates' mode. In this mode, the link tables will not be updated by the importer
-        * @param $noupdates bool
+        * @param bool $noupdates
         */
        function setNoUpdates( $noupdates ) {
                $this->mNoUpdates = $noupdates;
@@ -184,7 +193,7 @@ class WikiImporter {
 
        /**
         * Set a target namespace to override the defaults
-        * @param $namespace
+        * @param null|int $namespace
         * @return bool
         */
        public function setTargetNamespace( $namespace ) {
@@ -201,8 +210,8 @@ class WikiImporter {
 
        /**
         * Set a target root page under which all pages are imported
-        * @param $rootpage
-        * @return status object
+        * @param null|string $rootpage
+        * @return Status
         */
        public function setTargetRootPage( $rootpage ) {
                $status = Status::newGood();
@@ -211,7 +220,11 @@ class WikiImporter {
                        $this->mTargetRootPage = null;
                } elseif ( $rootpage !== '' ) {
                        $rootpage = rtrim( $rootpage, '/' ); //avoid double slashes
-                       $title = Title::newFromText( $rootpage, !is_null( $this->mTargetNamespace ) ? $this->mTargetNamespace : NS_MAIN );
+                       $title = Title::newFromText( $rootpage, !is_null( $this->mTargetNamespace )
+                               ? $this->mTargetNamespace
+                               : NS_MAIN
+                       );
+
                        if ( !$title || $title->isExternal() ) {
                                $status->fatal( 'import-rootpage-invalid' );
                        } else {
@@ -233,14 +246,14 @@ class WikiImporter {
        }
 
        /**
-        * @param $dir
+        * @param string $dir
         */
        public function setImageBasePath( $dir ) {
                $this->mImageBasePath = $dir;
        }
 
        /**
-        * @param $import
+        * @param bool $import
         */
        public function setImportUploads( $import ) {
                $this->mImportUploads = $import;
@@ -248,11 +261,11 @@ class WikiImporter {
 
        /**
         * Default per-revision callback, performs the import.
-        * @param $revision WikiRevision
+        * @param WikiRevision $revision
         * @return bool
         */
        public function importRevision( $revision ) {
-               if ( !$revision->getContent()->getContentHandler()->canBeUsedOn( $revision->getTitle() ) ) {
+               if ( !$revision->getContentHandler()->canBeUsedOn( $revision->getTitle() ) ) {
                        $this->notice( 'import-error-bad-location',
                                $revision->getTitle()->getPrefixedText(),
                                $revision->getID(),
@@ -278,17 +291,17 @@ class WikiImporter {
 
        /**
         * Default per-revision callback, performs the import.
-        * @param $rev WikiRevision
+        * @param WikiRevision $revision
         * @return bool
         */
-       public function importLogItem( $rev ) {
+       public function importLogItem( $revision ) {
                $dbw = wfGetDB( DB_MASTER );
-               return $dbw->deadlockLoop( array( $rev, 'importLogItem' ) );
+               return $dbw->deadlockLoop( array( $revision, 'importLogItem' ) );
        }
 
        /**
         * Dummy for now...
-        * @param $revision
+        * @param WikiRevision $revision
         * @return bool
         */
        public function importUpload( $revision ) {
@@ -298,12 +311,12 @@ class WikiImporter {
 
        /**
         * Mostly for hook use
-        * @param $title
-        * @param $origTitle
-        * @param $revCount
-        * @param $sRevCount
-        * @param $pageInfo
-        * @return
+        * @param Title $title
+        * @param string $origTitle
+        * @param int $revCount
+        * @param int $sRevCount
+        * @param array $pageInfo
+        * @return bool
         */
        public function finishImportPage( $title, $origTitle, $revCount, $sRevCount, $pageInfo ) {
                $args = func_get_args();
@@ -312,7 +325,7 @@ class WikiImporter {
 
        /**
         * Alternate per-revision callback, for debugging.
-        * @param $revision WikiRevision
+        * @param WikiRevision $revision
         */
        public function debugRevisionHandler( &$revision ) {
                $this->debug( "Got revision:" );
@@ -329,7 +342,7 @@ class WikiImporter {
 
        /**
         * Notify the callback function when a new "<page>" is reached.
-        * @param $title Title
+        * @param Title $title
         */
        function pageCallback( $title ) {
                if ( isset( $this->mPageCallback ) ) {
@@ -339,11 +352,11 @@ class WikiImporter {
 
        /**
         * Notify the callback function when a "</page>" is closed.
-        * @param $title Title
-        * @param $origTitle Title
-        * @param $revCount Integer
-        * @param int $sucCount number of revisions for which callback returned true
-        * @param array $pageInfo associative array of page information
+        * @param Title $title
+        * @param Title $origTitle
+        * @param int $revCount
+        * @param int $sucCount Number of revisions for which callback returned true
+        * @param array $pageInfo Associative array of page information
         */
        private function pageOutCallback( $title, $origTitle, $revCount, $sucCount, $pageInfo ) {
                if ( isset( $this->mPageOutCallback ) ) {
@@ -354,7 +367,7 @@ class WikiImporter {
 
        /**
         * Notify the callback function of a revision
-        * @param $revision WikiRevision object
+        * @param WikiRevision $revision
         * @return bool|mixed
         */
        private function revisionCallback( $revision ) {
@@ -368,7 +381,7 @@ class WikiImporter {
 
        /**
         * Notify the callback function of a new log item
-        * @param $revision WikiRevision object
+        * @param WikiRevision $revision
         * @return bool|mixed
         */
        private function logItemCallback( $revision ) {
@@ -380,6 +393,15 @@ class WikiImporter {
                }
        }
 
+       /**
+        * Retrieves the contents of the named attribute of the current element.
+        * @param string $attr The name of the attribute
+        * @return string The value of the attribute or an empty string if it is not set in the current element.
+        */
+       public function nodeAttribute( $attr ) {
+               return $this->reader->getAttribute( $attr );
+       }
+
        /**
         * Shouldn't something like this be built-in to XMLReader?
         * Fetches text contents of the current element, assuming
@@ -387,7 +409,7 @@ class WikiImporter {
         * @return string
         * @access private
         */
-       private function nodeContents() {
+       public function nodeContents() {
                if ( $this->reader->isEmptyElement ) {
                        return "";
                }
@@ -407,53 +429,12 @@ class WikiImporter {
                return '';
        }
 
-       # --------------
-
-       /** Left in for debugging */
-       private function dumpElement() {
-               static $lookup = null;
-               if ( !$lookup ) {
-                       $xmlReaderConstants = array(
-                               "NONE",
-                               "ELEMENT",
-                               "ATTRIBUTE",
-                               "TEXT",
-                               "CDATA",
-                               "ENTITY_REF",
-                               "ENTITY",
-                               "PI",
-                               "COMMENT",
-                               "DOC",
-                               "DOC_TYPE",
-                               "DOC_FRAGMENT",
-                               "NOTATION",
-                               "WHITESPACE",
-                               "SIGNIFICANT_WHITESPACE",
-                               "END_ELEMENT",
-                               "END_ENTITY",
-                               "XML_DECLARATION",
-                       );
-                       $lookup = array();
-
-                       foreach ( $xmlReaderConstants as $name ) {
-                               $lookup[constant( "XmlReader::$name" )] = $name;
-                       }
-               }
-
-               print var_dump(
-                       $lookup[$this->reader->nodeType],
-                       $this->reader->name,
-                       $this->reader->value
-               ) . "\n\n";
-       }
-
        /**
         * Primary entry point
         * @throws MWException
         * @return bool
         */
        public function doImport() {
-
                // Calls to reader->read need to be wrapped in calls to
                // libxml_disable_entity_loader() to avoid local file
                // inclusion attacks (bug 46932).
@@ -511,7 +492,7 @@ class WikiImporter {
        private function handleSiteInfo() {
                // Site info is useful, but not actually used for dump imports.
                // Includes a quick short-circuit to save performance.
-               if ( ! $this->mSiteInfoCallback ) {
+               if ( !$this->mSiteInfoCallback ) {
                        $this->reader->next();
                        return true;
                }
@@ -551,7 +532,7 @@ class WikiImporter {
        }
 
        /**
-        * @param $logInfo
+        * @param array $logInfo
         * @return bool|mixed
         */
        private function processLogItem( $logInfo ) {
@@ -605,17 +586,28 @@ class WikiImporter {
                                                &$pageInfo ) ) ) {
                                // Do nothing
                        } elseif ( in_array( $tag, $normalFields ) ) {
-                               $pageInfo[$tag] = $this->nodeContents();
-                               if ( $tag == 'title' ) {
-                                       $title = $this->processTitle( $pageInfo['title'] );
+                               // An XML snippet:
+                               // <page>
+                               //     <id>123</id>
+                               //     <title>Page</title>
+                               //     <redirect title="NewTitle"/>
+                               //     ...
+                               // Because the redirect tag is built differently, we need special handling for that case.
+                               if ( $tag == 'redirect' ) {
+                                       $pageInfo[$tag] = $this->nodeAttribute( 'title' );
+                               } else {
+                                       $pageInfo[$tag] = $this->nodeContents();
+                                       if ( $tag == 'title' ) {
+                                               $title = $this->processTitle( $pageInfo['title'] );
 
-                                       if ( !$title ) {
-                                               $badTitle = true;
-                                               $skip = true;
-                                       }
+                                               if ( !$title ) {
+                                                       $badTitle = true;
+                                                       $skip = true;
+                                               }
 
-                                       $this->pageCallback( $title );
-                                       list( $pageInfo['_title'], $origTitle ) = $title;
+                                               $this->pageCallback( $title );
+                                               list( $pageInfo['_title'], $origTitle ) = $title;
+                                       }
                                }
                        } elseif ( $tag == 'revision' ) {
                                $this->handleRevision( $pageInfo );
@@ -634,7 +626,7 @@ class WikiImporter {
        }
 
        /**
-        * @param $pageInfo array
+        * @param array $pageInfo
         */
        private function handleRevision( &$pageInfo ) {
                $this->debug( "Enter revision handler" );
@@ -673,8 +665,8 @@ class WikiImporter {
        }
 
        /**
-        * @param $pageInfo
-        * @param $revisionInfo
+        * @param array $pageInfo
+        * @param array $revisionInfo
         * @return bool|mixed
         */
        private function processRevision( $pageInfo, $revisionInfo ) {
@@ -683,9 +675,6 @@ class WikiImporter {
                if ( isset( $revisionInfo['id'] ) ) {
                        $revision->setID( $revisionInfo['id'] );
                }
-               if ( isset( $revisionInfo['text'] ) ) {
-                       $revision->setText( $revisionInfo['text'] );
-               }
                if ( isset( $revisionInfo['model'] ) ) {
                        $revision->setModel( $revisionInfo['model'] );
                }
@@ -694,6 +683,14 @@ class WikiImporter {
                }
                $revision->setTitle( $pageInfo['_title'] );
 
+               if ( isset( $revisionInfo['text'] ) ) {
+                       $handler = $revision->getContentHandler();
+                       $text = $handler->importTransform(
+                               $revisionInfo['text'],
+                               $revision->getFormat() );
+
+                       $revision->setText( $text );
+               }
                if ( isset( $revisionInfo['timestamp'] ) ) {
                        $revision->setTimestamp( $revisionInfo['timestamp'] );
                } else {
@@ -719,7 +716,7 @@ class WikiImporter {
        }
 
        /**
-        * @param $pageInfo
+        * @param array $pageInfo
         * @return mixed
         */
        private function handleUpload( &$pageInfo ) {
@@ -774,7 +771,7 @@ class WikiImporter {
        }
 
        /**
-        * @param $contents
+        * @param string $contents
         * @return string
         */
        private function dumpTemp( $contents ) {
@@ -784,8 +781,8 @@ class WikiImporter {
        }
 
        /**
-        * @param $pageInfo
-        * @param $uploadInfo
+        * @param array $pageInfo
+        * @param array $uploadInfo
         * @return mixed
         */
        private function processUpload( $pageInfo, $uploadInfo ) {
@@ -846,8 +843,8 @@ class WikiImporter {
        }
 
        /**
-        * @param $text string
-        * @return Array or false
+        * @param string $text
+        * @return array|bool
         */
        private function processTitle( $text ) {
                global $wgCommandLineMode;
@@ -893,17 +890,23 @@ class WikiImporter {
 
 /** This is a horrible hack used to keep source compatibility */
 class UploadSourceAdapter {
-       static $sourceRegistrations = array();
+       /** @var array */
+       private static $sourceRegistrations = array();
 
+       /** @var string */
        private $mSource;
+
+       /** @var string */
        private $mBuffer;
+
+       /** @var int */
        private $mPosition;
 
        /**
-        * @param $source
+        * @param ImportStreamSource $source
         * @return string
         */
-       static function registerSource( $source ) {
+       static function registerSource( ImportStreamSource $source ) {
                $id = wfRandomString();
 
                self::$sourceRegistrations[$id] = $source;
@@ -912,10 +915,10 @@ class UploadSourceAdapter {
        }
 
        /**
-        * @param $path
-        * @param $mode
-        * @param $options
-        * @param $opened_path
+        * @param string $path
+        * @param string $mode
+        * @param array $options
+        * @param string $opened_path
         * @return bool
         */
        function stream_open( $path, $mode, $options, &$opened_path ) {
@@ -932,7 +935,7 @@ class UploadSourceAdapter {
        }
 
        /**
-        * @param $count
+        * @param int $count
         * @return string
         */
        function stream_read( $count ) {
@@ -961,7 +964,7 @@ class UploadSourceAdapter {
        }
 
        /**
-        * @param $data
+        * @param string $data
         * @return bool
         */
        function stream_write( $data ) {
@@ -1006,84 +1009,114 @@ class UploadSourceAdapter {
        }
 }
 
-class XMLReader2 extends XMLReader {
-
-       /**
-        * @return bool|string
-        */
-       function nodeContents() {
-               if ( $this->isEmptyElement ) {
-                       return "";
-               }
-               $buffer = "";
-               while ( $this->read() ) {
-                       switch ( $this->nodeType ) {
-                       case XmlReader::TEXT:
-                       case XmlReader::SIGNIFICANT_WHITESPACE:
-                               $buffer .= $this->value;
-                               break;
-                       case XmlReader::END_ELEMENT:
-                               return $buffer;
-                       }
-               }
-               return $this->close();
-       }
-}
-
 /**
  * @todo document (e.g. one-sentence class description).
  * @ingroup SpecialPage
  */
 class WikiRevision {
-       var $importer = null;
-
-       /**
-        * @var Title
-        */
-       var $title = null;
-       var $id = 0;
-       var $timestamp = "20010115000000";
-       var $user = 0;
-       var $user_text = "";
-       var $model = null;
-       var $format = null;
-       var $text = "";
-       var $content = null;
-       var $comment = "";
-       var $minor = false;
-       var $type = "";
-       var $action = "";
-       var $params = "";
-       var $fileSrc = '';
-       var $sha1base36 = false;
-       var $isTemp = false;
-       var $archiveName = '';
-       var $fileIsTemp;
+       /** @todo Unused? */
+       private $importer = null;
+
+       /** @var Title */
+       public $title = null;
+
+       /** @var int */
+       private $id = 0;
+
+       /** @var string */
+       public $timestamp = "20010115000000";
+
+       /**
+        * @var int
+        * @todo Can't find any uses. Public, because that's suspicious. Get clarity. */
+       public $user = 0;
+
+       /** @var string */
+       public $user_text = "";
+
+       /** @var string */
+       protected $model = null;
+
+       /** @var string */
+       protected $format = null;
+
+       /** @var string */
+       public $text = "";
+
+       /** @var int */
+       protected $size;
+
+       /** @var Content */
+       protected $content = null;
+
+       /** @var ContentHandler */
+       protected $contentHandler = null;
+
+       /** @var string */
+       public $comment = "";
+
+       /** @var bool */
+       protected $minor = false;
+
+       /** @var string */
+       protected $type = "";
+
+       /** @var string */
+       protected $action = "";
+
+       /** @var string */
+       protected $params = "";
+
+       /** @var string */
+       protected $fileSrc = '';
+
+       /** @var bool|string */
+       protected $sha1base36 = false;
+
+       /**
+        * @var bool
+        * @todo Unused?
+        */
+       private $isTemp = false;
+
+       /** @var string */
+       protected $archiveName = '';
+
+       protected $filename;
+
+       /** @var mixed */
+       protected $src;
+
+       /** @todo Unused? */
+       private $fileIsTemp;
+
+       /** @var bool */
        private $mNoUpdates = false;
 
        /**
-        * @param $title
+        * @param Title $title
         * @throws MWException
         */
        function setTitle( $title ) {
                if ( is_object( $title ) ) {
                        $this->title = $title;
                } elseif ( is_null( $title ) ) {
-                       throw new MWException( "WikiRevision given a null title in import. You may need to adjust \$wgLegalTitleChars." );
+                       throw new MWException( "WikiRevision given a null title in import. "
+                               . "You may need to adjust \$wgLegalTitleChars." );
                } else {
                        throw new MWException( "WikiRevision given non-object title in import." );
                }
        }
 
        /**
-        * @param $id
+        * @param int $id
         */
        function setID( $id ) {
                $this->id = $id;
        }
 
        /**
-        * @param $ts
+        * @param string $ts
         */
        function setTimestamp( $ts ) {
                # 2003-08-05T18:30:02Z
@@ -1091,64 +1124,64 @@ class WikiRevision {
        }
 
        /**
-        * @param $user
+        * @param string $user
         */
        function setUsername( $user ) {
                $this->user_text = $user;
        }
 
        /**
-        * @param $ip
+        * @param string $ip
         */
        function setUserIP( $ip ) {
                $this->user_text = $ip;
        }
 
        /**
-        * @param $model
+        * @param string $model
         */
        function setModel( $model ) {
                $this->model = $model;
        }
 
        /**
-        * @param $format
+        * @param string $format
         */
        function setFormat( $format ) {
                $this->format = $format;
        }
 
        /**
-        * @param $text
+        * @param string $text
         */
        function setText( $text ) {
                $this->text = $text;
        }
 
        /**
-        * @param $text
+        * @param string $text
         */
        function setComment( $text ) {
                $this->comment = $text;
        }
 
        /**
-        * @param $minor
+        * @param bool $minor
         */
        function setMinor( $minor ) {
                $this->minor = (bool)$minor;
        }
 
        /**
-        * @param $src
+        * @param mixed $src
         */
        function setSrc( $src ) {
                $this->src = $src;
        }
 
        /**
-        * @param $src
-        * @param $isTemp
+        * @param string $src
+        * @param bool $isTemp
         */
        function setFileSrc( $src, $isTemp ) {
                $this->fileSrc = $src;
@@ -1156,56 +1189,56 @@ class WikiRevision {
        }
 
        /**
-        * @param $sha1base36
+        * @param string $sha1base36
         */
        function setSha1Base36( $sha1base36 ) {
                $this->sha1base36 = $sha1base36;
        }
 
        /**
-        * @param $filename
+        * @param string $filename
         */
        function setFilename( $filename ) {
                $this->filename = $filename;
        }
 
        /**
-        * @param $archiveName
+        * @param string $archiveName
         */
        function setArchiveName( $archiveName ) {
                $this->archiveName = $archiveName;
        }
 
        /**
-        * @param $size
+        * @param int $size
         */
        function setSize( $size ) {
                $this->size = intval( $size );
        }
 
        /**
-        * @param $type
+        * @param string $type
         */
        function setType( $type ) {
                $this->type = $type;
        }
 
        /**
-        * @param $action
+        * @param string $action
         */
        function setAction( $action ) {
                $this->action = $action;
        }
 
        /**
-        * @param $params
+        * @param array $params
         */
        function setParams( $params ) {
                $this->params = $params;
        }
 
        /**
-        * @param $noupdates
+        * @param bool $noupdates
         */
        public function setNoUpdates( $noupdates ) {
                $this->mNoUpdates = $noupdates;
@@ -1250,25 +1283,31 @@ class WikiRevision {
                return $this->text;
        }
 
+       /**
+        * @return ContentHandler
+        */
+       function getContentHandler() {
+               if ( is_null( $this->contentHandler ) ) {
+                       $this->contentHandler = ContentHandler::getForModelID( $this->getModel() );
+               }
+
+               return $this->contentHandler;
+       }
+
        /**
         * @return Content
         */
        function getContent() {
                if ( is_null( $this->content ) ) {
-                       $this->content =
-                               ContentHandler::makeContent(
-                                       $this->text,
-                                       $this->getTitle(),
-                                       $this->getModel(),
-                                       $this->getFormat()
-                               );
+                       $handler = $this->getContentHandler();
+                       $this->content = $handler->unserializeContent( $this->text, $this->getFormat() );
                }
 
                return $this->content;
        }
 
        /**
-        * @return String
+        * @return string
         */
        function getModel() {
                if ( is_null( $this->model ) ) {
@@ -1279,11 +1318,11 @@ class WikiRevision {
        }
 
        /**
-        * @return String
+        * @return string
         */
        function getFormat() {
-               if ( is_null( $this->model ) ) {
-                       $this->format = ContentHandler::getForTitle( $this->getTitle() )->getDefaultFormat();
+               if ( is_null( $this->format ) ) {
+                       $this->format = $this->getContentHandler()->getDefaultFormat();
                }
 
                return $this->format;
@@ -1311,7 +1350,7 @@ class WikiRevision {
        }
 
        /**
-        * @return bool|String
+        * @return bool|string
         */
        function getSha1() {
                if ( $this->sha1base36 ) {
@@ -1399,6 +1438,7 @@ class WikiRevision {
                $linkCache->clear();
 
                $page = WikiPage::factory( $this->title );
+               $page->loadPageData( 'fromdbmaster' );
                if ( !$page->exists() ) {
                        # must create the page...
                        $pageId = $page->insertOn( $dbw );
@@ -1431,7 +1471,8 @@ class WikiRevision {
                        'page' => $pageId,
                        'content_model' => $this->getModel(),
                        'content_format' => $this->getFormat(),
-                       'text' => $this->getContent()->serialize( $this->getFormat() ), //XXX: just set 'content' => $this->getContent()?
+                       //XXX: just set 'content' => $this->getContent()?
+                       'text' => $this->getContent()->serialize( $this->getFormat() ),
                        'comment' => $this->getComment(),
                        'user' => $userId,
                        'user_text' => $userText,
@@ -1443,7 +1484,11 @@ class WikiRevision {
 
                if ( $changed !== false && !$this->mNoUpdates ) {
                        wfDebug( __METHOD__ . ": running updates\n" );
-                       $page->doEditUpdates( $revision, $userObj, array( 'created' => $created, 'oldcountable' => $oldcountable ) );
+                       $page->doEditUpdates(
+                               $revision,
+                               $userObj,
+                               array( 'created' => $created, 'oldcountable' => $oldcountable )
+                       );
                }
 
                return true;
@@ -1475,8 +1520,9 @@ class WikiRevision {
                );
                // @todo FIXME: This could fail slightly for multiple matches :P
                if ( $prior ) {
-                       wfDebug( __METHOD__ . ": skipping existing item for Log:{$this->type}/{$this->action}, timestamp " .
-                               $this->timestamp . "\n" );
+                       wfDebug( __METHOD__
+                               . ": skipping existing item for Log:{$this->type}/{$this->action}, timestamp "
+                               . $this->timestamp . "\n" );
                        return;
                }
                $log_id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
@@ -1648,7 +1694,7 @@ class ImportStreamSource {
        }
 
        /**
-        * @param $filename string
+        * @param string $filename
         * @return Status
         */
        static function newFromFile( $filename ) {
@@ -1662,7 +1708,7 @@ class ImportStreamSource {
        }
 
        /**
-        * @param $fieldname string
+        * @param string $fieldname
         * @return Status
         */
        static function newFromUpload( $fieldname = "xmlimport" ) {
@@ -1673,13 +1719,18 @@ class ImportStreamSource {
                }
                if ( !empty( $upload['error'] ) ) {
                        switch ( $upload['error'] ) {
-                               case 1: # The uploaded file exceeds the upload_max_filesize directive in php.ini.
+                               case 1:
+                                       # The uploaded file exceeds the upload_max_filesize directive in php.ini.
                                        return Status::newFatal( 'importuploaderrorsize' );
-                               case 2: # The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
+                               case 2:
+                                       # The uploaded file exceeds the MAX_FILE_SIZE directive that
+                                       # was specified in the HTML form.
                                        return Status::newFatal( 'importuploaderrorsize' );
-                               case 3: # The uploaded file was only partially uploaded
+                               case 3:
+                                       # The uploaded file was only partially uploaded
                                        return Status::newFatal( 'importuploaderrorpartial' );
-                               case 6: #Missing a temporary folder.
+                               case 6:
+                                       # Missing a temporary folder.
                                        return Status::newFatal( 'importuploaderrortemp' );
                                # case else: # Currently impossible
                        }
@@ -1694,8 +1745,8 @@ class ImportStreamSource {
        }
 
        /**
-        * @param $url
-        * @param $method string
+        * @param string $url
+        * @param string $method
         * @return Status
         */
        static function newFromURL( $url, $method = 'GET' ) {
@@ -1717,14 +1768,16 @@ class ImportStreamSource {
        }
 
        /**
-        * @param $interwiki
-        * @param $page
-        * @param $history bool
-        * @param $templates bool
-        * @param $pageLinkDepth int
+        * @param string $interwiki
+        * @param string $page
+        * @param bool $history
+        * @param bool $templates
+        * @param int $pageLinkDepth
         * @return Status
         */
-       public static function newFromInterwiki( $interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0 ) {
+       public static function newFromInterwiki( $interwiki, $page, $history = false,
+               $templates = false, $pageLinkDepth = 0
+       ) {
                if ( $page == '' ) {
                        return Status::newFatal( 'import-noarticle' );
                }