MediaWiki  master
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...

Inheritance diagram for StubGlobalUser:
Collaboration diagram for 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. More...
 
- Public Member Functions inherited from StubObject
 __call ( $name, $args)
 Function called by PHP if no function with that name exists in this object. More...
 
 __construct ( $global=null, $class=null, $params=[])
 
 __get ( $name)
 Function called by PHP if no property with that name exists in this object. More...
 
 __set ( $name, $value)
 Function called by PHP if no property with that name exists in this object. More...
 
 _call ( $name, $args)
 Function called if any function exists with that name in this object. More...
 
 _get ( $name)
 Wrapper for __get(), similar to _call() above. More...
 
 _set ( $name, $value)
 Wrapper for __set(), similar to _call() above. More...
 

Static Public Member Functions

static getRealUser ( $globalUser)
 Get the relevant "real" user object based on either a User object or a StubGlobalUser wrapper. More...
 
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. More...
 
- Static Public Member Functions inherited from StubObject
static isRealObject ( $obj)
 Returns a bool value whenever $obj is a stub object. More...
 
static unstub (&$obj)
 Unstubs an object, if it is a stub object. More...
 

Public Attributes

User $realUser
 

Static Public Attributes

static bool $destructorDeprecationDisarmed = false
 

Additional Inherited Members

- Protected Attributes inherited from 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 31 of file StubGlobalUser.php.

Constructor & Destructor Documentation

◆ __construct()

StubGlobalUser::__construct ( User  $realUser)
Parameters
User$realUser

Definition at line 42 of file StubGlobalUser.php.

References $realUser.

◆ __destruct()

StubGlobalUser::__destruct ( )

Definition at line 143 of file StubGlobalUser.php.

References wfDeprecatedMsg().

Member Function Documentation

◆ _newObject()

StubGlobalUser::_newObject ( )
Returns
User

Reimplemented from StubObject.

Definition at line 50 of file StubGlobalUser.php.

References $realUser, and wfDeprecated().

Referenced by _unstub().

◆ _unstub()

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 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 StubObject.

Definition at line 131 of file StubGlobalUser.php.

References StubObject\$global, _newObject(), wfDebug(), and wfGetCaller().

◆ getRealUser()

static StubGlobalUser::getRealUser (   $globalUser)
static

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

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

Parameters
StubGlobalUser | User$globalUser
Returns
User

Definition at line 100 of file StubGlobalUser.php.

Referenced by WikiPage\doEditContent(), WikiPage\prepareContentForEdit(), and setUser().

◆ setUser()

static StubGlobalUser::setUser (   $user)
static

Member Data Documentation

◆ $destructorDeprecationDisarmed

bool StubGlobalUser::$destructorDeprecationDisarmed = false
static

Definition at line 34 of file StubGlobalUser.php.

◆ $realUser

User StubGlobalUser::$realUser

Definition at line 37 of file StubGlobalUser.php.

Referenced by __construct(), _newObject(), and setUser().


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