X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImport.php;h=bd9ce25cbca53d98d8541d8d41c1826ecd08b28c;hb=81ea9d1492c296902e9325f3b571cc4e5b39a272;hp=5f59b1c12248ccc99c97e156394b0815cae8d1ee;hpb=12166f46b4d63d3fd3cab68cf4c7090a1646dd09;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Import.php b/includes/Import.php index 5f59b1c122..bd9ce25cbc 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -252,8 +252,16 @@ class WikiImporter { * @return bool */ public function importRevision( $revision ) { - $dbw = wfGetDB( DB_MASTER ); - return $dbw->deadlockLoop( array( $revision, 'importOldRevision' ) ); + try { + $dbw = wfGetDB( DB_MASTER ); + return $dbw->deadlockLoop( array( $revision, 'importOldRevision' ) ); + } catch ( MWContentSerializationException $ex ) { + $this->notice( 'import-error-unserialize', + $revision->getTitle()->getPrefixedText(), + $revision->getID(), + $revision->getModel(), + $revision->getFormat() ); + } } /** @@ -429,6 +437,7 @@ class WikiImporter { /** * Primary entry point + * @throws MWException * @return bool */ public function doImport() { @@ -659,7 +668,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 +1026,7 @@ class WikiRevision { var $model = null; var $format = null; var $text = ""; + var $content = null; var $comment = ""; var $minor = false; var $type = ""; @@ -1209,11 +1219,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 +1405,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,