MediaWiki master
MediaWiki\StubObject\StubGlobalUser Class Reference

Stub object for the global user ($wgUser) that makes it possible to change the relevant underlying object while still ensuring that deprecation warnings will be emitted upon method calls. More...

Inherits MediaWiki\StubObject\StubObject.

Collaboration diagram for MediaWiki\StubObject\StubGlobalUser:

Public Member Functions

 __construct (User $realUser)
 
 __destruct ()
 
 _newObject ()
 
 _unstub ( $name='_unstub', $level=2)
 This function creates a new object of the real class and replace it in the global variable.
 
- Public Member Functions inherited from MediaWiki\StubObject\StubObject
 __call ( $name, $args)
 Function called by PHP if no function with that name exists in this object.
 
 __construct ( $global=null, $class=null, $params=[])
 
 __get ( $name)
 Function called by PHP if no property with that name exists in this object.
 
 __set ( $name, $value)
 Function called by PHP if no property with that name exists in this object.
 
 _call ( $name, $args)
 Function called if any function exists with that name in this object.
 
 _get ( $name)
 Wrapper for __get(), similar to _call() above.
 
 _set ( $name, $value)
 Wrapper for __set(), similar to _call() above.
 

Static Public Member Functions

static getRealUser ( $globalUser)
 Get the relevant "real" user object based on either a User object or a MediaWiki\StubObject\StubGlobalUser wrapper.
 
static setUser ( $user)
 Reset the stub global user to a different "real" user object, while ensuring that any method calls on that object will still trigger deprecation notices.
 
- Static Public Member Functions inherited from MediaWiki\StubObject\StubObject
static isRealObject ( $obj)
 Returns a bool value whenever $obj is a stub object.
 
static unstub (&$obj)
 Unstubs an object, if it is a stub object.
 

Public Attributes

User $realUser
 

Static Public Attributes

static bool $destructorDeprecationDisarmed = false
 

Additional Inherited Members

- Protected Attributes inherited from MediaWiki\StubObject\StubObject
null string $class
 
null callable $factory
 
null string $global
 
array $params
 

Detailed Description

Stub object for the global user ($wgUser) that makes it possible to change the relevant underlying object while still ensuring that deprecation warnings will be emitted upon method calls.

Access: internal
Will be removed in 1.38
Since
1.37
Author
Danny712

Definition at line 36 of file StubGlobalUser.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\StubObject\StubGlobalUser::__construct ( User $realUser)
Parameters
User$realUser

Definition at line 47 of file StubGlobalUser.php.

References MediaWiki\StubObject\StubGlobalUser\$realUser.

◆ __destruct()

MediaWiki\StubObject\StubGlobalUser::__destruct ( )

Definition at line 150 of file StubGlobalUser.php.

References wfDeprecatedMsg().

Member Function Documentation

◆ _newObject()

MediaWiki\StubObject\StubGlobalUser::_newObject ( )
Returns
User

Reimplemented from MediaWiki\StubObject\StubObject.

Definition at line 56 of file StubGlobalUser.php.

References MediaWiki\StubObject\StubGlobalUser\$realUser, and wfDeprecated().

◆ _unstub()

MediaWiki\StubObject\StubGlobalUser::_unstub ( $name = '_unstub',
$level = 2 )

This function creates a new object of the real class and replace it in the global variable.

This is public, for the convenience of external callers wishing to access properties, e.g. eval.php

Overriding MediaWiki\StubObject\StubObject::_unstub because for some reason that thinks there is an unstub loop when trying to use the magic __set() logic, but there isn't any loop because _newObject() returns a specific instance of User rather than calling any methods that could then try to use $wgUser. The main difference between this and the parent method is that we don't try to check for recursion loops.

Parameters
string$nameName of the method called in this object.
int$levelLevel to go in the stack trace to get the function who called this function.
Returns
User The unstubbed version

Reimplemented from MediaWiki\StubObject\StubObject.

Definition at line 138 of file StubGlobalUser.php.

References wfDebug(), and wfGetCaller().

◆ getRealUser()

static MediaWiki\StubObject\StubGlobalUser::getRealUser ( $globalUser)
static

Get the relevant "real" user object based on either a User object or a MediaWiki\StubObject\StubGlobalUser wrapper.

Bypasses deprecation notices from converting a MediaWiki\StubObject\StubGlobalUser to an actual user, and does not change $wgUser.

Parameters
StubGlobalUser | User$globalUser
Returns
User

Definition at line 106 of file StubGlobalUser.php.

Referenced by MediaWiki\StubObject\StubGlobalUser\setUser().

◆ setUser()

static MediaWiki\StubObject\StubGlobalUser::setUser ( $user)
static

Reset the stub global user to a different "real" user object, while ensuring that any method calls on that object will still trigger deprecation notices.

Parameters
StubGlobalUser | User$user

Definition at line 85 of file StubGlobalUser.php.

References MediaWiki\StubObject\StubGlobalUser\$realUser, $wgUser, and MediaWiki\StubObject\StubGlobalUser\getRealUser().

Member Data Documentation

◆ $destructorDeprecationDisarmed

bool MediaWiki\StubObject\StubGlobalUser::$destructorDeprecationDisarmed = false
static

Definition at line 39 of file StubGlobalUser.php.

◆ $realUser


The documentation for this class was generated from the following file: