Use ParserOptions::newFromContext in MessageCache

The context is already called, just reuse it.
This avoids unstub of $wgLang in ParserOptions constructor

Change-Id: I3ac6abf6237db7c1c09740c1fec1224779e86888
This commit is contained in:
Umherirrender 2021-10-27 00:10:36 +02:00
parent fdaf95c524
commit 43a1a61c1e

View file

@ -204,7 +204,8 @@ class MessageCache implements LoggerAwareInterface {
*/ */
private function getParserOptions() { private function getParserOptions() {
if ( !$this->mParserOptions ) { if ( !$this->mParserOptions ) {
$user = RequestContext::getMain()->getUser(); $context = RequestContext::getMain();
$user = $context->getUser();
if ( !$user->isSafeToLoad() ) { if ( !$user->isSafeToLoad() ) {
// It isn't safe to use the context user yet, so don't try to get a // It isn't safe to use the context user yet, so don't try to get a
// ParserOptions for it. And don't cache this ParserOptions // ParserOptions for it. And don't cache this ParserOptions
@ -214,7 +215,7 @@ class MessageCache implements LoggerAwareInterface {
return $po; return $po;
} }
$this->mParserOptions = new ParserOptions( $user ); $this->mParserOptions = ParserOptions::newFromContext( $context );
// Messages may take parameters that could come // Messages may take parameters that could come
// from malicious sources. As a precaution, disable // from malicious sources. As a precaution, disable
// the <html> parser tag when parsing messages. // the <html> parser tag when parsing messages.