From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- includes/content/Content.php | 14 +++++++------- includes/content/ContentHandler.php | 19 ++++++++++--------- includes/content/CssContent.php | 2 +- includes/content/JavaScriptContent.php | 2 +- includes/content/TextContent.php | 2 +- includes/content/WikitextContent.php | 3 ++- includes/content/WikitextContentHandler.php | 19 +++++++++++++++++-- 7 files changed, 39 insertions(+), 22 deletions(-) (limited to 'includes/content') diff --git a/includes/content/Content.php b/includes/content/Content.php index 72729b09..5a90e092 100644 --- a/includes/content/Content.php +++ b/includes/content/Content.php @@ -40,8 +40,8 @@ interface Content { * building a full text search index. If no useful representation exists, * this method returns an empty string. * - * @todo: test that this actually works - * @todo: make sure this also works with LuceneSearch / WikiSearch + * @todo Test that this actually works + * @todo Make sure this also works with LuceneSearch / WikiSearch */ public function getTextForSearchIndex(); @@ -51,11 +51,11 @@ interface Content { * @return string|false The wikitext to include when another page includes this * content, or false if the content is not includable in a wikitext page. * - * @todo allow native handling, bypassing wikitext representation, like - * for includable special pages. - * @todo allow transclusion into other content models than Wikitext! - * @todo used in WikiPage and MessageCache to get message text. Not so - * nice. What should we use instead?! + * @todo Allow native handling, bypassing wikitext representation, like + * for includable special pages. + * @todo Allow transclusion into other content models than Wikitext! + * @todo Used in WikiPage and MessageCache to get message text. Not so + * nice. What should we use instead?! */ public function getWikitextForTransclusion(); diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index 9c201955..2a92e233 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -319,7 +319,7 @@ abstract class ContentHandler { wfRunHooks( 'ContentHandlerForModelID', array( $modelId, &$handler ) ); if ( $handler === null ) { - throw new MWException( "No handler for model '$modelId'' registered in \$wgContentHandlers" ); + throw new MWException( "No handler for model '$modelId' registered in \$wgContentHandlers" ); } if ( !( $handler instanceof ContentHandler ) ) { @@ -449,10 +449,11 @@ abstract class ContentHandler { * @since 1.21 * * @param Title $destination the page to redirect to. + * @param string $text text to include in the redirect, if possible. * * @return Content */ - public function makeRedirectContent( Title $destination ) { + public function makeRedirectContent( Title $destination, $text = '' ) { return null; } @@ -937,7 +938,7 @@ abstract class ContentHandler { * @return ParserOptions */ public function makeParserOptions( $context ) { - global $wgContLang; + global $wgContLang, $wgEnableParserLimitReporting; if ( $context instanceof IContextSource ) { $options = ParserOptions::newFromContext( $context ); @@ -949,7 +950,7 @@ abstract class ContentHandler { throw new MWException( "Bad context for parser options: $context" ); } - $options->enableLimitReport(); // show inclusion/loop reports + $options->enableLimitReport( $wgEnableParserLimitReporting ); // show inclusion/loop reports $options->setTidy( true ); // fix bad HTML return $options; @@ -1060,7 +1061,7 @@ abstract class ContentHandler { if ( isset( $handler[1] ) ) { $info .= '::' . $handler[1]; } - } else if ( is_object( $handler ) ) { + } elseif ( is_object( $handler ) ) { $info = get_class( $handler[0] ); $info .= '::on' . $event; } else { @@ -1086,8 +1087,8 @@ abstract class ContentHandler { $contentObjects[$k] = $v; $v = $v->serialize(); - $contentTexts[ $k ] = $v; - $args[ $k ] = $v; + $contentTexts[$k] = $v; + $args[$k] = $v; } } @@ -1098,7 +1099,7 @@ abstract class ContentHandler { foreach ( $contentTexts as $k => $orig ) { /* @var Content $content */ - $modified = $args[ $k ]; + $modified = $args[$k]; $content = $contentObjects[$k]; if ( $modified !== $orig ) { @@ -1106,7 +1107,7 @@ abstract class ContentHandler { $content = $content->getContentHandler()->unserializeContent( $modified ); } - $args[ $k ] = $content; + $args[$k] = $content; } return $ok; diff --git a/includes/content/CssContent.php b/includes/content/CssContent.php index 569d122d..03cc2d00 100644 --- a/includes/content/CssContent.php +++ b/includes/content/CssContent.php @@ -46,7 +46,7 @@ class CssContent extends TextContent { */ public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) { global $wgParser; - // @todo: make pre-save transformation optional for script pages + // @todo Make pre-save transformation optional for script pages $text = $this->getNativeData(); $pst = $wgParser->preSaveTransform( $text, $title, $user, $popts ); diff --git a/includes/content/JavaScriptContent.php b/includes/content/JavaScriptContent.php index 9cd947f9..2ae572be 100644 --- a/includes/content/JavaScriptContent.php +++ b/includes/content/JavaScriptContent.php @@ -46,7 +46,7 @@ class JavaScriptContent extends TextContent { */ public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) { global $wgParser; - // @todo: make pre-save transformation optional for script pages + // @todo Make pre-save transformation optional for script pages // See bug #32858 $text = $this->getNativeData(); diff --git a/includes/content/TextContent.php b/includes/content/TextContent.php index 8fafcb63..f66dacd7 100644 --- a/includes/content/TextContent.php +++ b/includes/content/TextContent.php @@ -171,7 +171,7 @@ class TextContent extends AbstractContent { $this->checkModelID( $that->getModel() ); - # @todo: could implement this in DifferenceEngine and just delegate here? + // @todo could implement this in DifferenceEngine and just delegate here? if ( !$lang ) { $lang = $wgContLang; diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php index 8be4ebab..26337db9 100644 --- a/includes/content/WikitextContent.php +++ b/includes/content/WikitextContent.php @@ -61,7 +61,8 @@ class WikitextContent extends TextContent { $myModelId = $this->getModel(); $sectionModelId = $with->getModel(); - if ( $sectionModelId != $myModelId ) { + if ( $sectionModelId != $myModelId ) { + wfProfileOut( __METHOD__ ); throw new MWException( "Incompatible content model for section: " . "document uses $myModelId but " . "section uses $sectionModelId." ); diff --git a/includes/content/WikitextContentHandler.php b/includes/content/WikitextContentHandler.php index e1dcc668..b1b461fb 100644 --- a/includes/content/WikitextContentHandler.php +++ b/includes/content/WikitextContentHandler.php @@ -55,12 +55,27 @@ class WikitextContentHandler extends TextContentHandler { * @see ContentHandler::makeRedirectContent * * @param Title $destination the page to redirect to. + * @param string $text text to include in the redirect, if possible. * * @return Content */ - public function makeRedirectContent( Title $destination ) { + public function makeRedirectContent( Title $destination, $text = '' ) { + $optionalColon = ''; + + if ( $destination->getNamespace() == NS_CATEGORY ) { + $optionalColon = ':'; + } else { + $iw = $destination->getInterwiki(); + if ( $iw && Language::fetchLanguageName( $iw, null, 'mw' ) ) { + $optionalColon = ':'; + } + } + $mwRedir = MagicWord::get( 'redirect' ); - $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $destination->getPrefixedText() . ']]'; + $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $optionalColon . $destination->getFullText() . ']]'; + if ( $text != '' ) { + $redirectText .= "\n" . $text; + } return new WikitextContent( $redirectText ); } -- cgit v1.2.3-54-g00ecf