2011-09-15 17:42:17 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @author Daniel Friesen
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
2023-09-20 07:54:42 +00:00
|
|
|
|
2024-02-08 14:56:54 +00:00
|
|
|
namespace MediaWiki\Context;
|
|
|
|
|
|
|
|
|
|
use Language;
|
2023-09-20 07:54:42 +00:00
|
|
|
use MediaWiki\Config\Config;
|
2016-04-11 18:28:17 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2024-02-08 18:57:07 +00:00
|
|
|
use MediaWiki\Message\Message;
|
2023-09-05 17:31:53 +00:00
|
|
|
use MediaWiki\Output\OutputPage;
|
2021-01-08 01:01:28 +00:00
|
|
|
use MediaWiki\Permissions\Authority;
|
2023-09-07 11:46:15 +00:00
|
|
|
use MediaWiki\Request\WebRequest;
|
2023-03-01 20:33:26 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2023-09-19 12:13:45 +00:00
|
|
|
use MediaWiki\User\User;
|
2024-02-08 14:56:54 +00:00
|
|
|
use MessageSpecifier;
|
|
|
|
|
use Skin;
|
|
|
|
|
use Timing;
|
2023-06-08 22:30:57 +00:00
|
|
|
use Wikimedia\Assert\Assert;
|
2024-02-08 14:56:54 +00:00
|
|
|
use WikiPage;
|
2011-09-15 17:42:17 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An IContextSource implementation which will inherit context from another source
|
|
|
|
|
* but allow individual pieces of context to be changed locally
|
|
|
|
|
* eg: A ContextSource that can inherit from the main RequestContext but have
|
|
|
|
|
* a different Title instance set on it.
|
2020-06-26 12:56:03 +00:00
|
|
|
* @newable
|
2015-03-07 21:39:07 +00:00
|
|
|
* @since 1.19
|
2011-09-15 17:42:17 +00:00
|
|
|
*/
|
2014-07-21 09:13:23 +00:00
|
|
|
class DerivativeContext extends ContextSource implements MutableContext {
|
2011-09-15 17:42:17 +00:00
|
|
|
/**
|
|
|
|
|
* @var WebRequest
|
|
|
|
|
*/
|
|
|
|
|
private $request;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
|
|
|
|
private $title;
|
|
|
|
|
|
2012-01-06 20:00:04 +00:00
|
|
|
/**
|
|
|
|
|
* @var WikiPage
|
|
|
|
|
*/
|
|
|
|
|
private $wikipage;
|
|
|
|
|
|
context: Add a cached RequestContext::getActionName method
This method is dependent on, and inherently must depend on, all of
Title, WikiPage, and WebRequest. And, like Title and WikiPage,
which also have getters in RequestContext, Action is also derived
from a query parameter that is widely recognised in almost all
web requests to index.php.
The status quo in core and extensions, is to obtain this value
via Action::getActionName(), which as a static method that bypasses
dependency injection and also has the problem of not being cached.
Caching it within ActionFactory seems hard and awkward, due to
varying by context.
In change I61d66211bd (22f9a32853f) a cached wrapper method was added
internally to the Skin class. In change I8cbc4bba4d248d9 (235820d631)
another cached wrapper was added in the Gadgets extension.
This change takes this approach further by making it a stable public
method on RequestContext.
To facilitate testing and to offer basic confidence in this working
correctly, this commit also adopts the new method in two place that
are considered "safe" (Skin, and OutputPage). Both of these are
called relatively late in the PHP proccess and well after any Setup
code and overrides (such as in MediaWiki.php), during which it is
more complex to call this. I'll audit and update those in a subsequent
change.
Change-Id: I1e259b54dca48a32be5a8c6cbb8eb69aec2da115
2021-11-06 00:28:23 +00:00
|
|
|
/**
|
2021-11-06 04:52:40 +00:00
|
|
|
* @var string|null|false
|
context: Add a cached RequestContext::getActionName method
This method is dependent on, and inherently must depend on, all of
Title, WikiPage, and WebRequest. And, like Title and WikiPage,
which also have getters in RequestContext, Action is also derived
from a query parameter that is widely recognised in almost all
web requests to index.php.
The status quo in core and extensions, is to obtain this value
via Action::getActionName(), which as a static method that bypasses
dependency injection and also has the problem of not being cached.
Caching it within ActionFactory seems hard and awkward, due to
varying by context.
In change I61d66211bd (22f9a32853f) a cached wrapper method was added
internally to the Skin class. In change I8cbc4bba4d248d9 (235820d631)
another cached wrapper was added in the Gadgets extension.
This change takes this approach further by making it a stable public
method on RequestContext.
To facilitate testing and to offer basic confidence in this working
correctly, this commit also adopts the new method in two place that
are considered "safe" (Skin, and OutputPage). Both of these are
called relatively late in the PHP proccess and well after any Setup
code and overrides (such as in MediaWiki.php), during which it is
more complex to call this. I'll audit and update those in a subsequent
change.
Change-Id: I1e259b54dca48a32be5a8c6cbb8eb69aec2da115
2021-11-06 00:28:23 +00:00
|
|
|
*/
|
2021-11-06 04:52:40 +00:00
|
|
|
private $action = false;
|
context: Add a cached RequestContext::getActionName method
This method is dependent on, and inherently must depend on, all of
Title, WikiPage, and WebRequest. And, like Title and WikiPage,
which also have getters in RequestContext, Action is also derived
from a query parameter that is widely recognised in almost all
web requests to index.php.
The status quo in core and extensions, is to obtain this value
via Action::getActionName(), which as a static method that bypasses
dependency injection and also has the problem of not being cached.
Caching it within ActionFactory seems hard and awkward, due to
varying by context.
In change I61d66211bd (22f9a32853f) a cached wrapper method was added
internally to the Skin class. In change I8cbc4bba4d248d9 (235820d631)
another cached wrapper was added in the Gadgets extension.
This change takes this approach further by making it a stable public
method on RequestContext.
To facilitate testing and to offer basic confidence in this working
correctly, this commit also adopts the new method in two place that
are considered "safe" (Skin, and OutputPage). Both of these are
called relatively late in the PHP proccess and well after any Setup
code and overrides (such as in MediaWiki.php), during which it is
more complex to call this. I'll audit and update those in a subsequent
change.
Change-Id: I1e259b54dca48a32be5a8c6cbb8eb69aec2da115
2021-11-06 00:28:23 +00:00
|
|
|
|
2011-09-15 17:42:17 +00:00
|
|
|
/**
|
|
|
|
|
* @var OutputPage
|
|
|
|
|
*/
|
|
|
|
|
private $output;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-07-02 11:58:44 +00:00
|
|
|
* @var User|null
|
2011-09-15 17:42:17 +00:00
|
|
|
*/
|
|
|
|
|
private $user;
|
|
|
|
|
|
2021-01-08 01:01:28 +00:00
|
|
|
/**
|
|
|
|
|
* @var Authority
|
|
|
|
|
*/
|
|
|
|
|
private $authority;
|
|
|
|
|
|
2011-09-15 17:42:17 +00:00
|
|
|
/**
|
|
|
|
|
* @var Language
|
|
|
|
|
*/
|
|
|
|
|
private $lang;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Skin
|
|
|
|
|
*/
|
|
|
|
|
private $skin;
|
|
|
|
|
|
2013-10-25 21:17:24 +00:00
|
|
|
/**
|
2014-05-27 02:36:59 +00:00
|
|
|
* @var Config
|
2013-10-25 21:17:24 +00:00
|
|
|
*/
|
|
|
|
|
private $config;
|
|
|
|
|
|
2015-11-03 02:26:07 +00:00
|
|
|
/**
|
|
|
|
|
* @var Timing
|
|
|
|
|
*/
|
|
|
|
|
private $timing;
|
|
|
|
|
|
2011-09-15 17:42:17 +00:00
|
|
|
/**
|
2020-07-13 08:53:06 +00:00
|
|
|
* @stable to call
|
2013-01-11 15:56:04 +00:00
|
|
|
* @param IContextSource $context Context to inherit from
|
2011-09-15 17:42:17 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct( IContextSource $context ) {
|
|
|
|
|
$this->setContext( $context );
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-25 21:17:24 +00:00
|
|
|
/**
|
2017-12-28 18:59:53 +00:00
|
|
|
* @param Config $config
|
2013-10-25 21:17:24 +00:00
|
|
|
*/
|
2017-12-28 18:59:53 +00:00
|
|
|
public function setConfig( Config $config ) {
|
|
|
|
|
$this->config = $config;
|
2013-10-25 21:17:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-01-24 01:45:11 +00:00
|
|
|
* @return Config
|
2013-10-25 21:17:24 +00:00
|
|
|
*/
|
|
|
|
|
public function getConfig() {
|
2019-03-20 18:53:00 +00:00
|
|
|
return $this->config ?: $this->getContext()->getConfig();
|
2013-10-25 21:17:24 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-03 02:26:07 +00:00
|
|
|
/**
|
|
|
|
|
* @return Timing
|
|
|
|
|
*/
|
|
|
|
|
public function getTiming() {
|
2019-03-20 18:53:00 +00:00
|
|
|
return $this->timing ?: $this->getContext()->getTiming();
|
2015-11-03 02:26:07 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-15 17:42:17 +00:00
|
|
|
/**
|
2017-12-28 18:59:53 +00:00
|
|
|
* @param WebRequest $request
|
2011-09-15 17:42:17 +00:00
|
|
|
*/
|
2017-12-28 18:59:53 +00:00
|
|
|
public function setRequest( WebRequest $request ) {
|
|
|
|
|
$this->request = $request;
|
2011-09-15 17:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return WebRequest
|
|
|
|
|
*/
|
|
|
|
|
public function getRequest() {
|
2019-03-20 18:53:00 +00:00
|
|
|
return $this->request ?: $this->getContext()->getRequest();
|
2011-09-15 17:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-12-28 18:59:53 +00:00
|
|
|
* @param Title $title
|
2011-09-15 17:42:17 +00:00
|
|
|
*/
|
2017-12-28 18:59:53 +00:00
|
|
|
public function setTitle( Title $title ) {
|
|
|
|
|
$this->title = $title;
|
2021-11-06 04:52:40 +00:00
|
|
|
$this->action = null;
|
2011-09-15 17:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-04-24 17:53:20 +00:00
|
|
|
* @return Title|null
|
2011-09-15 17:42:17 +00:00
|
|
|
*/
|
|
|
|
|
public function getTitle() {
|
2019-03-20 18:53:00 +00:00
|
|
|
return $this->title ?: $this->getContext()->getTitle();
|
2011-09-15 17:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-14 14:27:46 +00:00
|
|
|
/**
|
|
|
|
|
* Check whether a WikiPage object can be get with getWikiPage().
|
|
|
|
|
* Callers should expect that an exception is thrown from getWikiPage()
|
|
|
|
|
* if this method returns false.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.19
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function canUseWikiPage() {
|
|
|
|
|
if ( $this->wikipage !== null ) {
|
|
|
|
|
return true;
|
2019-03-20 18:53:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->title !== null ) {
|
2012-01-14 14:27:46 +00:00
|
|
|
return $this->title->canExist();
|
|
|
|
|
}
|
2019-03-20 18:53:00 +00:00
|
|
|
|
|
|
|
|
return $this->getContext()->canUseWikiPage();
|
2012-01-14 14:27:46 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-15 17:42:17 +00:00
|
|
|
/**
|
2012-01-06 20:00:04 +00:00
|
|
|
* @since 1.19
|
2017-12-28 18:59:53 +00:00
|
|
|
* @param WikiPage $wikiPage
|
2012-01-06 20:00:04 +00:00
|
|
|
*/
|
2017-12-28 18:59:53 +00:00
|
|
|
public function setWikiPage( WikiPage $wikiPage ) {
|
2022-06-24 19:17:17 +00:00
|
|
|
$pageTitle = $wikiPage->getTitle();
|
|
|
|
|
if ( !$this->title || !$pageTitle->equals( $this->title ) ) {
|
|
|
|
|
$this->setTitle( $pageTitle );
|
|
|
|
|
}
|
2017-12-28 18:59:53 +00:00
|
|
|
$this->wikipage = $wikiPage;
|
2021-11-06 04:52:40 +00:00
|
|
|
$this->action = null;
|
2012-01-06 20:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-01-14 14:27:46 +00:00
|
|
|
* Get the WikiPage object.
|
|
|
|
|
* May throw an exception if there's no Title object set or the Title object
|
|
|
|
|
* belongs to a special namespace that doesn't have WikiPage, so use first
|
|
|
|
|
* canUseWikiPage() to check whether this method can be called safely.
|
2012-01-06 20:00:04 +00:00
|
|
|
*
|
|
|
|
|
* @since 1.19
|
|
|
|
|
* @return WikiPage
|
|
|
|
|
*/
|
|
|
|
|
public function getWikiPage() {
|
2022-06-24 19:17:17 +00:00
|
|
|
if ( !$this->wikipage && $this->title ) {
|
|
|
|
|
$this->wikipage = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( $this->title );
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-20 18:53:00 +00:00
|
|
|
return $this->wikipage ?: $this->getContext()->getWikiPage();
|
2012-01-06 20:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
context: Add a cached RequestContext::getActionName method
This method is dependent on, and inherently must depend on, all of
Title, WikiPage, and WebRequest. And, like Title and WikiPage,
which also have getters in RequestContext, Action is also derived
from a query parameter that is widely recognised in almost all
web requests to index.php.
The status quo in core and extensions, is to obtain this value
via Action::getActionName(), which as a static method that bypasses
dependency injection and also has the problem of not being cached.
Caching it within ActionFactory seems hard and awkward, due to
varying by context.
In change I61d66211bd (22f9a32853f) a cached wrapper method was added
internally to the Skin class. In change I8cbc4bba4d248d9 (235820d631)
another cached wrapper was added in the Gadgets extension.
This change takes this approach further by making it a stable public
method on RequestContext.
To facilitate testing and to offer basic confidence in this working
correctly, this commit also adopts the new method in two place that
are considered "safe" (Skin, and OutputPage). Both of these are
called relatively late in the PHP proccess and well after any Setup
code and overrides (such as in MediaWiki.php), during which it is
more complex to call this. I'll audit and update those in a subsequent
change.
Change-Id: I1e259b54dca48a32be5a8c6cbb8eb69aec2da115
2021-11-06 00:28:23 +00:00
|
|
|
/**
|
|
|
|
|
* @since 1.38
|
|
|
|
|
* @param string $action
|
|
|
|
|
*/
|
|
|
|
|
public function setActionName( string $action ): void {
|
|
|
|
|
$this->action = $action;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the action name for the current web request.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.38
|
|
|
|
|
* @return string Action
|
|
|
|
|
*/
|
|
|
|
|
public function getActionName(): string {
|
2021-11-06 04:52:40 +00:00
|
|
|
if ( $this->action === false ) {
|
|
|
|
|
return $this->getContext()->getActionName();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-16 23:48:27 +00:00
|
|
|
$this->action ??= MediaWikiServices::getInstance()
|
|
|
|
|
->getActionFactory()
|
|
|
|
|
->getActionName( $this );
|
2021-11-06 04:52:40 +00:00
|
|
|
|
|
|
|
|
return $this->action;
|
context: Add a cached RequestContext::getActionName method
This method is dependent on, and inherently must depend on, all of
Title, WikiPage, and WebRequest. And, like Title and WikiPage,
which also have getters in RequestContext, Action is also derived
from a query parameter that is widely recognised in almost all
web requests to index.php.
The status quo in core and extensions, is to obtain this value
via Action::getActionName(), which as a static method that bypasses
dependency injection and also has the problem of not being cached.
Caching it within ActionFactory seems hard and awkward, due to
varying by context.
In change I61d66211bd (22f9a32853f) a cached wrapper method was added
internally to the Skin class. In change I8cbc4bba4d248d9 (235820d631)
another cached wrapper was added in the Gadgets extension.
This change takes this approach further by making it a stable public
method on RequestContext.
To facilitate testing and to offer basic confidence in this working
correctly, this commit also adopts the new method in two place that
are considered "safe" (Skin, and OutputPage). Both of these are
called relatively late in the PHP proccess and well after any Setup
code and overrides (such as in MediaWiki.php), during which it is
more complex to call this. I'll audit and update those in a subsequent
change.
Change-Id: I1e259b54dca48a32be5a8c6cbb8eb69aec2da115
2021-11-06 00:28:23 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-06 20:00:04 +00:00
|
|
|
/**
|
2017-12-28 18:59:53 +00:00
|
|
|
* @param OutputPage $output
|
2011-09-15 17:42:17 +00:00
|
|
|
*/
|
2017-12-28 18:59:53 +00:00
|
|
|
public function setOutput( OutputPage $output ) {
|
|
|
|
|
$this->output = $output;
|
2011-09-15 17:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2013-01-11 15:56:04 +00:00
|
|
|
* @return OutputPage
|
2011-09-15 17:42:17 +00:00
|
|
|
*/
|
|
|
|
|
public function getOutput() {
|
2019-03-20 18:53:00 +00:00
|
|
|
return $this->output ?: $this->getContext()->getOutput();
|
2011-09-15 17:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-12-28 18:59:53 +00:00
|
|
|
* @param User $user
|
2011-09-15 17:42:17 +00:00
|
|
|
*/
|
2017-12-28 18:59:53 +00:00
|
|
|
public function setUser( User $user ) {
|
2021-01-08 01:01:28 +00:00
|
|
|
$this->authority = $user;
|
2017-12-28 18:59:53 +00:00
|
|
|
$this->user = $user;
|
2011-09-15 17:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return User
|
|
|
|
|
*/
|
|
|
|
|
public function getUser() {
|
2022-07-02 11:58:44 +00:00
|
|
|
if ( !$this->user && $this->authority ) {
|
|
|
|
|
// Keep user consistent by using a possible set authority
|
|
|
|
|
$this->user = MediaWikiServices::getInstance()
|
|
|
|
|
->getUserFactory()
|
|
|
|
|
->newFromAuthority( $this->authority );
|
|
|
|
|
}
|
2019-03-20 18:53:00 +00:00
|
|
|
return $this->user ?: $this->getContext()->getUser();
|
2011-09-15 17:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-08 01:01:28 +00:00
|
|
|
public function setAuthority( Authority $authority ) {
|
|
|
|
|
$this->authority = $authority;
|
2022-07-02 11:58:44 +00:00
|
|
|
// If needed, a User object is constructed from this authority
|
|
|
|
|
$this->user = null;
|
2021-01-08 01:01:28 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-13 18:38:36 +00:00
|
|
|
/**
|
|
|
|
|
* @since 1.36
|
|
|
|
|
* @return Authority
|
|
|
|
|
*/
|
2021-01-08 01:01:28 +00:00
|
|
|
public function getAuthority(): Authority {
|
|
|
|
|
return $this->authority ?: $this->getContext()->getAuthority();
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-23 10:28:21 +00:00
|
|
|
/**
|
2017-12-28 18:59:53 +00:00
|
|
|
* @param Language|string $language Language instance or language code
|
2011-12-05 18:56:09 +00:00
|
|
|
* @since 1.19
|
2011-11-23 10:28:21 +00:00
|
|
|
*/
|
2017-12-28 18:59:53 +00:00
|
|
|
public function setLanguage( $language ) {
|
2023-06-08 22:30:57 +00:00
|
|
|
Assert::parameterType( [ Language::class, 'string' ], $language, '$language' );
|
2017-12-28 18:59:53 +00:00
|
|
|
if ( $language instanceof Language ) {
|
|
|
|
|
$this->lang = $language;
|
2023-06-08 22:30:57 +00:00
|
|
|
} else {
|
2017-12-28 18:59:53 +00:00
|
|
|
$language = RequestContext::sanitizeLangCode( $language );
|
2019-08-26 12:24:37 +00:00
|
|
|
$obj = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $language );
|
2011-09-15 17:42:17 +00:00
|
|
|
$this->lang = $obj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Language
|
2011-12-05 18:56:09 +00:00
|
|
|
* @since 1.19
|
2011-09-15 17:42:17 +00:00
|
|
|
*/
|
2011-11-21 16:13:21 +00:00
|
|
|
public function getLanguage() {
|
2019-03-20 18:53:00 +00:00
|
|
|
return $this->lang ?: $this->getContext()->getLanguage();
|
2011-09-15 17:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-12-28 18:59:53 +00:00
|
|
|
* @param Skin $skin
|
2011-09-15 17:42:17 +00:00
|
|
|
*/
|
2017-12-28 18:59:53 +00:00
|
|
|
public function setSkin( Skin $skin ) {
|
|
|
|
|
$this->skin = clone $skin;
|
2011-09-15 17:42:17 +00:00
|
|
|
$this->skin->setContext( $this );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Skin
|
|
|
|
|
*/
|
|
|
|
|
public function getSkin() {
|
2019-03-20 18:53:00 +00:00
|
|
|
return $this->skin ?: $this->getContext()->getSkin();
|
2011-09-15 17:42:17 +00:00
|
|
|
}
|
2013-08-12 18:29:29 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a message using the current context.
|
|
|
|
|
*
|
|
|
|
|
* This can't just inherit from ContextSource, since then
|
|
|
|
|
* it would set only the original context, and not take
|
|
|
|
|
* into account any changes.
|
|
|
|
|
*
|
2017-06-12 09:53:51 +00:00
|
|
|
* @param string|string[]|MessageSpecifier $key Message key, or array of keys,
|
|
|
|
|
* or a MessageSpecifier.
|
2018-06-08 20:35:15 +00:00
|
|
|
* @param mixed ...$params
|
2013-08-12 18:29:29 +00:00
|
|
|
* @return Message
|
|
|
|
|
*/
|
2018-06-08 20:35:15 +00:00
|
|
|
public function msg( $key, ...$params ) {
|
2018-08-22 13:41:49 +00:00
|
|
|
// phpcs:ignore MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage
|
2018-06-08 20:35:15 +00:00
|
|
|
return wfMessage( $key, ...$params )->setContext( $this );
|
2013-08-12 18:29:29 +00:00
|
|
|
}
|
2011-09-15 17:42:17 +00:00
|
|
|
}
|
2024-02-08 14:56:54 +00:00
|
|
|
|
2024-03-07 21:56:58 +00:00
|
|
|
/** @deprecated class alias since 1.42 */
|
2024-02-08 14:56:54 +00:00
|
|
|
class_alias( DerivativeContext::class, 'DerivativeContext' );
|