47 'table' =>
'revision_actor_temp',
48 'pk' =>
'revactor_rev',
49 'field' =>
'revactor_actor',
52 'revactor_timestamp' =>
'rev_timestamp',
53 'revactor_page' =>
'rev_page',
71 'ipb_by' => [
'ipb_by_text',
'ipb_by_actor' ],
90 return MediaWikiServices::getInstance()->getActorMigration();
99 return $this->stage ===
MIGRATION_NEW ?
"$field IS NULL" :
"$field = 0";
108 return $this->stage ===
MIGRATION_NEW ?
"$field IS NOT NULL" :
"$field != 0";
117 if ( isset( self::$specialFields[$key] ) ) {
118 return self::$specialFields[$key];
121 return [ $key .
'_text', substr( $key, 0, -5 ) .
'_actor' ];
136 if ( !isset( $this->joinCache[$key] ) ) {
141 list( $text, $actor ) = self::getFieldNames( $key );
144 $fields[$key] = $key;
145 $fields[$text] = $text;
146 $fields[$actor] =
'NULL';
148 $join = $this->stage ===
MIGRATION_NEW ?
'JOIN' :
'LEFT JOIN';
150 if ( isset( self::$tempTables[$key] ) ) {
151 $t = self::$tempTables[$key];
152 $alias =
"temp_$key";
154 $joins[$alias] = [ $join,
"{$alias}.{$t['pk']} = {$t['joinPK']}" ];
155 $joinField =
"{$alias}.{$t['field']}";
160 $alias =
"actor_$key";
162 $joins[$alias] = [ $join,
"{$alias}.actor_id = {$joinField}" ];
165 $fields[$key] =
"{$alias}.actor_user";
166 $fields[$text] =
"{$alias}.actor_name";
168 $fields[$key] =
"COALESCE( {$alias}.actor_user, $key )";
169 $fields[$text] =
"COALESCE( {$alias}.actor_name, $text )";
171 $fields[$actor] = $joinField;
174 $this->joinCache[$key] = [
181 return $this->joinCache[$key];
197 [
'actor_name' =>
$user->getName() ],
200 if ( $row ===
false ) {
204 return (
int)$row->actor_id;
220 'actor_user' =>
$user->getId() ?:
null,
226 'Cannot create an actor for a usable name that is not an existing user'
229 if ( $q[
'actor_name'] ===
'' ) {
232 $dbw->insert(
'actor', $q, __METHOD__, [
'IGNORE' ] );
233 if ( $dbw->affectedRows() ) {
234 $actorId = (int)$dbw->insertId();
238 $actorId = (int)$dbw->selectField(
243 [
'LOCK IN SHARE MODE' ]
247 "Cannot create actor ID for user_id={$user->getId()} user_name={$user->getName()}"
253 list( $index,
$options ) = DBAccessObjectUtils::getDBOptions( $dbw );
255 $actorId = (int)$db->selectField(
'actor',
'actor_id', $q, __METHOD__,
$options );
271 if ( isset( self::$tempTables[$key] ) ) {
272 throw new InvalidArgumentException(
"Must use getInsertValuesWithTempTable() for $key" );
275 list( $text, $actor ) = self::getFieldNames( $key );
285 if ( $existingActorId !==
false ) {
286 $ret[$actor] = $existingActorId;
307 if ( isset( self::$formerTempTables[$key] ) ) {
308 wfDeprecated( __METHOD__ .
" for $key", self::$formerTempTables[$key] );
309 } elseif ( !isset( self::$tempTables[$key] ) ) {
310 throw new InvalidArgumentException(
"Must use getInsertValues() for $key" );
313 list( $text, $actor ) = self::getFieldNames( $key );
325 $id =
$user->getActorId( $dbw );
327 if ( isset( self::$tempTables[$key] ) ) {
329 $callback =
function ( $pk,
array $extra )
use ( $dbw, $key, $id, $func ) {
330 $t = self::$tempTables[$key];
331 $set = [
$t[
'field'] => $id ];
332 foreach (
$t[
'extra']
as $to => $from ) {
333 if ( !array_key_exists( $from, $extra ) ) {
334 throw new InvalidArgumentException(
"$func callback: \$extra[$from] is not provided" );
336 $set[$to] = $extra[$from];
340 [
$t[
'pk'] => $pk ] + $set,
348 $callback =
function ( $pk,
array $extra ) {
351 } elseif ( isset( self::$tempTables[$key] ) ) {
353 $callback =
function ( $pk,
array $extra )
use ( $key, $func ) {
354 $t = self::$tempTables[$key];
355 foreach (
$t[
'extra']
as $to => $from ) {
356 if ( !array_key_exists( $from, $extra ) ) {
357 throw new InvalidArgumentException(
"$func callback: \$extra[$from] is not provided" );
362 $callback =
function ( $pk,
array $extra ) {
365 return [
$ret, $callback ];
401 if ( $useId &&
$user->getId() ) {
402 $ids[] =
$user->getId();
404 $names[] =
$user->getName();
406 $actorId =
$user->getActorId();
408 $actors[] = $actorId;
412 list( $text, $actor ) = self::getFieldNames( $key );
419 } elseif ( isset( self::$tempTables[$key] ) ) {
420 $t = self::$tempTables[$key];
421 $alias =
"temp_$key";
425 "{$alias}.{$t['pk']} = {$t['joinPK']}"
427 $joinField =
"{$alias}.{$t['field']}";
428 $actorEmpty = [ $joinField => null ];
432 $actorNotEmpty = [
"$joinField IS NOT NULL" ];
436 $actorEmpty = [ $joinField => 0 ];
441 $actorNotEmpty + [ $joinField => $actors ], IDatabase::LIST_AND
446 $actorEmpty + [ $key => $ids ], IDatabase::LIST_AND
451 $actorEmpty + [ $text => $names ], IDatabase::LIST_AND
457 'conds' => $conds ? $db->
makeList( array_values( $conds ), IDatabase::LIST_OR ) :
'1=0',
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
This class handles the logic for the actor table migration.
static array $formerTempTables
Fields that formerly used $tempTables Key is '$key', value is the MediaWiki version in which it was r...
isAnon( $field)
Return an SQL condition to test if a user field is anonymous.
getInsertValues(IDatabase $dbw, $key, UserIdentity $user)
Get UPDATE fields for the actor.
static array $tempTables
Define fields that use temporary tables for transitional purposes Keys are '$key',...
static array $specialFields
Define fields that use non-standard mapping Keys are the user id column name, values are arrays with ...
getNewActorId( $dbw, UserIdentity $user)
Attempt to assign an actor ID to the given user.
static newMigration()
Static constructor.
array null $joinCache
Cache for self::getJoin()
getInsertValuesWithTempTable(IDatabase $dbw, $key, UserIdentity $user)
Get UPDATE fields for the actor.
int $stage
One of the MIGRATION_* constants.
isNotAnon( $field)
Return an SQL condition to test if a user field is non-anonymous.
getExistingActorId(IDatabase $db, UserIdentity $user)
Get actor ID from UserIdentity, if it exists.
getWhere(IDatabase $db, $key, $users, $useId=true)
Get WHERE condition for the actor.
getJoin( $key)
Get SELECT fields and joins for the actor key.
static getFieldNames( $key)
Exception thrown when an actor can't be created.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static newFromAnyId( $userId, $userName, $actorId)
Static factory method for creation from an ID, name, and/or actor ID.
static isUsableName( $name)
Usernames which fail to pass this function will be blocked from user login and new account registrati...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const MIGRATION_WRITE_BOTH
the array() calling protocol came about after MediaWiki 1.4rc1.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php