Merge branch 'Wikidata' of ssh://gerrit.wikimedia.org:29418/mediawiki/core into Wikidata
authordaniel <daniel.kinzler@wikimedia.de>
Tue, 17 Apr 2012 16:09:17 +0000 (18:09 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Tue, 17 Apr 2012 16:09:17 +0000 (18:09 +0200)
includes/Article.php
includes/Content.php
includes/ContentHandler.php
includes/EditPage.php
includes/WikiPage.php

index 31c0ac4..dbdae4c 100644 (file)
@@ -638,7 +638,7 @@ class Article extends Page {
                                                        # Viewing a redirect page (e.g. with parameter redirect=no)
                                                        $wgOut->addHTML( $this->viewRedirect( $rt ) );
                                                        # Parse just to get categories, displaytitle, etc.
-                                                       $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid, $parserOptions, false );
+                                                       $this->mParserOutput = $content->getParserOutput( $this->getContext(), $oldid, $parserOptions, false );
                                                        $wgOut->addParserOutputNoText( $this->mParserOutput );
                                                        $outputDone = true;
                                                }
index 55859da..8c9686f 100644 (file)
@@ -207,7 +207,7 @@ abstract class Content {
     public abstract function isCountable( $hasLinks = null ) ;
 
     /**
-     * @param null|Title $title
+     * @param IContextSource $context
      * @param null $revId
      * @param null|ParserOptions $options
      * @param Boolean $generateHtml whether to generate Html (default: true). If false,
@@ -216,7 +216,7 @@ abstract class Content {
      *
      * @return ParserOutput
      */
-    public abstract function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = NULL, $generateHtml = true );
+    public abstract function getParserOutput( IContextSource $context, $revId = null, ParserOptions $options = NULL, $generateHtml = true );
 
     /**
      * Construct the redirect destination from this content and return an
@@ -420,7 +420,7 @@ abstract class TextContent extends Content {
      *
      * @return ParserOutput representing the HTML form of the text
      */
-    public function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
+    public function getParserOutput( IContextSource $context, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
         # generic implementation, relying on $this->getHtml()
 
         if ( $generateHtml ) $html = $this->getHtml( $options );
@@ -458,18 +458,25 @@ class WikitextContent extends TextContent {
     }
 
     /**
-     * Returns a ParserOutput object reesulting from parsing the content's text using $wgParser
-     *
-     * @return ParserOutput representing the HTML form of the text
-     */
-    public function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
+        * Returns a ParserOutput object resulting from parsing the content's text using $wgParser.
+        *
+        * @since WikiData1
+        *
+        * @param IContextSource|null $context
+        * @param null $revId
+        * @param null|ParserOptions $options
+        * @param bool $generateHtml
+        *
+        * @return ParserOutput representing the HTML form of the text
+        */
+    public function getParserOutput( IContextSource $context = null, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
         global $wgParser;
 
         if ( !$options ) {
             $options = $this->getDefaultParserOptions();
         }
 
-        $po = $wgParser->parse( $this->mText, $title, $options, true, true, $revId );
+        $po = $wgParser->parse( $this->mText, $context->getTitle(), $options, true, true, $revId );
 
         return $po;
     }
index d03bdca..8f3c6ee 100644 (file)
@@ -357,7 +357,7 @@ abstract class ContentHandler {
      * Returns overrides for action handlers.
      * Classes listed here will be used instead of the default one when
      * (and only when) $wgActions[$action] === true. This allows subclasses
-     * to override the default actiuon handlers.
+     * to override the default action handlers.
      *
      * @return Array
      */
index 2e202ed..a0cf421 100644 (file)
@@ -2794,7 +2794,9 @@ HTML
 
                 #XXX: For CSS/JS pages, we should have called the ShowRawCssJs hook here. But it's now deprecated, so never mind
                 $content = $content->preSaveTransform( $this->mTitle, $wgUser, $parserOptions );
-                $parserOutput = $content->getParserOutput( $this->mTitle, null, $parserOptions );
+
+                               // TODO: might be a saner way to get a meaningfull context here?
+                $parserOutput = $content->getParserOutput( $this->getArticle()->getContext(), null, $parserOptions );
 
                 $previewHTML = $parserOutput->getText();
                 $this->mParserOutput = $parserOutput;
index 54827ed..17ce936 100644 (file)
@@ -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 );
@@ -3088,7 +3092,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