Go to the documentation of this file.
51 parent::__construct(
'Block',
'block' );
61 parent::checkExecutePermissions(
$user );
63 # bug 15810: blocked admins should have limited access here
65 if ( $status !==
true ) {
76 # Extract variables from the request. Try not to get into a situation where we
77 # need to extract *every* variable from the form just for processing here, but
78 # there are legitimate uses for some variables
81 if ( $this->target instanceof
User ) {
82 # Set the 'relevant user' in the skin, so it displays links like Contributions,
83 # User logs, UserRights, etc.
84 $this->
getSkin()->setRelevantUser( $this->target );
88 $this->requestedHideUser = $request->getBool(
'wpHideUser' );
97 $form->setWrapperLegendMsg(
'blockip-legend' );
98 $form->setHeaderText(
'' );
99 $form->setSubmitCallback(
array( __CLASS__,
'processUIForm' ) );
101 $msg = $this->alreadyBlocked ?
'ipb-change-block' :
'ipbsubmit';
102 $form->setSubmitTextMsg( $msg );
104 # Don't need to do anything if the form has been posted
105 if ( !$this->
getRequest()->wasPosted() && $this->preErrors ) {
110 array(
'class' =>
'error' ),
122 global $wgBlockAllowsUTEdit;
131 'label-message' =>
'ipadressorusername',
133 'id' =>
'mw-bi-target',
137 'validation-callback' =>
array( __CLASS__,
'validateTargetField' ),
140 'type' => !count( $suggestedDurations ) ?
'text' :
'selectorother',
141 'label-message' =>
'ipbexpiry',
144 'options' => $suggestedDurations,
145 'other' => $this->
msg(
'ipbother' )->
text(),
146 'default' => $this->
msg(
'ipb-default-expiry' )->inContentLanguage()->
text(),
149 'type' =>
'selectandother',
150 'label-message' =>
'ipbreason',
151 'options-message' =>
'ipbreason-dropdown',
153 'CreateAccount' =>
array(
155 'label-message' =>
'ipbcreateaccount',
160 if ( self::canBlockEmail(
$user ) ) {
161 $a[
'DisableEmail'] =
array(
163 'label-message' =>
'ipbemailban',
167 if ( $wgBlockAllowsUTEdit ) {
168 $a[
'DisableUTEdit'] =
array(
170 'label-message' =>
'ipb-disableusertalk',
175 $a[
'AutoBlock'] =
array(
177 'label-message' =>
'ipbenableautoblock',
181 # Allow some users to hide name from block log, blocklist and listusers
182 if (
$user->isAllowed(
'hideuser' ) ) {
183 $a[
'HideUser'] =
array(
185 'label-message' =>
'ipbhidename',
186 'cssclass' =>
'mw-block-hideuser',
190 # Watchlist their user page? (Only if user is logged in)
191 if (
$user->isLoggedIn() ) {
194 'label-message' =>
'ipbwatchuser',
198 $a[
'HardBlock'] =
array(
200 'label-message' =>
'ipb-hardblock',
204 # This is basically a copy of the Target field, but the user can't change it, so we
205 # can see if the warnings we maybe showed to the user before still apply
206 $a[
'PreviousTarget'] =
array(
211 # We'll turn this into a checkbox if we need to
212 $a[
'Confirm'] =
array(
215 'label-message' =>
'ipb-confirm',
234 # This will be overwritten by request data
235 $fields[
'Target'][
'default'] = (string)$this->target;
238 $fields[
'PreviousTarget'][
'default'] = (string)$this->target;
242 if ( $block instanceof
Block && !$block->mAuto # The
block exists and isn
't an autoblock
243 && ( $this->type != Block::TYPE_RANGE # The block isn't a rangeblock
244 || $block->getTarget() ==
$this->target ) # or
if it is, the range
is what we
're about to block
246 $fields['HardBlock
']['default'] = $block->isHardblock();
247 $fields['CreateAccount
']['default'] = $block->prevents( 'createaccount
' );
248 $fields['AutoBlock
']['default'] = $block->isAutoblocking();
250 if ( isset( $fields['DisableEmail
'] ) ) {
251 $fields['DisableEmail
']['default'] = $block->prevents( 'sendemail
' );
254 if ( isset( $fields['HideUser
'] ) ) {
255 $fields['HideUser
']['default'] = $block->mHideName;
258 if ( isset( $fields['DisableUTEdit
'] ) ) {
259 $fields['DisableUTEdit
']['default'] = $block->prevents( 'editownusertalk
' );
262 // If the username was hidden (ipb_deleted == 1), don't show the reason
264 if ( !$block->mHideName || $this->getUser()->isAllowed(
'hideuser' ) ) {
265 $fields[
'Reason'][
'default'] = $block->mReason;
267 $fields[
'Reason'][
'default'] =
'';
271 # Ok, so we got a POST submission asking us to reblock a user. So show the
272 # confirm checkbox; the user will only see it if they haven't previously
273 $fields[
'Confirm'][
'type'] =
'check';
275 # We got a target, but it wasn't a POST request, so the user must have gone
276 # to a link like [[Special:Block/User]]. We don't need to show the checkbox
277 # as long as they go ahead and block *that* user
278 $fields[
'Confirm'][
'default'] = 1;
281 if ( $block->mExpiry ==
'infinity' ) {
282 $fields[
'Expiry'][
'default'] =
'infinite';
287 $this->alreadyBlocked =
true;
291 # We always need confirmation to do HideUser
292 if ( $this->requestedHideUser ) {
293 $fields[
'Confirm'][
'type'] =
'check';
294 unset( $fields[
'Confirm'][
'default'] );
295 $this->preErrors[] =
array(
'ipb-confirmhideuser',
'ipb-confirmaction' );
298 # Or if the user is trying to block themselves
300 $fields[
'Confirm'][
'type'] =
'check';
301 unset( $fields[
'Confirm'][
'default'] );
302 $this->preErrors[] =
array(
'ipb-blockingself',
'ipb-confirmaction' );
310 protected function preText() {
311 $this->getOutput()->addModules(
'mediawiki.special.block' );
313 $text = $this->msg(
'blockiptext' )->parse();
315 $otherBlockMessages =
array();
316 if ( $this->target !==
null ) {
317 # Get other blocks, i.e. from GlobalBlocking or TorBlock extension
318 wfRunHooks(
'OtherBlockLogLink',
array( &$otherBlockMessages, $this->target ) );
320 if ( count( $otherBlockMessages ) ) {
324 $this->msg(
'ipb-otherblocks-header', count( $otherBlockMessages ) )->parse()
329 foreach ( $otherBlockMessages
as $link ) {
335 array(
'class' =>
'mw-blockip-alreadyblocked' ),
350 protected function postText() {
353 # Link to the user's contributions, if applicable
354 if ( $this->target instanceof
User ) {
358 $this->msg(
'ipb-blocklist-contribs', $this->target->getName() )->escaped()
362 # Link to unblock the specified user, or to a blank unblock form
363 if ( $this->target instanceof
User ) {
364 $message = $this->msg(
'ipb-unblock-addr',
wfEscapeWikiText( $this->target->getName() ) )->parse();
367 $message = $this->msg(
'ipb-unblock' )->parse();
372 # Link to the block list
375 $this->msg(
'ipb-blocklist' )->escaped()
378 $user = $this->getUser();
380 # Link to edit the block dropdown reasons, if applicable
381 if (
$user->isAllowed(
'editinterface' ) ) {
384 $this->msg(
'ipb-edit-dropdown' )->escaped(),
386 array(
'action' =>
'edit' )
392 array(
'class' =>
'mw-ipb-conveniencelinks' ),
393 $this->getLanguage()->pipeList( $links )
396 $userTitle = self::getTargetUserTitle( $this->target );
398 # Get relevant extracts from the block and suppression logs, if possible
408 'msgKey' =>
array(
'blocklog-showlog', $userTitle->getText() ),
409 'showIfEmpty' =>
false
414 # Add suppression block entries if allowed
415 if (
$user->isAllowed(
'suppressionlog' ) ) {
423 'conds' =>
array(
'log_action' =>
array(
'block',
'reblock',
'unblock' ) ),
424 'msgKey' =>
array(
'blocklog-showsuppresslog', $userTitle->getText() ),
425 'showIfEmpty' =>
false
442 protected static function getTargetUserTitle( $target ) {
443 if ( $target instanceof
User ) {
444 return $target->getUserPage();
460 public static function getTargetAndType( $par,
WebRequest $request =
null ) {
467 # The HTMLForm will check wpTarget first and only if it doesn't get
468 # a value use the default, which will be generated from the options
469 # below; so this has to have a higher precedence here than $par, or
470 # we could end up with different values in $this->target and the HTMLForm!
472 $target = $request->getText(
'wpTarget',
null );
480 $target = $request->getText(
'ip',
null );
486 $target = $request->getText(
'wpBlockAddress',
null );
495 if (
$type !==
null ) {
500 return array(
null,
null );
511 public static function validateTargetField(
$value, $alldata,
$form ) {
512 $status = self::validateTarget(
$value,
$form->getUser() );
513 if ( !$status->isOK() ) {
514 $errors = $status->getErrorsArray();
516 return call_user_func_array(
array(
$form,
'msg' ), $errors[0] );
538 if ( $target->isAnon() ) {
545 $unblockStatus = self::checkUnblockSelf( $target,
$user );
546 if ( $unblockStatus !==
true ) {
547 $status->fatal(
'badaccess', $unblockStatus );
550 list( $ip, $range ) = explode(
'/', $target, 2 );
553 (
IP::isIPv4( $ip ) && $wgBlockCIDRLimit[
'IPv4'] == 32 ) ||
554 (
IP::isIPv6( $ip ) && $wgBlockCIDRLimit[
'IPv6'] == 128 )
557 $status->fatal(
'range_block_disabled' );
565 $status->fatal(
'ip_range_invalid' );
568 if (
IP::isIPv4( $ip ) && $range < $wgBlockCIDRLimit[
'IPv4'] ) {
569 $status->fatal(
'ip_range_toolarge', $wgBlockCIDRLimit[
'IPv4'] );
572 if (
IP::isIPv6( $ip ) && $range < $wgBlockCIDRLimit[
'IPv6'] ) {
573 $status->fatal(
'ip_range_toolarge', $wgBlockCIDRLimit[
'IPv6'] );
578 $status->fatal(
'badipaddress' );
591 return self::processForm( $data,
$form->getContext() );
601 global $wgBlockAllowsUTEdit, $wgHideUserContribLimit;
603 $performer = $context->
getUser();
608 # This might have been a hidden field or a checkbox, so interesting data
610 $data[
'Confirm'] = !in_array( $data[
'Confirm'],
array(
'',
'0',
null,
false ),
true );
613 list( $target,
$type ) = self::getTargetAndType( $data[
'Target'] );
616 $target =
$user->getName();
617 $userId =
$user->getId();
619 # Give admins a heads-up before they go and block themselves. Much messier
620 # to do this for IPs, but it's pretty unlikely they'd ever get the 'block'
621 # permission anyway, although the code does allow for it.
622 # Note: Important to use $target instead of $data['Target']
623 # since both $data['PreviousTarget'] and $target are normalized
624 # but $data['target'] gets overriden by (non-normalized) request variable
625 # from previous request.
626 if ( $target === $performer->getName() &&
627 ( $data[
'PreviousTarget'] !== $target || !$data[
'Confirm'] )
629 return array(
'ipb-blockingself',
'ipb-confirmaction' );
634 $target = $target->getName();
637 # This should have been caught in the form field validation
638 return array(
'badipaddress' );
641 if ( ( strlen( $data[
'Expiry'] ) == 0 ) || ( strlen( $data[
'Expiry'] ) > 50 )
642 || !self::parseExpiryInput( $data[
'Expiry'] )
644 return array(
'ipb_expiry_invalid' );
647 if ( !isset( $data[
'DisableEmail'] ) ) {
648 $data[
'DisableEmail'] =
false;
651 # If the user has done the form 'properly', they won't even have been given the
652 # option to suppress-block unless they have the 'hideuser' permission
653 if ( !isset( $data[
'HideUser'] ) ) {
654 $data[
'HideUser'] =
false;
657 if ( $data[
'HideUser'] ) {
658 if ( !$performer->isAllowed(
'hideuser' ) ) {
659 # this codepath is unreachable except by a malicious user spoofing forms,
660 # or by race conditions (user has oversight and sysop, loads block form,
661 # and is de-oversighted before submission); so need to fail completely
662 # rather than just silently disable hiding
663 return array(
'badaccess-group0' );
666 # Recheck params here...
668 $data[
'HideUser'] =
false; #
IP users should not be hidden
669 } elseif ( !in_array( $data[
'Expiry'],
array(
'infinite',
'infinity',
'indefinite' ) ) ) {
671 return array(
'ipb_expiry_temp' );
672 } elseif ( $wgHideUserContribLimit !==
false
673 &&
$user->getEditCount() > $wgHideUserContribLimit
675 # Typically, the user should have a handful of edits.
676 # Disallow hiding users with many edits for performance.
678 Message::numParam( $wgHideUserContribLimit ) ) );
679 } elseif ( !$data[
'Confirm'] ) {
680 return array(
'ipb-confirmhideuser',
'ipb-confirmaction' );
684 # Create block object.
685 $block =
new Block();
686 $block->setTarget( $target );
687 $block->setBlocker( $performer );
688 $block->mReason = $data[
'Reason'][0];
689 $block->mExpiry = self::parseExpiryInput( $data[
'Expiry'] );
690 $block->prevents(
'createaccount', $data[
'CreateAccount'] );
691 $block->prevents(
'editownusertalk', ( !$wgBlockAllowsUTEdit || $data[
'DisableUTEdit'] ) );
692 $block->prevents(
'sendemail', $data[
'DisableEmail'] );
693 $block->isHardblock( $data[
'HardBlock'] );
694 $block->isAutoblocking( $data[
'AutoBlock'] );
695 $block->mHideName = $data[
'HideUser'];
697 $reason =
array(
'hookaborted' );
698 if ( !
wfRunHooks(
'BlockIp',
array( &$block, &$performer, &$reason ) ) ) {
702 # Try to insert block. Is there a conflicting block?
703 $status = $block->insert();
705 # Indicates whether the user is confirming the block and is aware of
706 # the conflict (did not change the block target in the meantime)
707 $blockNotConfirmed = !$data[
'Confirm'] || ( array_key_exists(
'PreviousTarget', $data )
708 && $data[
'PreviousTarget'] !== $target );
710 # Special case for API - bug 32434
711 $reblockNotAllowed = ( array_key_exists(
'Reblock', $data ) && !$data[
'Reblock'] );
713 # Show form unless the user is already aware of this...
714 if ( $blockNotConfirmed || $reblockNotAllowed ) {
715 return array(
array(
'ipb_already_blocked', $block->getTarget() ) );
716 # Otherwise, try to update the block...
718 # This returns direct blocks before autoblocks/rangeblocks, since we should
719 # be sure the user is blocked by now it should work for our purposes
722 if ( $block->equals( $currentBlock ) ) {
723 return array(
array(
'ipb_already_blocked', $block->getTarget() ) );
726 # If the name was hidden and the blocking user cannot hide
727 # names, then don't allow any block changes...
728 if ( $currentBlock->mHideName && !$performer->isAllowed(
'hideuser' ) ) {
729 return array(
'cant-see-hidden-user' );
732 $currentBlock->isHardblock( $block->isHardblock() );
733 $currentBlock->prevents(
'createaccount', $block->prevents(
'createaccount' ) );
734 $currentBlock->mExpiry = $block->mExpiry;
735 $currentBlock->isAutoblocking( $block->isAutoblocking() );
736 $currentBlock->mHideName = $block->mHideName;
737 $currentBlock->prevents(
'sendemail', $block->prevents(
'sendemail' ) );
738 $currentBlock->prevents(
'editownusertalk', $block->prevents(
'editownusertalk' ) );
739 $currentBlock->mReason = $block->mReason;
741 $status = $currentBlock->update();
743 $logaction =
'reblock';
745 # Unset _deleted fields if requested
746 if ( $currentBlock->mHideName && !$data[
'HideUser'] ) {
750 # If hiding/unhiding a name, this should go in the private logs
751 if ( (
bool)$currentBlock->mHideName ) {
752 $data[
'HideUser'] =
true;
756 $logaction =
'block';
761 # Set *_deleted fields if requested
762 if ( $data[
'HideUser'] ) {
766 # Can't watch a rangeblock
771 # Block constructor sanitizes certain block options on insert
772 $data[
'BlockEmail'] = $block->prevents(
'sendemail' );
773 $data[
'AutoBlock'] = $block->isAutoblocking();
775 # Prepare log parameters
776 $logParams =
array();
777 $logParams[] = $data[
'Expiry'];
778 $logParams[] = self::blockLogFlags( $data,
$type );
780 # Make log entry, if the name is hidden, put it in the oversight log
781 $log_type = $data[
'HideUser'] ?
'suppress' :
'block';
782 $log =
new LogPage( $log_type );
783 $log_id = $log->addEntry(
790 # Relate log ID to block IDs (bug 25763)
791 $blockIds = array_merge(
array( $status[
'id'] ), $status[
'autoIds'] );
792 $log->addRelations(
'ipb_id', $blockIds, $log_id );
806 public static function getSuggestedDurations( $lang =
null ) {
808 $msg = $lang ===
null
809 ?
wfMessage(
'ipboptions' )->inContentLanguage()->text()
810 :
wfMessage(
'ipboptions' )->inLanguage( $lang )->text();
816 foreach ( explode(
',', $msg )
as $option ) {
817 if ( strpos( $option,
':' ) ===
false ) {
818 $option =
"$option:$option";
821 list( $show,
$value ) = explode(
':', $option );
822 $a[htmlspecialchars( $show )] = htmlspecialchars(
$value );
834 public static function parseExpiryInput( $expiry ) {
836 if ( $infinity ==
null ) {
840 if ( $expiry ==
'infinite' || $expiry ==
'indefinite' ) {
843 $expiry = strtotime( $expiry );
845 if ( $expiry < 0 || $expiry ===
false ) {
860 public static function canBlockEmail(
$user ) {
861 global $wgEnableUserEmail, $wgSysopEmailBans;
863 return ( $wgEnableUserEmail && $wgSysopEmailBans &&
$user->isAllowed(
'blockemail' ) );
874 public static function checkUnblockSelf(
$user,
User $performer ) {
875 if ( is_int(
$user ) ) {
877 } elseif ( is_string(
$user ) ) {
883 # User is trying to unblock themselves
884 if ( $performer->
isAllowed(
'unblockself' ) ) {
886 # User blocked themselves and is now trying to reverse it
890 return 'ipbnounblockself';
893 # User is trying to block/unblock someone else
908 protected static function blockLogFlags(
array $data,
$type ) {
909 global $wgBlockAllowsUTEdit;
912 # when blocking a user the option 'anononly' is not available/has no effect
913 # -> do not write this into log
919 if ( $data[
'CreateAccount'] ) {
924 # Same as anononly, this is not displayed when blocking an IP address
930 if ( $data[
'DisableEmail'] ) {
935 if ( $wgBlockAllowsUTEdit && $data[
'DisableUTEdit'] ) {
940 if ( $data[
'HideUser'] ) {
945 return implode(
',',
$flags );
953 public function onSubmit(
array $data ) {
962 public function onSuccess() {
964 $out->setPageTitle( $this->msg(
'blockipsuccesssub' ) );
968 protected function getGroupName() {
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static newFromId( $id)
Static factory method for creation from a given user ID.
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
getId()
Get the user's ID.
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for except in special pages derived from QueryPage It s a common pitfall for new developers to submit code containing SQL queries which examine huge numbers of rows Remember that COUNT * is(N), counting rows in atable is like counting beans in a bucket.------------------------------------------------------------------------ Replication------------------------------------------------------------------------The largest installation of MediaWiki, Wikimedia, uses a large set ofslave MySQL servers replicating writes made to a master MySQL server. Itis important to understand the issues associated with this setup if youwant to write code destined for Wikipedia.It 's often the case that the best algorithm to use for a given taskdepends on whether or not replication is in use. Due to our unabashedWikipedia-centrism, we often just use the replication-friendly version, but if you like, you can use wfGetLB() ->getServerCount() > 1 tocheck to see if replication is in use.===Lag===Lag primarily occurs when large write queries are sent to the master.Writes on the master are executed in parallel, but they are executed inserial when they are replicated to the slaves. The master writes thequery to the binlog when the transaction is committed. The slaves pollthe binlog and start executing the query as soon as it appears. They canservice reads while they are performing a write query, but will not readanything more from the binlog and thus will perform no more writes. Thismeans that if the write query runs for a long time, the slaves will lagbehind the master for the time it takes for the write query to complete.Lag can be exacerbated by high read load. MediaWiki 's load balancer willstop sending reads to a slave when it is lagged by more than 30 seconds.If the load ratios are set incorrectly, or if there is too much loadgenerally, this may lead to a slave permanently hovering around 30seconds lag.If all slaves are lagged by more than 30 seconds, MediaWiki will stopwriting to the database. All edits and other write operations will berefused, with an error returned to the user. This gives the slaves achance to catch up. Before we had this mechanism, the slaves wouldregularly lag by several minutes, making review of recent editsdifficult.In addition to this, MediaWiki attempts to ensure that the user seesevents occurring on the wiki in chronological order. A few seconds of lagcan be tolerated, as long as the user sees a consistent picture fromsubsequent requests. This is done by saving the master binlog positionin the session, and then at the start of each request, waiting for theslave to catch up to that position before doing any reads from it. Ifthis wait times out, reads are allowed anyway, but the request isconsidered to be in "lagged slave mode". Lagged slave mode can bechecked by calling wfGetLB() ->getLaggedSlaveMode(). The onlypractical consequence at present is a warning displayed in the pagefooter.===Lag avoidance===To avoid excessive lag, queries which write large numbers of rows shouldbe split up, generally to write one row at a time. Multi-row INSERT ...SELECT queries are the worst offenders should be avoided altogether.Instead do the select first and then the insert.===Working with lag===Despite our best efforts, it 's not practical to guarantee a low-lagenvironment. Lag will usually be less than one second, but mayoccasionally be up to 30 seconds. For scalability, it 's very importantto keep load on the master low, so simply sending all your queries tothe master is not the answer. So when you have a genuine need forup-to-date data, the following approach is advised:1) Do a quick query to the master for a sequence number or timestamp 2) Run the full query on the slave and check if it matches the data you gotfrom the master 3) If it doesn 't, run the full query on the masterTo avoid swamping the master every time the slaves lag, use of thisapproach should be kept to a minimum. In most cases you should just readfrom the slave and let the user deal with the delay.------------------------------------------------------------------------ Lock contention------------------------------------------------------------------------Due to the high write rate on Wikipedia(and some other wikis), MediaWiki developers need to be very careful to structure their writesto avoid long-lasting locks. By default, MediaWiki opens a transactionat the first query, and commits it before the output is sent. Locks willbe held from the time when the query is done until the commit. So youcan reduce lock time by doing as much processing as possible before youdo your write queries.Often this approach is not good enough, and it becomes necessary toenclose small groups of queries in their own transaction. Use thefollowing syntax:$dbw=wfGetDB(DB_MASTER
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
static processForm(array $data, IContextSource $context)
Given the form data, actually implement a block.
preText()
Add header elements like block log entries, etc.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead $form
static canBlockEmail( $user)
Can we do an email block?
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static newGood( $value=null)
Factory function for good results.
A collection of public static functions to play with IP address and IP blocks.
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
Special page which uses an HTMLForm to handle processing.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static isIPv6( $ip)
Given a string, determine if it as valid IP in IPv6 only.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
getSkin()
Shortcut to get the skin being used for this instance.
checkExecutePermissions(User $user)
Checks that the user can unblock themselves if they are trying to do so.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
getName()
Get the name of this Special Page.
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
setParameter( $par)
Handle some magic here.
static linkKnown( $target, $html=null, $customAttribs=array(), $query=array(), $options=array( 'known', 'noclasses'))
Identical to link(), except $options defaults to 'known'.
static unsuppressUserName( $name, $userId, $dbw=null)
postText()
Add footer elements to the form.
static link( $target, $html=null, $customAttribs=array(), $query=array(), $options=array())
This function returns an HTML link to the given target.
static parseTarget( $target)
From an existing Block, get the target and the type of target.
maybeAlterFormDefaults(&$fields)
If the user has already been blocked with similar settings, load that block and change the defaults f...
alterForm(HTMLForm $form)
Customizes the HTMLForm a bit.
A special page that allows users with 'block' right to block users from editing pages and other actio...
Bool $requestedHideUser
whether the previous submission of the form asked for HideUser *
const IGNORE_USER_RIGHTS
Constant to specify that user rights 'editmywatchlist' and 'viewmywatchlist' should not be checked.
Class to simplify the use of log pages.
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 just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables 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 unset offset - wrap String Wrap the message in html(usually something like "<
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
static getTargetUserTitle( $target)
Get a user page target for things like logs.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
getUser()
Shortcut to get the User executing this instance.
when a variable name is used in a it is silently declared as a new masking the global
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
Integer $type
Block::TYPE_ constant *.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
msg()
Wrapper around wfMessage that sets the current context.
string $par
The sub-page of the special page.
User String $previousTarget
the previous block target *
static getSuggestedDurations( $lang=null)
Get an array of suggested block durations from MediaWiki:Ipboptions.
getRequest()
Get the WebRequest being used for this instance.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getFormFields()
Get the HTMLForm descriptor array for the block form.
getUser()
Get the User object.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LoginAuthenticateAudit' this hook is for auditing only etc block
blockedBy()
If user is blocked, return the name of the user who placed the block.
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 account $user
static isIPv4( $ip)
Given a string, determine if it as valid IP in IPv4 only.
Interface for objects which can provide a context on request.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
=Architecture==Two class hierarchies are used to provide the functionality associated with the different content models:*Content interface(and AbstractContent base class) define functionality that acts on the concrete content of a page, and *ContentHandler base class provides functionality specific to a content model, but not acting on concrete content. The most important function of ContentHandler is to act as a factory for the appropriate implementation of Content. These Content objects are to be used by MediaWiki everywhere, instead of passing page content around as text. All manipulation and analysis of page content must be done via the appropriate methods of the Content object. For each content model, a subclass of ContentHandler has to be registered with $wgContentHandlers. The ContentHandler object for a given content model can be obtained using ContentHandler::getForModelID($id). Also Title, WikiPage and Revision now have getContentHandler() methods for convenience. ContentHandler objects are singletons that provide functionality specific to the content type, but not directly acting on the content of some page. ContentHandler::makeEmptyContent() and ContentHandler::unserializeContent() can be used to create a Content object of the appropriate type. However, it is recommended to instead use WikiPage::getContent() resp. Revision::getContent() to get a page 's content as a Content object. These two methods should be the ONLY way in which page content is accessed. Another important function of ContentHandler objects is to define custom action handlers for a content model, see ContentHandler::getActionOverrides(). This is similar to what WikiPage::getActionOverrides() was already doing.==Serialization==With the ContentHandler facility, page content no longer has to be text based. Objects implementing the Content interface are used to represent and handle the content internally. For storage and data exchange, each content model supports at least one serialization format via ContentHandler::serializeContent($content). The list of supported formats for a given content model can be accessed using ContentHandler::getSupportedFormats(). Content serialization formats are identified using MIME type like strings. The following formats are built in:*text/x-wiki - wikitext *text/javascript - for js pages *text/css - for css pages *text/plain - for future use, e.g. with plain text messages. *text/html - for future use, e.g. with plain html messages. *application/vnd.php.serialized - for future use with the api and for extensions *application/json - for future use with the api, and for use by extensions *application/xml - for future use with the api, and for use by extensions In PHP, use the corresponding CONTENT_FORMAT_XXX constant. Note that when using the API to access page content, especially action=edit, action=parse and action=query &prop=revisions, the model and format of the content should always be handled explicitly. Without that information, interpretation of the provided content is not reliable. The same applies to XML dumps generated via maintenance/dumpBackup.php or Special:Export. Also note that the API will provide encapsulated, serialized content - so if the API was called with format=json, and contentformat is also json(or rather, application/json), the page content is represented as a string containing an escaped json structure. Extensions that use JSON to serialize some types of page content may provide specialized API modules that allow access to that content in a more natural form.==Compatibility==The ContentHandler facility is introduced in a way that should allow all existing code to keep functioning at least for pages that contain wikitext or other text based content. However, a number of functions and hooks have been deprecated in favor of new versions that are aware of the page 's content model, and will now generate warnings when used. Most importantly, the following functions have been deprecated:*Revisions::getText() and Revisions::getRawText() is deprecated in favor Revisions::getContent() *WikiPage::getText() is deprecated in favor WikiPage::getContent() Also, the old Article::getContent()(which returns text) is superceded by Article::getContentObject(). However, both methods should be avoided since they do not provide clean access to the page 's actual content. For instance, they may return a system message for non-existing pages. Use WikiPage::getContent() instead. Code that relies on a textual representation of the page content should eventually be rewritten. However, ContentHandler::getContentText() provides a stop-gap that can be used to get text for a page. Its behavior is controlled by $wgContentHandlerTextFallback it
onSubmit(array $data)
Process the form on POST submission.
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
static validateTargetField( $value, $alldata, $form)
HTMLForm field validation-callback for Target field.
static validateTarget( $value, User $user)
Validate a block target.
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 parseExpiryInput( $expiry)
Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute ("24 May 2034",...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
static checkUnblockSelf( $user, User $performer)
bug 15810: blocked admins should not be able to block/unblock others, and probably shouldn't be able ...
static processUIForm(array $data, HTMLForm $form)
Submit callback for an HTMLForm object, will simply pass.
static getTargetAndType( $par, WebRequest $request=null)
Determine the target of the block, and the type of target TODO: should be in Block....
static blockLogFlags(array $data, $type)
Return a comma-delimited list of "flags" to be passed to the log reader for this block,...
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
isBlocked( $bFromSlave=true)
Check if user is blocked.
An error page which can definitely be safely rendered using the OutputPage.
static doWatch(Title $title, User $user, $checkRights=WatchedItem::CHECK_USER_RIGHTS)
Watch a page.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getName()
Get the user name, or the IP of an anonymous user.
const TS_RFC2822
RFC 2822 format, for E-mail and HTTP headers.
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
static suppressUserName( $name, $userId, $dbw=null)
static showLogExtract(&$out, $types=array(), $page='', $user='', $param=array())
Show log extract.
isAllowed( $action='')
Internal mechanics of testing a permission.