ApiTestCase: stop interacting with $wgUser
Bug: T285448 Change-Id: I6c91f47321c5ab717812a7dd0d629230b71a3ef1
This commit is contained in:
parent
f3bab2f249
commit
d82849a649
2 changed files with 11 additions and 12 deletions
|
|
@ -316,6 +316,15 @@ because of Phabricator reports.
|
|||
deprecated since 1.36, was removed.
|
||||
* Skin::generateDebugHTML(), deprecated since 1.35, was removed. Call
|
||||
MWDebug::getHTMLDebugLog() directly.
|
||||
* The ApiTestCase class no longer interacts with the global $wgUser.
|
||||
Previously, the global variable was set at the start of each test, and in
|
||||
ApiTestCase::doApiRequest() if a performer was specified $wgUser was
|
||||
updated to match, and if no performer was specified $wgUser was used
|
||||
instead. Now, $wgUser is not updated, and if no performer is specified
|
||||
the reusable TestUser object for the sysop is relied on. Extensions
|
||||
or skins that rely on the global $wgUser variable (which has been
|
||||
deprecated since 1.35) should instead retrieve the acting user from the
|
||||
relevant context source.
|
||||
* …
|
||||
|
||||
=== Deprecations in 1.37 ===
|
||||
|
|
|
|||
|
|
@ -30,9 +30,6 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
|
|||
];
|
||||
|
||||
$this->setRequest( new FauxRequest( [] ) );
|
||||
$this->setMwGlobals( [
|
||||
'wgUser' => self::$users['sysop']->getUser(),
|
||||
] );
|
||||
|
||||
$this->apiContext = new ApiTestContext();
|
||||
}
|
||||
|
|
@ -63,7 +60,7 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
|
|||
protected function doApiRequest( array $params, array $session = null,
|
||||
$appendModule = false, Authority $performer = null, $tokenType = null
|
||||
) {
|
||||
global $wgRequest, $wgUser;
|
||||
global $wgRequest;
|
||||
|
||||
if ( $session === null ) {
|
||||
// re-use existing global session by default
|
||||
|
|
@ -81,16 +78,9 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
|
|||
// set up global environment
|
||||
if ( $performer ) {
|
||||
$legacyUser = $this->getServiceContainer()->getUserFactory()->newFromAuthority( $performer );
|
||||
$wgUser = $legacyUser;
|
||||
// Only $contextUser should be used, $wgUser is set for anything that still
|
||||
// tries to read it
|
||||
$contextUser = $legacyUser;
|
||||
} else {
|
||||
// Fallback, eventually should be removed. Once no tests write to $wgUser
|
||||
// directly or via `setMwGlobals`, this should always be a reference
|
||||
// to `self::$users['sysop']->getUser()` (which is set as the value of
|
||||
// $wgUser in ::setUp) and should be replaced with using that.
|
||||
$contextUser = $wgUser;
|
||||
$contextUser = self::$users['sysop']->getUser();
|
||||
$performer = $contextUser;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue