Merge "Implement static public Parser::getExternalLinkRel"
[lhc/web/wiklou.git] / includes / Import.php
index 5f59b1c..2017466 100644 (file)
@@ -429,6 +429,7 @@ class WikiImporter {
 
        /**
         * Primary entry point
+        * @throws MWException
         * @return bool
         */
        public function doImport() {
@@ -659,7 +660,7 @@ class WikiImporter {
                if ( isset( $revisionInfo['model'] ) ) {
                        $revision->setModel( $revisionInfo['model'] );
                }
-               if ( isset( $revisionInfo['text'] ) ) {
+               if ( isset( $revisionInfo['format'] ) ) {
                        $revision->setFormat( $revisionInfo['format'] );
                }
                $revision->setTitle( $pageInfo['_title'] );
@@ -1017,6 +1018,7 @@ class WikiRevision {
        var $model = null;
        var $format = null;
        var $text = "";
+       var $content = null;
        var $comment = "";
        var $minor = false;
        var $type = "";
@@ -1209,11 +1211,32 @@ class WikiRevision {
 
        /**
         * @return string
+        *
+        * @deprecated Since 1.21, use getContent() instead.
         */
        function getText() {
+               ContentHandler::deprecated( __METHOD__, '1.21' );
+
                return $this->text;
        }
 
+       /**
+        * @return Content
+        */
+       function getContent() {
+               if ( is_null( $this->content ) ) {
+                       $this->content =
+                               ContentHandler::makeContent(
+                                       $this->text,
+                                       $this->getTitle(),
+                                       $this->getModel(),
+                                       $this->getFormat()
+                               );
+               }
+
+               return $this->content;
+       }
+
        /**
         * @return String
         */
@@ -1374,10 +1397,11 @@ class WikiRevision {
                # @todo FIXME: Use original rev_id optionally (better for backups)
                # Insert the row
                $revision = new Revision( array(
+                       'title'      => $this->title,
                        'page'       => $pageId,
                        'content_model'  => $this->getModel(),
                        'content_format' => $this->getFormat(),
-                       'text'       => $this->getText(),
+                       'text'       => $this->getContent()->serialize( $this->getFormat() ), //XXX: just set 'content' => $this->getContent()?
                        'comment'    => $this->getComment(),
                        'user'       => $userId,
                        'user_text'  => $userText,