116 'createAccount' =>
false,
117 'enableAutoblock' =>
false,
119 'blockEmail' =>
false,
120 'allowUsertalk' =>
false,
124 if ( func_num_args() > 1 || !is_array(
$options ) ) {
126 array_slice( array_keys( $defaults ), 0, func_num_args() ),
129 wfDeprecated( __METHOD__ .
' with multiple arguments',
'1.26' );
136 if ( $this->target instanceof
User &&
$options[
'user'] ) {
137 # Needed for foreign users
138 $this->forcedTargetID =
$options[
'user'];
149 $this->mReason =
$options[
'reason'];
154 $this->mAuto = (bool)
$options[
'auto'];
155 $this->mHideName = (bool)
$options[
'hideName'];
159 # Prevention measures
160 $this->
prevents(
'sendemail', (
bool)$options[
'blockEmail'] );
161 $this->
prevents(
'editownusertalk', !$options[
'allowUsertalk'] );
162 $this->
prevents(
'createaccount', (
bool)$options[
'createAccount'] );
164 $this->mFromMaster =
false;
177 self::selectFields(),
182 return self::newFromRow(
$res );
203 'ipb_create_account',
204 'ipb_enable_autoblock',
208 'ipb_allow_usertalk',
209 'ipb_parent_block_id',
223 (
string)$this->target == (
string)$block->target
224 && $this->type == $block->type
225 && $this->mAuto == $block->mAuto
227 && $this->
prevents(
'createaccount' ) == $block->
prevents(
'createaccount' )
228 && $this->mExpiry == $block->mExpiry
230 && $this->mHideName == $block->mHideName
232 && $this->
prevents(
'editownusertalk' ) == $block->
prevents(
'editownusertalk' )
233 && $this->mReason == $block->mReason
247 protected function newLoad( $vagueTarget = null ) {
250 if ( $this->
type !== null ) {
252 'ipb_address' => [ (
string)$this->target ],
255 $conds = [
'ipb_address' => [] ];
258 # Be aware that the != '' check is explicit, since empty values will be
259 # passed by some callers (bug 29116)
260 if ( $vagueTarget !=
'' ) {
263 case self::TYPE_USER:
264 # Slightly weird, but who are we to argue?
271 $conds = $db->makeList( $conds,
LIST_OR );
274 case self::TYPE_RANGE:
277 $conds[] = self::getRangeCond( $start, $end );
278 $conds = $db->makeList( $conds,
LIST_OR );
282 throw new MWException(
"Tried to load block with invalid type" );
286 $res = $db->select(
'ipblocks', self::selectFields(), $conds, __METHOD__ );
288 # This result could contain a block on the user, a block on the IP, and a russian-doll
289 # set of rangeblocks. We want to choose the most specific one, so keep a leader board.
292 # Lower will be better
293 $bestBlockScore = 100;
295 # This is begging for $this = $bestBlock, but that's not allowed in PHP :(
296 $bestBlockPreventsEdit = null;
298 foreach (
$res as $row ) {
299 $block = self::newFromRow( $row );
301 # Don't use expired blocks
302 if ( $block->isExpired() ) {
306 # Don't use anon only blocks on users
307 if ( $this->
type == self::TYPE_USER && !$block->isHardblock() ) {
311 if ( $block->getType() == self::TYPE_RANGE ) {
312 # This is the number of bits that are allowed to vary in the block, give
313 # or take some floating point errors
314 $end = Wikimedia\base_convert( $block->getRangeEnd(), 16, 10 );
315 $start = Wikimedia\base_convert( $block->getRangeStart(), 16, 10 );
316 $size = log( $end - $start + 1, 2 );
318 # This has the nice property that a /32 block is ranked equally with a
319 # single-IP block, which is exactly what it is...
320 $score = self::TYPE_RANGE - 1 + ( $size / 128 );
323 $score = $block->getType();
326 if ( $score < $bestBlockScore ) {
327 $bestBlockScore = $score;
329 $bestBlockPreventsEdit = $block->prevents(
'edit' );
333 if ( $bestRow !== null ) {
335 $this->
prevents(
'edit', $bestBlockPreventsEdit );
349 if ( $end === null ) {
352 # Per bug 14634, we want to include relevant active rangeblocks; for
353 # rangeblocks, we want to include larger ranges which enclose the given
354 # range. We know that all blocks must be smaller than $wgBlockCIDRLimit,
355 # so we can improve performance by filtering on a LIKE clause
356 $chunk = self::getIpFragment( $start );
358 $like =
$dbr->buildLike( $chunk,
$dbr->anyString() );
360 # Fairly hard to make a malicious SQL statement out of hex characters,
361 # but stranger things have happened...
362 $safeStart =
$dbr->addQuotes( $start );
363 $safeEnd =
$dbr->addQuotes( $end );
365 return $dbr->makeList(
367 "ipb_range_start $like",
368 "ipb_range_start <= $safeStart",
369 "ipb_range_end >= $safeEnd",
383 if ( substr( $hex, 0, 3 ) ==
'v6-' ) {
384 return 'v6-' . substr( substr( $hex, 3 ), 0, floor( $wgBlockCIDRLimit[
'IPv6'] / 4 ) );
386 return substr( $hex, 0, floor( $wgBlockCIDRLimit[
'IPv4'] / 4 ) );
397 if ( $row->ipb_by ) {
403 $this->mReason = $row->ipb_reason;
405 $this->mAuto = $row->ipb_auto;
406 $this->mHideName = $row->ipb_deleted;
407 $this->mId = (int)$row->ipb_id;
408 $this->mParentBlockId = $row->ipb_parent_block_id;
416 $this->
prevents(
'createaccount', $row->ipb_create_account );
417 $this->
prevents(
'sendemail', $row->ipb_block_email );
418 $this->
prevents(
'editownusertalk', !$row->ipb_allow_usertalk );
438 public function delete() {
443 if ( !$this->
getId() ) {
444 throw new MWException(
"Block::delete() requires that the mId member be filled\n" );
448 $dbw->delete(
'ipblocks', [
'ipb_parent_block_id' => $this->
getId() ], __METHOD__ );
449 $dbw->delete(
'ipblocks', [
'ipb_id' => $this->
getId() ], __METHOD__ );
451 return $dbw->affectedRows() > 0;
463 global $wgBlockDisablesLogin;
464 wfDebug(
"Block::insert; timestamp {$this->mTimestamp}\n" );
466 if ( $dbw === null ) {
470 # Periodic purge via commit hooks
471 if ( mt_rand( 0, 9 ) == 0 ) {
476 $row[
'ipb_id'] = $dbw->nextSequenceValue(
"ipblocks_ipb_id_seq" );
478 $dbw->insert(
'ipblocks', $row, __METHOD__, [
'IGNORE' ] );
479 $affected = $dbw->affectedRows();
480 $this->mId = $dbw->insertId();
482 # Don't collide with expired blocks.
483 # Do this after trying to insert to avoid locking.
485 # T96428: The ipb_address index uses a prefix on a field, so
486 # use a standard SELECT + DELETE to avoid annoying gap locks.
487 $ids = $dbw->selectFieldValues(
'ipblocks',
490 'ipb_address' => $row[
'ipb_address'],
491 'ipb_user' => $row[
'ipb_user'],
492 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() )
497 $dbw->delete(
'ipblocks', [
'ipb_id' => $ids ], __METHOD__ );
498 $dbw->insert(
'ipblocks', $row, __METHOD__, [
'IGNORE' ] );
499 $affected = $dbw->affectedRows();
500 $this->mId = $dbw->insertId();
507 if ( $wgBlockDisablesLogin && $this->target instanceof
User ) {
509 $this->target->setToken();
510 $this->target->saveSettings();
513 return [
'id' =>
$this->mId,
'autoIds' => $auto_ipd_ids ];
527 wfDebug(
"Block::update; timestamp {$this->mTimestamp}\n" );
530 $dbw->startAtomic( __METHOD__ );
535 [
'ipb_id' => $this->
getId() ],
539 $affected = $dbw->affectedRows();
546 [
'ipb_parent_block_id' => $this->
getId() ],
553 [
'ipb_parent_block_id' => $this->
getId() ],
558 $dbw->endAtomic( __METHOD__ );
562 return [
'id' =>
$this->mId,
'autoIds' => $auto_ipd_ids ];
577 $expiry = $db->encodeExpiry( $this->mExpiry );
579 if ( $this->forcedTargetID ) {
582 $uid = $this->target instanceof
User ? $this->target->getId() : 0;
586 'ipb_address' => (
string)$this->target,
588 'ipb_by' => $this->
getBy(),
591 'ipb_timestamp' => $db->timestamp( $this->mTimestamp ),
594 'ipb_create_account' => $this->
prevents(
'createaccount' ),
596 'ipb_expiry' => $expiry,
599 'ipb_deleted' => intval( $this->mHideName ),
600 'ipb_block_email' => $this->
prevents(
'sendemail' ),
601 'ipb_allow_usertalk' => !$this->
prevents(
'editownusertalk' ),
613 'ipb_by' => $this->
getBy(),
616 'ipb_create_account' => $this->
prevents(
'createaccount' ),
617 'ipb_deleted' => (int)$this->mHideName,
618 'ipb_allow_usertalk' => !$this->
prevents(
'editownusertalk' ),
630 # If autoblock is enabled, autoblock the LAST IP(s) used
635 'PerformRetroactiveAutoblock', [ $this, &$blockIds ] );
638 self::defaultRetroactiveAutoblock( $this, $blockIds );
655 if ( !$wgPutIPinRC ) {
661 $options = [
'ORDER BY' =>
'rc_timestamp DESC' ];
667 $res =
$dbr->select(
'recentchanges', [
'rc_ip' ], $conds,
670 if ( !
$res->numRows() ) {
671 # No results, don't autoblock anything
672 wfDebug(
"No IP found to retroactively autoblock\n" );
674 foreach (
$res as $row ) {
695 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
697 wfMemcKey(
'ipb',
'autoblock',
'whitelist' ),
699 function ( $curValue, &$ttl,
array &$setOpts ) {
702 return explode(
"\n",
703 wfMessage(
'autoblock_whitelist' )->inContentLanguage()->
plain() );
707 wfDebug(
"Checking the autoblock whitelist..\n" );
711 if ( substr( $line, 0, 1 ) !==
'*' ) {
715 $wlEntry = substr( $line, 1 );
716 $wlEntry = trim( $wlEntry );
718 wfDebug(
"Checking $ip against $wlEntry..." );
720 # Is the IP in this range?
722 wfDebug(
" IP $ip matches $wlEntry, not autoblocking\n" );
739 # If autoblocks are disabled, go away.
744 # Check for presence on the autoblock whitelist.
745 if ( self::isWhitelistedFromAutoblocks( $autoblockIP ) ) {
749 # Allow hooks to cancel the autoblock.
750 if ( !
Hooks::run(
'AbortAutoblock', [ $autoblockIP, &$this ] ) ) {
751 wfDebug(
"Autoblock aborted by hook.\n" );
755 # It's okay to autoblock. Go ahead and insert/update the block...
757 # Do not add a *new* block if the IP is already blocked.
760 # Check if the block is an autoblock and would exceed the user block
761 # if renewed. If so, do nothing, otherwise prolong the block time...
762 if ( $ipblock->mAuto &&
765 # Reset block timestamp to now and its expiry to
766 # $wgAutoblockExpiry in the future
767 $ipblock->updateTimestamp();
772 # Make a new block object with the desired properties.
773 $autoblock =
new Block;
774 wfDebug(
"Autoblocking {$this->getTarget()}@" . $autoblockIP .
"\n" );
775 $autoblock->setTarget( $autoblockIP );
776 $autoblock->setBlocker( $this->
getBlocker() );
778 ->inContentLanguage()->plain();
781 $autoblock->mAuto = 1;
782 $autoblock->prevents(
'createaccount', $this->
prevents(
'createaccount' ) );
783 # Continue suppressing the name if needed
785 $autoblock->prevents(
'editownusertalk', $this->
prevents(
'editownusertalk' ) );
788 if ( $this->mExpiry ==
'infinity' ) {
789 # Original block was indefinite, start an autoblock now
792 # If the user is already blocked with an expiry date, we don't
793 # want to pile on top of that.
797 # Insert the block...
798 $status = $autoblock->insert();
811 wfDebug(
"Block::deleteIfExpired() -- deleting\n" );
815 wfDebug(
"Block::deleteIfExpired() -- not expired\n" );
828 wfDebug(
"Block::isExpired() checking current " .
$timestamp .
" vs $this->mExpiry\n" );
830 if ( !$this->mExpiry ) {
849 if ( $this->mAuto ) {
854 $dbw->update(
'ipblocks',
856 'ipb_timestamp' => $dbw->timestamp( $this->mTimestamp ),
857 'ipb_expiry' => $dbw->timestamp( $this->mExpiry ),
860 'ipb_id' => $this->
getId(),
873 switch ( $this->
type ) {
874 case self::TYPE_USER:
878 case self::TYPE_RANGE:
882 throw new MWException(
"Block with invalid type" );
892 switch ( $this->
type ) {
893 case self::TYPE_USER:
897 case self::TYPE_RANGE:
901 throw new MWException(
"Block with invalid type" );
944 return wfSetVar( $this->mFromMaster, $x );
955 # You can't *not* hardblock a user
956 return $this->
getType() == self::TYPE_USER
968 # You can't put an autoblock on an IP or range as we don't have any history to
969 # look over to get more IPs from
970 return $this->
getType() == self::TYPE_USER
983 global $wgBlockDisablesLogin;
987 # For now... <evil laugh>
990 case 'createaccount':
996 case 'editownusertalk':
1003 if ( !
$res && $wgBlockDisablesLogin ) {
1007 $res = $anon->isAllowed( $action ) ?
$res :
true;
1018 if ( $this->mAuto ) {
1021 [
'class' =>
'mw-autoblockid' ],
1025 return htmlspecialchars( $this->
getTarget() );
1036 global $wgAutoblockExpiry;
1082 public static function newFromTarget( $specificTarget, $vagueTarget = null, $fromMaster =
false ) {
1088 } elseif (
$target === null && $vagueTarget ==
'' ) {
1089 # We're not going to find anything useful here
1090 # Be aware that the == '' check is explicit, since empty values will be
1091 # passed by some callers (bug 29116)
1094 } elseif ( in_array(
1098 $block =
new Block();
1099 $block->fromMaster( $fromMaster );
1101 if (
$type !== null ) {
1105 if ( $block->newLoad( $vagueTarget ) ) {
1123 if ( !count( $ipChain ) ) {
1128 $proxyLookup = MediaWikiServices::getInstance()->getProxyLookup();
1129 foreach ( array_unique( $ipChain )
as $ipaddr ) {
1130 # Discard invalid IP addresses. Since XFF can be spoofed and we do not
1131 # necessarily trust the header given to us, make sure that we are only
1132 # checking for blocks on well-formatted IP addresses (IPv4 and IPv6).
1133 # Do not treat private IP spaces as special as it may be desirable for wikis
1134 # to block those IP ranges in order to stop misbehaving proxies that spoof XFF.
1138 # Don't check trusted IPs (includes local squids which will be in every request)
1139 if ( $proxyLookup->isTrustedProxy( $ipaddr ) ) {
1142 # Check both the original IP (to check against single blocks), as well as build
1143 # the clause to check for rangeblocks for the given IP.
1144 $conds[
'ipb_address'][] = $ipaddr;
1145 $conds[] = self::getRangeCond(
IP::toHex( $ipaddr ) );
1148 if ( !count( $conds ) ) {
1152 if ( $fromMaster ) {
1157 $conds = $db->makeList( $conds,
LIST_OR );
1159 $conds = [ $conds,
'ipb_anon_only' => 0 ];
1161 $selectFields = array_merge(
1162 [
'ipb_range_start',
'ipb_range_end' ],
1165 $rows = $db->select(
'ipblocks',
1172 foreach ( $rows
as $row ) {
1173 $block = self::newFromRow( $row );
1174 if ( !$block->isExpired() ) {
1204 if ( !count( $blocks ) ) {
1206 } elseif ( count( $blocks ) == 1 ) {
1212 usort( $blocks,
function (
Block $a,
Block $b ) {
1215 return strcmp( $bWeight, $aWeight );
1218 $blocksListExact = [
1220 'disable_create' =>
false,
1224 $blocksListRange = [
1226 'disable_create' =>
false,
1230 $ipChain = array_reverse( $ipChain );
1233 foreach ( $blocks
as $block ) {
1236 if ( !$block->isHardblock() && $blocksListExact[
'hard'] ) {
1238 } elseif ( !$block->prevents(
'createaccount' ) && $blocksListExact[
'disable_create'] ) {
1242 foreach ( $ipChain
as $checkip ) {
1244 if ( (
string)$block->getTarget() === $checkip ) {
1245 if ( $block->isHardblock() ) {
1246 $blocksListExact[
'hard'] = $blocksListExact[
'hard'] ?: $block;
1247 } elseif ( $block->prevents(
'createaccount' ) ) {
1248 $blocksListExact[
'disable_create'] = $blocksListExact[
'disable_create'] ?: $block;
1249 } elseif ( $block->mAuto ) {
1250 $blocksListExact[
'auto'] = $blocksListExact[
'auto'] ?: $block;
1252 $blocksListExact[
'other'] = $blocksListExact[
'other'] ?: $block;
1256 } elseif ( array_filter( $blocksListExact ) == []
1257 && $block->getRangeStart() <= $checkipHex
1258 && $block->getRangeEnd() >= $checkipHex
1260 if ( $block->isHardblock() ) {
1261 $blocksListRange[
'hard'] = $blocksListRange[
'hard'] ?: $block;
1262 } elseif ( $block->prevents(
'createaccount' ) ) {
1263 $blocksListRange[
'disable_create'] = $blocksListRange[
'disable_create'] ?: $block;
1264 } elseif ( $block->mAuto ) {
1265 $blocksListRange[
'auto'] = $blocksListRange[
'auto'] ?: $block;
1267 $blocksListRange[
'other'] = $blocksListRange[
'other'] ?: $block;
1274 if ( array_filter( $blocksListExact ) == [] ) {
1275 $blocksList = &$blocksListRange;
1277 $blocksList = &$blocksListExact;
1280 $chosenBlock = null;
1281 if ( $blocksList[
'hard'] ) {
1282 $chosenBlock = $blocksList[
'hard'];
1283 } elseif ( $blocksList[
'disable_create'] ) {
1284 $chosenBlock = $blocksList[
'disable_create'];
1285 } elseif ( $blocksList[
'other'] ) {
1286 $chosenBlock = $blocksList[
'other'];
1287 } elseif ( $blocksList[
'auto'] ) {
1288 $chosenBlock = $blocksList[
'auto'];
1290 throw new MWException(
"Proxy block found, but couldn't be classified." );
1293 return $chosenBlock;
1306 # We may have been through this before
1309 return [
$target, self::TYPE_IP ];
1311 return [
$target, self::TYPE_USER ];
1313 } elseif (
$target === null ) {
1314 return [ null, null ];
1320 # We can still create a User if it's an IP address, but we need to turn
1321 # off validation checking (which would exclude IP addresses)
1328 # Can't create a User from an IP range
1332 # Consider the possibility that this is not a username at all
1333 # but actually an old subpage (bug #29797)
1334 if ( strpos(
$target,
'/' ) !==
false ) {
1335 # An old subpage, drill down to the user behind it
1340 if ( $userObj instanceof User ) {
1341 # Note that since numbers are valid usernames, a $target of "12345" will be
1342 # considered a User. If you want to pass a block ID, prepend a hash "#12345",
1343 # since hash characters are not valid in usernames or titles generally.
1346 } elseif ( preg_match(
'/^#\d+$/',
$target ) ) {
1347 # Autoblock reference in the form "#12345"
1352 return [ null, null ];
1417 $this->blocker =
$user;
1431 $link =
"[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]";
1437 if ( $reason ==
'' ) {
1438 $reason = $context->
msg(
'blockednoreason' )->text();
1447 $this->mAuto ?
'autoblockedtext' :
'blockedtext',
1453 $lang->formatExpiry( $this->mExpiry ),
1455 $lang->userTimeAndDate( $this->mTimestamp, $context->
getUser() ),
getBy()
Get the user id of the blocking sysop.
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
static getRangeCond($start, $end=null)
Get a set of SQL conditions which will select rangeblocks encompassing a given range.
setBlocker($user)
Set the user who implemented (or will implement) this block.
Interface for objects which can provide a MediaWiki context on request.
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
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
the array() calling protocol came about after MediaWiki 1.4rc1.
static defaultRetroactiveAutoblock(Block $block, array &$blockIds)
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block...
static sanitizeIP($ip)
Convert an IP into a verbose, uppercase, normalized form.
static chooseBlock(array $blocks, array $ipChain)
From a list of multiple blocks, find the most exact and strongest Block.
static isInRange($addr, $range)
Determine if a given IPv4/IPv6 address is in a given CIDR network.
static isWhitelistedFromAutoblocks($ip)
Checks whether a given IP is on the autoblock whitelist.
static sanitizeRange($range)
Gets rid of unneeded numbers in quad-dotted/octet IP strings For example, 127.111.113.151/24 -> 127.111.113.0/24.
processing should stop and the error should be shown to the user * false
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
isValid()
Is the block address valid (i.e.
static getCacheSetOptions(IDatabase $db1)
Merge the result of getSessionLagStatus() for several DBs using the most pessimistic values to estima...
msg()
Get a Message object with context set.
getType()
Get the type of target for this particular block.
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
if(!isset($args[0])) $lang
equals(Block $block)
Check if two blocks are effectively equal.
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
static newFromId($id)
Static factory method for creation from a given user ID.
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 MediaWikiServices
__construct($options=[])
Create a new block with specified parameters on a user, IP or IP range.
when a variable name is used in a it is silently declared as a new local masking the global
timestamp($ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
getName()
Get the user name, or the IP of an anonymous user.
update()
Update a block in the DB with new parameters.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
getRangeEnd()
Get the IP address at the end of the range in Hex form.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
getAutoblockUpdateArray()
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
deleteIfExpired()
Check if a block has expired.
getUser()
Get the User object.
insert($dbw=null)
Insert a block into the block table.
delete($table, $conds, $fname=__METHOD__)
DELETE query wrapper.
wfReadOnly()
Check whether the wiki is in read-only mode.
int $type
Block::TYPE_ constant.
getTargetAndType()
Get the target and target type for this particular Block.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"<
static newFromTarget($specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
getRedactedName()
Get the block name, but with autoblocked IPs hidden as per standard privacy policy.
static isValid($ip)
Validate an IP address.
setTarget($target)
Set the target for this block, and update $this->type accordingly.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
doAutoblock($autoblockIP)
Autoblocks the given IP, referring to this Block.
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
static parseTarget($target)
From an existing Block, get the target and the type of target.
static purgeExpired()
Purge expired blocks from the ipblocks table.
newLoad($vagueTarget=null)
Load a block from the database which affects the already-set $this->target: 1) A block directly on th...
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static toHex($ip)
Return a zero-padded upper case hexadecimal representation of an IP address.
getLanguage()
Get the Language object.
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
static newFromRow($row)
Create a new Block object from a database row.
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
doRetroactiveAutoblock()
Retroactively autoblocks the last IP used by the user (if it is a user) blocked by this Block...
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
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
static getBlocksForIPList(array $ipChain, $isAnon, $fromMaster=false)
Get all blocks that match any IP from an array of IP addresses.
int $forcedTargetID
Hack for foreign blocking (CentralAuth)
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
updateTimestamp()
Update the timestamp on autoblocks.
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
prevents($action, $x=null)
Get/set whether the Block prevents a given action.
static getAutoblockExpiry($timestamp)
Get a timestamp of the expiry for autoblocks.
getBlocker()
Get the user who implemented this block.
static parseRange($range)
Given a string range in a number of formats, return the start and end of the range in hexadecimal...
getId()
Get the user's ID.
getPermissionsError(IContextSource $context)
Get the key and parameters for the corresponding error message.
static selectFields()
Return the list of ipblocks fields that should be selected to create a new block. ...
getTarget()
Get the target for this particular Block.
getUserPage()
Get this user's personal page title.
static newFromID($id)
Load a blocked user from their block id.
getDatabaseArray($db=null)
Get an array suitable for passing to $dbw->insert() or $dbw->update()
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
fromMaster($x=null)
Get/set a flag determining whether the master is used for reads.
wfMemcKey()
Make a cache key for the local wiki.
addQuotes($s)
Adds quotes and backslashes.
isHardblock($x=null)
Get/set whether the Block is a hardblock (affects logged-in users on a given IP/range) ...
initFromRow($row)
Given a database row from the ipblocks table, initialize member variables.
static isValidBlock($ipblock)
Validate an IP Block (valid address WITH a valid prefix).
getRangeStart()
Get the IP address at the start of the range in Hex form.
getRequest()
Get the WebRequest object.
static getIpFragment($hex)
Get the component of an IP address which is certain to be the same between an IP address and a rangeb...
getByName()
Get the username of the blocking sysop.
Basic database interface for live and lazy-loaded relation database handles.
isExpired()
Has the block expired?