From 30d416f1c480afdbf5458a0e45bf88fb88213367 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 6 Aug 2012 15:55:52 +0200 Subject: [PATCH] add Article::setParserOptions Change-Id: Ica1c0a3c4b5b569c4911d4c1fb0167812f932c20 --- includes/Article.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/includes/Article.php b/includes/Article.php index ec05491c58..6b2bd4c788 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1699,11 +1699,25 @@ class Article extends Page { */ public function getParserOutput( $oldid = null, User $user = null ) { $user = is_null( $user ) ? $this->getContext()->getUser() : $user; - $parserOptions = $this->mPage->makeParserOptions( $user ); + $parserOptions = $this->mPage->makeParserOptions( $user ); //XXX: bypasses mParserOptions and thus setParserOptions() return $this->mPage->getParserOutput( $parserOptions, $oldid ); } + /** + * Override the ParserOptions used to render the primary article wikitext. + * + * @param ParserOptions $options + * @throws MWException if the parser options where already initialized. + */ + public function setParserOptions( ParserOptions $options ) { + if ( $this->mParserOptions ) { + throw new MWException( "can't change parser options after they have already been set" ); + } + + $this->mParserOptions = clone $options; // clone, so if $options is modified later, it doesn't confuse the parser cache. + } + /** * Get parser options suitable for rendering the primary article wikitext * @return ParserOptions -- 2.20.1