54 $a = mt_rand( 0, 100 );
55 $b = mt_rand( 0, 10 );
59 $op = mt_rand( 0, 1 ) ?
'+' :
'−';
64 $answer = ( $op ==
'+' ) ? ( $a + $b ) : ( $a - $b );
65 return [
'question' => $test,
'answer' => $answer ];
75 $resultArr[
'captcha'][
'id'] = $index;
76 $resultArr[
'captcha'][
'question'] = $captcha[
'question'];
87 'mime' =>
'text/plain',
125 'html' =>
"<p><label for=\"wpCaptchaWord\">{$captcha['question']} = </label>" .
126 Xml::element(
'input', [
127 'name' =>
'wpCaptchaWord',
128 'class' =>
'mw-ui-input',
129 'id' =>
'wpCaptchaWord',
131 'autocomplete' =>
'off',
133 'tabindex' => $tabIndex ] ) .
135 Xml::element(
'input', [
137 'name' =>
'wpCaptchaId',
138 'id' =>
'wpCaptchaId',
139 'value' => $index ] )
162 if ( !$formInformation ) {
165 if ( isset( $formInformation[
'html'] ) ) {
166 $out->addHTML( $formInformation[
'html'] );
168 if ( isset( $formInformation[
'modules'] ) ) {
169 $out->addModules( $formInformation[
'modules'] );
171 if ( isset( $formInformation[
'modulestyles'] ) ) {
172 $out->addModuleStyles( $formInformation[
'modulestyles'] );
174 if ( isset( $formInformation[
'headitems'] ) ) {
175 $out->addHeadItems( $formInformation[
'headitems'] );
185 return $captchaData[
'question'] .
' =';
194 $page = $editPage->getArticle()->getPage();
195 if ( !isset( $page->ConfirmEdit_ActivateCaptcha ) ) {
199 if ( $this->action !==
'edit' ) {
200 unset( $page->ConfirmEdit_ActivateCaptcha );
201 $out->addHTML( $this->
getMessage( $this->action )->parseAsBlock() );
211 $context = $editPage->getArticle()->getContext();
212 $page = $editPage->getArticle()->getPage();
214 if ( isset( $page->ConfirmEdit_ActivateCaptcha ) ||
215 $this->shouldCheck( $page,
'',
'',
$context )
217 $out->addHTML( $this->
getMessage( $this->action )->parseAsBlock() );
220 unset( $page->ConfirmEdit_ActivateCaptcha );
233 $name = static::$messagePrefix .
$action;
237 return $msg->isDisabled() ?
wfMessage( static::$messagePrefix .
'edit' ) : $msg;
247 $out = $form->getOutput();
248 $user = $form->getUser();
250 $this->action =
'sendemail';
255 $formMetainfo = $formInformation;
256 unset( $formMetainfo[
'html'] );
258 $form->addFooterText(
259 "<div class='captcha'>" .
260 $out->parse( $this->getMessage(
'sendemail' )->plain() ) .
261 $formInformation[
'html'] .
274 global $wgCaptchaBadLoginExpiration, $wgCaptchaBadLoginPerUserExpiration;
276 $cache = ObjectCache::getLocalClusterInstance();
280 $count = ObjectCache::getLocalClusterInstance()->get( $key );
282 $cache->add( $key, 0, $wgCaptchaBadLoginExpiration );
290 $count =
$cache->get( $key );
292 $cache->add( $key, 0, $wgCaptchaBadLoginPerUserExpiration );
305 $cache = ObjectCache::getLocalClusterInstance();
317 global $wgCaptchaBadLoginAttempts;
319 $cache = ObjectCache::getLocalClusterInstance();
321 && (int)
$cache->get( $this->badLoginKey() ) >= $wgCaptchaBadLoginAttempts;
331 global $wgCaptchaBadLoginPerUserAttempts;
333 $cache = ObjectCache::getLocalClusterInstance();
335 if ( is_object( $u ) ) {
339 && (int)
$cache->get( $this->badLoginPerUserKey( $u ) ) >= $wgCaptchaBadLoginPerUserAttempts;
354 if ( $wgCaptchaWhitelistIP ) {
355 if ( IP::isInRanges( $ip, $wgCaptchaWhitelistIP ) ) {
360 $whitelistMsg =
wfMessage(
'captcha-ip-whitelist' )->inContentLanguage();
361 if ( !$whitelistMsg->isDisabled() ) {
363 if ( IP::isInRanges( $ip, $whitelistedIPs ) ) {
379 $cache = ObjectCache::getMainWANInstance();
380 $cacheKey =
$cache->makeKey(
'confirmedit',
'ipwhitelist' );
382 $cachedWhitelist =
$cache->get( $cacheKey );
383 if ( $cachedWhitelist ===
false ) {
387 explode(
"\n", $msg->plain() )
392 $cache->set( $cacheKey, $whitelist, 86400 );
395 $whitelist = $cachedWhitelist;
414 $ips = array_map(
'trim',
$input );
415 $ips = array_filter( $ips );
418 foreach ( $ips as $ip ) {
419 if ( IP::isIPAddress( $ip ) ) {
458 return $answer == $info[
'answer'];
484 global $wgCaptchaTriggers, $wgCaptchaTriggersOnNamespace;
487 $triggers = $wgCaptchaTriggers;
490 if ( is_array( $attributeCaptchaTriggers ) ) {
491 $triggers += $attributeCaptchaTriggers;
494 if ( isset( $triggers[
$action] ) ) {
500 isset( $wgCaptchaTriggersOnNamespace[$title->getNamespace()][
$action] )
502 $result = $wgCaptchaTriggersOnNamespace[$title->getNamespace()][
$action];
519 $context = RequestContext::getMain();
529 $title = $page->getTitle();
534 $newtext =
$content->getNativeData();
546 $this->trigger = sprintf(
"edit trigger by '%s' at [[%s]]",
548 $title->getPrefixedText() );
549 $this->action =
'edit';
550 wfDebug(
"ConfirmEdit: checking all edits...\n" );
554 if ( $this->
triggersCaptcha(
'create', $title ) && !$title->exists() ) {
556 $this->trigger = sprintf(
"Create trigger by '%s' at [[%s]]",
558 $title->getPrefixedText() );
559 $this->action =
'create';
560 wfDebug(
"ConfirmEdit: checking on page creation...\n" );
568 "ConfirmEdit: request not posted, assuming that no content will be saved -> no CAPTCHA check"
579 $editInfo = $page->prepareContentForEdit(
$content );
580 if ( $editInfo->output ) {
581 $newLinks = array_keys( $editInfo->output->getExternalLinks() );
587 $oldtext = isset( $oldtext ) ? $oldtext : $this->
loadText( $title,
$section );
588 $oldLinks = $this->
findLinks( $title, $oldtext );
589 $newLinks = $this->
findLinks( $title, $newtext );
592 $unknownLinks = array_filter( $newLinks, [ $this,
'filterLink' ] );
593 $addedLinks = array_diff( $unknownLinks, $oldLinks );
594 $numLinks = count( $addedLinks );
596 if ( $numLinks > 0 ) {
597 $this->trigger = sprintf(
"%dx url trigger by '%s' at [[%s]]: %s",
600 $title->getPrefixedText(),
601 implode(
", ", $addedLinks ) );
602 $this->action =
'addurl';
607 global $wgCaptchaRegexes;
608 if ( $newtext !==
null && $wgCaptchaRegexes ) {
609 if ( !is_array( $wgCaptchaRegexes ) ) {
610 throw new UnexpectedValueException(
611 '$wgCaptchaRegexes is required to be an array, ' . gettype( $wgCaptchaRegexes ) .
' given.'
615 $oldtext = isset( $oldtext ) ? $oldtext : $this->
loadText( $title,
$section );
617 foreach ( $wgCaptchaRegexes as $regex ) {
619 if ( preg_match_all( $regex, $newtext, $newMatches ) ) {
621 preg_match_all( $regex, $oldtext, $oldMatches );
623 $addedMatches = array_diff( $newMatches[0], $oldMatches[0] );
625 $numHits = count( $addedMatches );
626 if ( $numHits > 0 ) {
627 $this->trigger = sprintf(
"%dx %s at [[%s]]: %s",
631 $title->getPrefixedText(),
632 implode(
", ", $addedMatches ) );
633 $this->action =
'edit';
649 global $wgCaptchaWhitelist;
650 static $regexes =
null;
652 if ( $regexes ===
null ) {
655 $regexes =
$source->isDisabled()
659 if ( $wgCaptchaWhitelist !==
false ) {
660 array_unshift( $regexes, $wgCaptchaWhitelist );
664 foreach ( $regexes as $regex ) {
665 if ( preg_match( $regex, $url ) ) {
680 # Code duplicated from the SpamBlacklist extension (r19197)
681 # and later modified.
683 # Strip comments and whitespace, then remove blanks
684 $lines = array_filter( array_map(
'trim', preg_replace(
'/#.*$/',
'',
$lines ) ) );
686 # No lines, don't make a regex which will match everything
687 if ( count(
$lines ) == 0 ) {
692 # It's faster using the S modifier even though it will usually only be run once
697 'normal' =>
'/^(?:https?:)?\/\/+[a-z0-9_\-.]*(?:',
698 'noprotocol' =>
'/^(?:',
702 'noprotocol' =>
')/Si',
707 # Extract flags from the line
709 if ( preg_match(
'/^(.*?)\s*<([^<>]*)>$/',
$line,
$matches ) ) {
711 wfDebug(
"Line with empty regex\n" );
715 $opts = preg_split(
'/\s*\|\s*/', trim(
$matches[2] ) );
716 foreach ( $opts as
$opt ) {
718 if (
$opt ==
'noprotocol' ) {
724 $key = isset(
$options[
'noprotocol'] ) ?
'noprotocol' :
'normal';
727 if ( !isset( $build[$key] ) ) {
728 $build[$key] =
$line;
729 } elseif ( strlen( $build[$key] ) + strlen(
$line ) > $regexMax ) {
730 $regexes[] = $regexStart[$key] .
731 str_replace(
'/',
'\/', preg_replace(
'|\\\*/|',
'/', $build[$key] ) ) .
733 $build[$key] =
$line;
735 $build[$key] .=
'|' .
$line;
738 foreach ( $build as $key =>
$value ) {
739 $regexes[] = $regexStart[$key] .
740 str_replace(
'/',
'\/', preg_replace(
'|\\\*/|',
'/', $build[$key] ) ) .
755 $id = $title->getArticleID();
756 $res =
$dbr->select(
'externallinks', [
'el_to' ],
757 [
'el_from' => $id ], __METHOD__ );
759 foreach (
$res as $row ) {
760 $links[] = $row->el_to;
779 if (
$request->getVal(
'captchaid' ) ) {
783 if (
$request->getVal(
'captchaword' ) ) {
790 wfDebug(
"ConfirmEdit: no need to show captcha.\n" );
806 if ( !
$context->canUseWikiPage() ) {
810 if ( $title instanceof
Title ) {
811 $title = $title->getFullText();
819 wfDebug( __METHOD__ .
': Skipped ConfirmEdit check: No WikiPage for title ' . $title );
829 if ( $this->action ===
'edit' ) {
834 [
'class' =>
'errorbox' ],
835 $context->msg(
'captcha-edit-fail' )->text()
841 $page->ConfirmEdit_ActivateCaptcha =
true;
856 $creatingUser = $creatingUser ?: $wgUser;
860 \
MediaWiki\MediaWikiServices::getInstance()->getMainConfig() ) ) {
882 \
MediaWiki\MediaWikiServices::getInstance()->getMainConfig() ) ) {
886 if ( defined(
'MW_API' ) ) {
888 # Asking for captchas in the API is really silly
889 $error = Status::newFatal(
'captcha-disabledinapi' );
892 $this->trigger =
"{$wgUser->getName()} sending email";
894 $error = Status::newFatal(
'captcha-sendemail-fail' );
946 $index =
$request->getVal(
'wpCaptchaId' );
947 $word =
$request->getVal(
'wpCaptchaWord' );
948 return [ $index, $word ];
963 if ( $user->pingLimiter(
'badcaptcha', 0 ) ) {
965 $this->
log(
'User reached RateLimit, preventing action' );
974 $user->pingLimiter(
'badcaptcha' );
1000 if ( isset( $this->captchaSolved ) ) {
1006 if ( $this->
keyMatch( $word, $info ) ) {
1007 $this->
log(
"passed" );
1009 $this->captchaSolved =
true;
1013 $this->
log(
"bad form input" );
1014 $this->captchaSolved =
false;
1018 $this->
log(
"new captcha session" );
1027 protected function log( $message ) {
1028 wfDebugLog(
'captcha',
'ConfirmEdit: ' . $message .
'; ' . $this->trigger );
1043 if ( !isset( $info[
'index'] ) ) {
1045 $info[
'index'] = strval( mt_rand() );
1048 return $info[
'index'];
1081 if ( is_null(
$rev ) ) {
1086 $text = ContentHandler::getContentText(
$content );
1107 return array_keys(
$out->getExternalLinks() );
1116 $wgOut->addWikiMsg(
'captchahelp-text' );
1118 $wgOut->addWikiMsg(
'captchahelp-cookies-needed' );
1142 CaptchaAuthenticationRequest::class );
1148 'label-message' =>
null,
1149 'autocomplete' =>
false,
1150 'persistent' =>
false,
1163 $allowConfirmEmail = $config->
get(
'AllowConfirmedEmail' );
1165 if ( $user->isAllowed(
'skipcaptcha' ) ) {
1166 wfDebug(
"ConfirmEdit: user group allows skipping captcha\n" );
1171 wfDebug(
"ConfirmEdit: user IP is whitelisted" );
1175 if ( $allowConfirmEmail && $user->isEmailConfirmed() ) {
1176 wfDebug(
"ConfirmEdit: user has confirmed mail, skipping captcha\n" );
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfGlobalCacheKey(... $args)
Make a cache key with database-agnostic prefix.
if(! $wgDBerrorLogTZ) $wgRequest
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
A module that allows for editing and creating pages.
Generic captcha authentication request class.
static get()
Get somewhere to store captcha data that will persist between requests.
const EXT_REG_ATTRIBUTE_NAME
const AS_HOOK_ERROR_EXPECTED
Status: A hook function returned an error.
The Message class provides methods which fulfil two basic services:
This class should be covered by a general architecture document which does not exist as of January 20...
Set options of the Parser.
Variant of the Message class.
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
Demo CAPTCHA (not for production usage) and base class for real CAPTCHAs.
getMessage( $action)
Show a message asking the user to enter a captcha on edit The result will be treated as wiki text.
buildRegexes( $lines)
Build regex from whitelist.
findLinks( $title, $text)
Extract a list of all recognized HTTP links in the text.
isIPWhitelisted()
Check if the current IP is allowed to skip captchas.
isBadLoginTriggered()
Check if a bad login has already been registered for this IP address.
addFormToOutput(OutputPage $out, $tabIndex=1)
Uses getFormInformation() to get the CAPTCHA form and adds it to the given OutputPage object.
retrieveCaptcha( $index)
Fetch this session's captcha info.
log( $message)
Log the status and any triggering info for debugging or statistics.
isAPICaptchaModule( $module)
loadText( $title, $section, $flags=Revision::READ_LATEST)
Retrieve the current version of the page or section being edited...
triggersCaptcha( $action, $title=null)
Checks, whether the passed action should trigger a CAPTCHA.
keyMatch( $answer, $info)
Check if the submitted form matches the captcha session data provided by the plugin when the form was...
passCaptchaFromRequest(WebRequest $request, User $user)
Given a required captcha run, test form input for correct input on the open session.
getCaptchaInfo( $captchaData, $id)
showEditFormFields(&$editPage, &$out)
Show error message for missing or incorrect captcha on EditPage.
getError()
Return the error from the last passCaptcha* call.
editShowCaptcha( $editPage)
Insert the captcha prompt into an edit form.
needCreateAccountCaptcha(User $creatingUser=null)
Logic to check if we need to pass a captcha for the current user to create a new account,...
showHelp()
Show a page explaining what this wacky thing is.
badLoginPerUserKey( $username)
Cache key for badloginPerUser checks.
badLoginKey()
Internal cache key for badlogin checks.
filterLink( $url)
Filter callback function for URL whitelisting.
injectEmailUser(&$form)
Inject whazawhoo @fixme if multiple thingies insert a header, could break.
getLinksFromTracker( $title)
Load external links from the externallinks table.
string $trigger
Used in log messages.
getFormInformation( $tabIndex=1)
Insert a captcha prompt into the edit form.
string $action
Used to select the right message.
confirmEditMerged( $context, $content, $status, $summary, $user, $minorEdit)
An efficient edit filter callback based on the text after section merging.
buildValidIPs(array $input)
From a list of unvalidated input, get all the valid IP addresses and IP ranges from it.
apiGetAllowedParams(&$module, &$params, $flags)
isBadLoginPerUserTriggered( $u)
Is the per-user captcha triggered?
confirmEmailUser( $from, $to, $subject, $text, &$error)
Check the captcha on Special:EmailUser.
passCaptchaLimited( $index, $word, User $user)
Checks, if the user reached the amount of false CAPTCHAs and give him some vacation or run self::pass...
passCaptchaLimitedFromRequest(WebRequest $request, User $user)
Checks, if the user reached the amount of false CAPTCHAs and give him some vacation or run self::pass...
addFormInformationToOutput(OutputPage $out, array $formInformation)
Processes the given $formInformation array and adds the options (see getFormInformation()) to the giv...
getWikiIPWhitelist(Message $msg)
Get the on-wiki IP whitelist stored in [[MediaWiki:Captcha-ip-whitelist]] page from cache if possible...
storeCaptcha( $info)
Generate a captcha session ID and save the info in PHP's session storage.
canSkipCaptcha( $user, Config $config)
Check whether the user provided / IP making the request is allowed to skip captchas.
increaseBadLoginCounter( $username)
Increase bad login counter after a failed login.
captchaTriggers( $title, $action)
clearCaptcha( $index)
Clear out existing captcha info from the session, to ensure it can't be reused.
passCaptcha( $index, $word)
Given a required captcha run, test form input for correct input on the open session.
getCaptchaParamsFromRequest(WebRequest $request)
shouldCheck(WikiPage $page, $content, $section, $context, $oldtext=null)
addCaptchaAPI(&$resultArr)
doConfirmEdit(WikiPage $page, $newtext, $section, IContextSource $context)
Backend function for confirmEditMerged()
createAuthenticationRequest()
getCaptcha()
Returns an array with 'question' and 'answer' keys.
describeCaptchaType()
Describes the captcha type for API clients.
boolean null $captchaSolved
Was the CAPTCHA already passed and if yes, with which result?
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
Modify the appearance of the captcha field.
resetBadLoginCounter( $username)
Reset bad login counter after a successful login.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Class representing a MediaWiki article and history.
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 hook is for auditing only $req
namespace being checked & $result
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
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 use $formDescriptor instead & $formDescriptor
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
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
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 use $formDescriptor instead 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 "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead. & $feedLinks hooks can tweak the array to change how login etc forms should look $requests
this hook is for auditing only or null if authentication failed before getting that far $username
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action, or null $user:User who performed the tagging when the tagging is subsequent to the action, or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy: boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'ContentSecurityPolicyDefaultSource':Modify the allowed CSP load sources. This affects all directives except for the script directive. If you want to add a script source, see ContentSecurityPolicyScriptSource hook. & $defaultSrc:Array of Content-Security-Policy allowed sources $policyConfig:Current configuration for the Content-Security-Policy header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyDirectives':Modify the content security policy directives. Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs. & $directives:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyScriptSource':Modify the allowed CSP script sources. Note that you also have to use ContentSecurityPolicyDefaultSource if you want non-script sources to be loaded from whatever you add. & $scriptSrc:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as
patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
const CONTENT_MODEL_WIKITEXT
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
Base interface for content objects.
Interface for objects which can provide a MediaWiki context on request.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
if(is_array($mode)) switch( $mode) $input