From: daniel Date: Mon, 6 Aug 2012 13:55:52 +0000 (+0200) Subject: add Article::setParserOptions X-Git-Tag: 1.31.0-rc.0~22097^2^2~61^2 X-Git-Url: https://git.cyclocoop.org/?a=commitdiff_plain;h=30d416f1c480afdbf5458a0e45bf88fb88213367;p=lhc%2Fweb%2Fwiklou.git add Article::setParserOptions Change-Id: Ica1c0a3c4b5b569c4911d4c1fb0167812f932c20 --- 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