fix handling of per-revision content model if different from title's default content...
[lhc/web/wiklou.git] / includes / WikiPage.php
index 4638546..6105637 100644 (file)
@@ -353,8 +353,8 @@ class WikiPage extends Page {
     public function getContentModelName() {
         if ( $this->exists() ) {
             # look at the revision's actual content model
-            $content = $this->getContent();
-            return $content->getModelName();
+            $rev = $this->getRevision();
+            return $rev->getContentModelName();
         } else {
             # use the default model for this page
             return $this->mTitle->getContentModelName();
@@ -448,7 +448,7 @@ class WikiPage extends Page {
         if ( $this->mLastRevision ) {
             return $this->mLastRevision->getContent( $audience );
         }
-        return false;
+        return null;
     }
 
        /**
@@ -1384,7 +1384,7 @@ class WikiPage extends Page {
 
             if ( $txt !== $content_text ) {
                 # if the text changed, unserialize the new version to create an updated Content object.
-                $content = $content->getContentHandler()->unserialize( $txt );
+                $content = $content->getContentHandler()->unserializeContent( $txt );
             }
         }
 
@@ -1687,7 +1687,11 @@ class WikiPage extends Page {
         $edit->format = $serialization_format;
 
                $edit->popts = $this->makeParserOptions( 'canonical' );
-               $edit->output = $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts );
+
+               // TODO: is there no better way to obtain a context here?
+               $context = RequestContext::getMain();
+               $context->setTitle( $this->mTitle );
+               $edit->output = $edit->pstContent->getParserOutput( $context, $revid, $edit->popts );
 
         $edit->newContent = $content;
                $edit->oldContent = $this->getContent( Revision::RAW );
@@ -1742,7 +1746,7 @@ class WikiPage extends Page {
                }
 
                # Update the links tables and other secondary data
-        $updates = $editInfo->output->getLinksUpdateAndOtherUpdates( $this->mTitle );
+        $updates = $editInfo->output->getSecondaryDataUpdates( $this->mTitle );
         SecondaryDataUpdate::runUpdates( $updates );
 
                wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) );
@@ -2267,6 +2271,8 @@ class WikiPage extends Page {
 
                $this->updateCategoryCounts( array(), $cats );
 
+        #TODO: move this to an Update object!
+
                # If using cascading deletes, we can skip some explicit deletes
                if ( !$dbw->cascadingDeletes() ) {
                        $dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ );
@@ -2627,8 +2633,8 @@ class WikiPage extends Page {
                # NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't.
 
         $handler = ContentHandler::getForModelName( CONTENT_MODEL_WIKITEXT );
-        $oldContent = $oldtext ? $handler->unserialize( $oldtext ) : null;
-        $newContent = $newtext ? $handler->unserialize( $newtext ) : null;
+        $oldContent = $oldtext ? $handler->unserializeContent( $oldtext ) : null;
+        $newContent = $newtext ? $handler->unserializeContent( $newtext ) : null;
 
         return $handler->getAutosummary( $oldContent, $newContent, $flags );
        }
@@ -3088,7 +3094,8 @@ class PoolWorkArticleView extends PoolCounterWork {
                }
 
                $time = - microtime( true );
-               $this->parserOutput = $content->getParserOutput( $this->page->getTitle(), $this->revid, $this->parserOptions );
+               // TODO: page might not have this method? Hard to tell what page is supposed to be here...
+               $this->parserOutput = $content->getParserOutput( $this->page->getContext(), $this->revid, $this->parserOptions );
                $time += microtime( true );
 
                # Timing hack