X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOutputPage.php;h=f161cb37c38047a77f89d121276067a11d8c9b63;hb=56172358dcbf1e8ee9ba615d65ff798fee0de118;hp=3adef5b2515411ddffd857a068beb02a24982ac1;hpb=ff20437da7bed879299d94329cd9c9091fe033ba;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 3adef5b251..f161cb37c3 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1573,11 +1573,42 @@ class OutputPage extends ContextSource { * @return ParserOptions */ public function parserOptions( $options = null ) { + if ( $options !== null && !empty( $options->isBogus ) ) { + // Someone is trying to set a bogus pre-$wgUser PO. Check if it has + // been changed somehow, and keep it if so. + $anonPO = ParserOptions::newFromAnon(); + $anonPO->setEditSection( false ); + if ( !$options->matches( $anonPO ) ) { + wfLogWarning( __METHOD__ . ': Setting a changed bogus ParserOptions: ' . wfGetAllCallers( 5 ) ); + $options->isBogus = false; + } + } + if ( !$this->mParserOptions ) { + if ( !$this->getContext()->getUser()->isSafeToLoad() ) { + // $wgUser isn't unstubbable yet, so don't try to get a + // ParserOptions for it. And don't cache this ParserOptions + // either. + $po = ParserOptions::newFromAnon(); + $po->setEditSection( false ); + $po->isBogus = true; + if ( $options !== null ) { + $this->mParserOptions = empty( $options->isBogus ) ? $options : null; + } + return $po; + } + $this->mParserOptions = ParserOptions::newFromContext( $this->getContext() ); $this->mParserOptions->setEditSection( false ); } - return wfSetVar( $this->mParserOptions, $options ); + + if ( $options !== null && !empty( $options->isBogus ) ) { + // They're trying to restore the bogus pre-$wgUser PO. Do the right + // thing. + return wfSetVar( $this->mParserOptions, null, true ); + } else { + return wfSetVar( $this->mParserOptions, $options ); + } } /** @@ -4057,5 +4088,8 @@ class OutputPage extends ContextSource { 'oojs-ui.styles.textures', 'mediawiki.widgets.styles', ) ); + // Used by 'skipFunction' of the four 'oojs-ui.styles.*' modules. Please don't treat this as a + // public API or you'll be severely disappointed when T87871 is fixed and it disappears. + $this->addMeta( 'X-OOUI-PHP', '1' ); } }