Go to the documentation of this file.
51 'login' =>
'ApiLogin',
52 'logout' =>
'ApiLogout',
53 'createaccount' =>
'ApiCreateAccount',
54 'query' =>
'ApiQuery',
55 'expandtemplates' =>
'ApiExpandTemplates',
56 'parse' =>
'ApiParse',
57 'opensearch' =>
'ApiOpenSearch',
58 'feedcontributions' =>
'ApiFeedContributions',
59 'feedrecentchanges' =>
'ApiFeedRecentChanges',
60 'feedwatchlist' =>
'ApiFeedWatchlist',
62 'paraminfo' =>
'ApiParamInfo',
64 'compare' =>
'ApiComparePages',
65 'tokens' =>
'ApiTokens',
68 'purge' =>
'ApiPurge',
69 'setnotificationtimestamp' =>
'ApiSetNotificationTimestamp',
70 'rollback' =>
'ApiRollback',
71 'delete' =>
'ApiDelete',
72 'undelete' =>
'ApiUndelete',
73 'protect' =>
'ApiProtect',
74 'block' =>
'ApiBlock',
75 'unblock' =>
'ApiUnblock',
77 'edit' =>
'ApiEditPage',
78 'upload' =>
'ApiUpload',
79 'filerevert' =>
'ApiFileRevert',
80 'emailuser' =>
'ApiEmailUser',
81 'watch' =>
'ApiWatch',
82 'patrol' =>
'ApiPatrol',
83 'import' =>
'ApiImport',
84 'userrights' =>
'ApiUserrights',
85 'options' =>
'ApiOptions',
86 'imagerotate' =>
'ApiImageRotate',
87 'revisiondelete' =>
'ApiRevisionDelete',
94 'json' =>
'ApiFormatJson',
95 'jsonfm' =>
'ApiFormatJson',
96 'php' =>
'ApiFormatPhp',
97 'phpfm' =>
'ApiFormatPhp',
98 'wddx' =>
'ApiFormatWddx',
99 'wddxfm' =>
'ApiFormatWddx',
100 'xml' =>
'ApiFormatXml',
101 'xmlfm' =>
'ApiFormatXml',
102 'yaml' =>
'ApiFormatYaml',
103 'yamlfm' =>
'ApiFormatYaml',
104 'rawfm' =>
'ApiFormatJson',
105 'txt' =>
'ApiFormatTxt',
106 'txtfm' =>
'ApiFormatTxt',
107 'dbg' =>
'ApiFormatDbg',
108 'dbgfm' =>
'ApiFormatDbg',
109 'dump' =>
'ApiFormatDump',
110 'dumpfm' =>
'ApiFormatDump',
111 'none' =>
'ApiFormatNone',
123 'msg' =>
'Use of the write API',
126 'apihighlimits' =>
array(
127 'msg' =>
'Use higher limits in API queries (Slow queries: $1 results; Fast queries: $2 results). The limits for slow queries also apply to multivalue parameters.',
165 if ( isset( $request ) ) {
172 parent::
__construct( $this, $this->mInternalMode ? 'main_int' : '
main' );
174 if ( !$this->mInternalMode ) {
180 if ( $this->
getVal(
'callback' ) !==
null ) {
183 wfDebug(
"API: stripping user credentials for JSON callback\n" );
184 $wgUser =
new User();
189 global $wgAPIModules, $wgAPIFormatModules;
191 $this->mModuleMgr->addModules( self::$Modules,
'action' );
192 $this->mModuleMgr->addModules( $wgAPIModules,
'action' );
193 $this->mModuleMgr->addModules( self::$Formats,
'format' );
194 $this->mModuleMgr->addModules( $wgAPIFormatModules,
'format' );
197 $this->mEnableWrite = $enableWrite;
199 $this->mSquidMaxage = -1;
200 $this->mCommit =
false;
245 'max-age' => $maxage,
246 's-maxage' => $maxage
276 if ( !in_array( $mode,
array(
'private',
'public',
'anon-public-user-private' ) ) ) {
277 wfDebug( __METHOD__ .
": unrecognised cache mode \"$mode\"\n" );
285 if ( $mode !==
'private' ) {
286 wfDebug( __METHOD__ .
": ignoring request for $mode cache mode, private wiki\n" );
292 wfDebug( __METHOD__ .
": setting cache mode $mode\n" );
293 $this->mCacheMode = $mode;
318 $printer = $this->mModuleMgr->getModule( $format,
'format' );
319 if ( $printer ===
null ) {
320 $this->
dieUsage(
"Unrecognized format: {$format}",
'unknown_format' );
331 if ( $this->mInternalMode ) {
353 if ( $this->
getRequest()->getMethod() ===
'OPTIONS' ) {
361 $t = microtime(
true );
364 }
catch ( Exception
$e ) {
375 if ( $this->mPrinter->getIsHtml() && !$this->mPrinter->isDisabled() ) {
413 $headerStr =
'MediaWiki-API-Error: ' . $errCode;
414 if (
$e->getCode() === 0 ) {
417 $response->header( $headerStr,
true,
$e->getCode() );
424 $this->mPrinter->safeProfileOut();
442 $main->handleException(
$e );
443 }
catch ( Exception $e2 ) {
449 $main->logRequest( 0 );
450 $main->sendCacheHeaders();
468 global $wgCrossSiteAJAXdomains, $wgCrossSiteAJAXdomainExceptions;
471 if ( $originParam ===
null ) {
479 $originHeader = $request->getHeader(
'Origin' );
480 if ( $originHeader ===
false ) {
483 $origins = explode(
' ', $originHeader );
486 if ( !in_array( $originParam, $origins ) ) {
490 $response->header(
"HTTP/1.1 403 $message",
true, 403 );
491 $response->header(
'Cache-Control: no-cache' );
492 echo
"'origin' parameter does not match Origin header\n";
499 $wgCrossSiteAJAXdomains,
500 $wgCrossSiteAJAXdomainExceptions
503 if ( $matchOrigin ) {
504 $response->header(
"Access-Control-Allow-Origin: $originParam" );
505 $response->header(
'Access-Control-Allow-Credentials: true' );
506 $this->
getOutput()->addVaryHeader(
'Origin' );
521 foreach ( $rules
as $rule ) {
522 if ( preg_match( self::wildcardToRegex( $rule ),
$value ) ) {
525 if ( preg_match( self::wildcardToRegex( $exc ),
$value ) ) {
546 $wildcard = preg_quote( $wildcard,
'/' );
547 $wildcard = str_replace(
553 return "/https?:\/\/$wildcard/";
557 global $wgUseXVO, $wgVaryOnXFP;
561 if ( $wgVaryOnXFP ) {
562 $out->addVaryHeader(
'X-Forwarded-Proto' );
565 if ( $this->mCacheMode ==
'private' ) {
566 $response->header(
'Cache-Control: private' );
571 if ( $this->mCacheMode ==
'anon-public-user-private' ) {
572 $out->addVaryHeader(
'Cookie' );
576 if (
$out->haveCacheVaryCookies() ) {
578 $response->header(
'Cache-Control: private' );
583 } elseif ( session_id() !=
'' ) {
586 $response->header(
'Cache-Control: private' );
599 if ( !isset( $this->mCacheControl[
's-maxage'] ) ) {
600 $this->mCacheControl[
's-maxage'] = $this->
getParameter(
'smaxage' );
602 if ( !isset( $this->mCacheControl[
'max-age'] ) ) {
603 $this->mCacheControl[
'max-age'] = $this->
getParameter(
'maxage' );
606 if ( !$this->mCacheControl[
's-maxage'] && !$this->mCacheControl[
'max-age'] ) {
610 $response->header(
'Cache-Control: private' );
615 $this->mCacheControl[
'public'] =
true;
618 $maxAge = min( $this->mCacheControl[
's-maxage'], $this->mCacheControl[
'max-age'] );
619 $expiryUnixTime = ( $maxAge == 0 ? 1 : time() + $maxAge );
626 if ( is_bool(
$value ) ) {
628 $ccHeader .= $separator .
$name;
632 $ccHeader .= $separator .
"$name=$value";
637 $response->header(
"Cache-Control: $ccHeader" );
652 if ( !isset( $this->mPrinter ) ) {
655 if ( !$this->mModuleMgr->isDefined(
$value,
'format' ) ) {
664 if ( !$this->mPrinter->canPrintErrors() ) {
665 $this->mPrinter->safeProfileOut();
670 $result->setRawMode( $this->mPrinter->getNeedsRawData() );
674 $errMessage =
$e->getMessageArray();
677 if ( $this->mPrinter->getWantsHelp() || $this->mAction ==
'help' ) {
681 global $wgShowSQLErrors, $wgShowExceptionDetails;
684 $info =
'Database query error';
686 $info =
"Exception Caught: {$e->getMessage()}";
690 'code' =>
'internal_api_error_' . get_class(
$e ),
695 $wgShowExceptionDetails ?
"\n\n{$e->getTraceAsString()}\n\n" :
''
700 $oldResult =
$result->getData();
701 $warnings = isset( $oldResult[
'warnings'] ) ? $oldResult[
'warnings'] :
null;
707 if ( !is_null( $requestid ) ) {
708 $result->addValue(
null,
'requestid', $requestid );
710 if ( $wgShowHostnames ) {
712 $result->addValue(
null,
'servedby', wfHostName() );
714 if ( $warnings !==
null ) {
715 $result->addValue(
null,
'warnings', $warnings );
718 $result->addValue(
null,
'error', $errMessage );
720 return $errMessage[
'code'];
733 if ( !is_null( $requestid ) ) {
734 $result->addValue(
null,
'requestid', $requestid );
737 if ( $wgShowHostnames ) {
740 $result->addValue(
null,
'servedby', wfHostName() );
746 $this->mAction =
$params[
'action'];
748 if ( !is_string( $this->mAction ) ) {
749 $this->
dieUsage(
'The API requires a valid action parameter',
'unknown_action' );
761 $module = $this->mModuleMgr->getModule( $this->mAction,
'action' );
762 if ( $module ===
null ) {
763 $this->
dieUsage(
'The API requires a valid action parameter',
'unknown_action' );
765 $moduleParams = $module->extractRequestParams();
768 $salt = $module->getTokenSalt();
769 if ( $salt !==
false ) {
770 if ( !isset( $moduleParams[
'token'] ) ) {
774 if ( !$this->
getUser()->matchEditToken(
775 $moduleParams[
'token'],
793 if ( $module->shouldCheckMaxlag() && isset(
$params[
'maxlag'] ) ) {
798 if ( $lag > $maxLag ) {
801 $response->header(
'Retry-After: ' . max( intval( $maxLag ), 5 ) );
802 $response->header(
'X-Database-Lag: ' . intval( $lag ) );
804 if ( $wgShowHostnames ) {
805 $this->
dieUsage(
"Waiting for $host: $lag seconds lagged",
'maxlag' );
808 $this->
dieUsage(
"Waiting for a database server: $lag seconds lagged",
'maxlag' );
822 !
$user->isAllowed(
'read' )
826 if ( $module->isWriteMode() ) {
827 if ( !$this->mEnableWrite ) {
830 if ( !
$user->isAllowed(
'writeapi' ) ) {
850 if ( isset(
$params[
'assert'] ) ) {
854 if (
$user->isAnon() ) {
855 $this->
dieUsage(
'Assertion that the user is logged in failed',
'assertuserfailed' );
859 if ( !
$user->isAllowed(
'bot' ) ) {
860 $this->
dieUsage(
'Assertion that the user has the bot right failed',
'assertbotfailed' );
873 if ( !$this->
getRequest()->wasPosted() && $module->mustBePosted() ) {
880 $this->mPrinter = $module->getCustomPrinter();
881 if ( is_null( $this->mPrinter ) ) {
886 if ( $this->mPrinter->getNeedsRawData() ) {
897 $this->mModule = $module;
905 if ( !$this->mInternalMode ) {
912 $module->profileIn();
915 $module->profileOut();
919 if ( !$this->mInternalMode ) {
934 $milliseconds =
$time ===
null ?
'?' : round(
$time * 1000 );
936 ' ' . $request->getMethod() .
938 ' ' . $request->getIP() .
939 ' T=' . $milliseconds .
'ms';
946 if ( strlen(
$value ) > 256 ) {
948 $s .= $encValue .
'[...]';
963 $chars =
';@$!*(),/:';
964 $numChars = strlen( $chars );
965 for ( $i = 0; $i < $numChars; $i++ ) {
966 $table[rawurlencode( $chars[$i] )] = $chars[$i];
970 return strtr( rawurlencode(
$s ), $table );
977 return array_keys( $this->mParamsUsed );
984 $this->mParamsUsed[
$name] =
true;
986 return $this->
getRequest()->getVal( $name, $default );
994 $this->mParamsUsed[
$name] =
true;
996 return $this->
getRequest()->getCheck( $name );
1007 $this->mParamsUsed[
$name] =
true;
1009 return $this->
getRequest()->getUpload( $name );
1018 $allParams = $this->
getRequest()->getValueNames();
1020 if ( !$this->mInternalMode ) {
1022 $printerParams = array_map(
1023 array( $this->mPrinter,
'encodeParamName' ),
1024 array_keys( $this->mPrinter->getFinalParams() ?:
array() )
1026 $unusedParams = array_diff( $allParams, $paramsUsed, $printerParams );
1028 $unusedParams = array_diff( $allParams, $paramsUsed );
1031 if ( count( $unusedParams ) ) {
1032 $s = count( $unusedParams ) > 1 ?
's' :
'';
1033 $this->
setWarning(
"Unrecognized parameter$s: '" . implode( $unusedParams,
"', '" ) .
"'" );
1044 if ( $wgDebugAPI !==
false ) {
1045 $this->
setWarning(
'SECURITY WARNING: $wgDebugAPI is enabled' );
1057 $isHelp = $isError || $this->mAction ==
'help';
1058 $printer->setUnescapeAmps( $isHelp && $printer->getFormat() ==
'XML' && $printer->getIsHtml() );
1060 $printer->initPrinter( $isHelp );
1062 $printer->execute();
1063 $printer->closePrinter();
1064 $printer->profileOut();
1103 'requestid' =>
null,
1104 'servedby' =>
false,
1116 'format' =>
'The format of the output',
1117 'action' =>
'What action you would like to perform. See below for module help',
1119 'Maximum lag can be used when MediaWiki is installed on a database replicated cluster.',
1120 'To save actions causing any more site replication lag, this parameter can make the client',
1121 'wait until the replication lag is less than the specified value.',
1122 'In case of a replag error, error code "maxlag" is returned, with the message like',
1123 '"Waiting for $host: $lag seconds lagged\n".',
1124 'See https://www.mediawiki.org/wiki/Manual:Maxlag_parameter for more information',
1126 'smaxage' =>
'Set the s-maxage header to this many seconds. Errors are never cached',
1127 'maxage' =>
'Set the max-age header to this many seconds. Errors are never cached',
1128 'assert' =>
'Verify the user is logged in if set to "user", or has the bot userright if "bot"',
1129 'requestid' =>
'Request ID to distinguish requests. This will just be output back to you',
1130 'servedby' =>
'Include the hostname that served the request in the ' .
1131 'results. Unconditionally shown on error',
1133 'When accessing the API using a cross-domain AJAX request (CORS), set this to the',
1134 'originating domain. This must be included in any pre-flight request, and',
1135 'therefore must be part of the request URI (not the POST body). This must match',
1136 'one of the origins in the Origin: header exactly, so it has to be set to ',
1137 'something like http://en.wikipedia.org or https://meta.wikimedia.org . If this',
1138 'parameter does not match the Origin: header, a 403 response will be returned. If',
1139 'this parameter matches the Origin: header and the origin is whitelisted, an',
1140 'Access-Control-Allow-Origin header will be set.',
1154 '**********************************************************************************************',
1156 '** This is an auto-generated MediaWiki API documentation page **',
1158 '** Documentation and Examples: **',
1159 '** https://www.mediawiki.org/wiki/API **',
1161 '**********************************************************************************************',
1163 'Status: All features shown on this page should be working, but the API',
1164 ' is still in active development, and may change at any time.',
1165 ' Make sure to monitor our mailing list for any updates.',
1167 'Erroneous requests: When erroneous requests are sent to the API, a HTTP header will be sent',
1168 ' with the key "MediaWiki-API-Error" and then both the value of the',
1169 ' header and the error code sent back will be set to the same value.',
1171 ' In the case of an invalid action being passed, these will have a value',
1172 ' of "unknown_action".',
1174 ' For more information see https://www.mediawiki.org' .
1175 '/wiki/API:Errors_and_warnings',
1177 'Documentation: https://www.mediawiki.org/wiki/API:Main_page',
1178 'FAQ https://www.mediawiki.org/wiki/API:FAQ',
1179 'Mailing list: https://lists.wikimedia.org/mailman/listinfo/mediawiki-api',
1180 'Api Announcements: https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce',
1181 'Bugs & Requests: https://bugzilla.wikimedia.org/buglist.cgi?component=API&' .
1182 'bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&order=bugs.delta_ts',
1195 return array_merge( parent::getPossibleErrors(),
array(
1196 array(
'readonlytext' ),
1197 array(
'code' =>
'unknown_format',
'info' =>
'Unrecognized format: format' ),
1198 array(
'code' =>
'unknown_action',
'info' =>
'The API requires a valid action parameter' ),
1199 array(
'code' =>
'maxlag',
'info' =>
'Waiting for host: x seconds lagged' ),
1200 array(
'code' =>
'maxlag',
'info' =>
'Waiting for a database server: x seconds lagged' ),
1201 array(
'code' =>
'assertuserfailed',
'info' =>
'Assertion that the user is logged in failed' ),
1203 'code' =>
'assertbotfailed',
1204 'info' =>
'Assertion that the user has the bot right failed'
1216 ' Roan Kattouw (lead developer Sep 2007-2009)',
1220 ' Yuri Astrakhan (creator, lead developer Sep 2006-Sep 2007, 2012-present)',
1222 'Please send your comments, suggestions and questions to mediawiki-api@lists.wikimedia.org',
1223 'or file a bug report at https://bugzilla.wikimedia.org/'
1233 $this->mPrinter->setHelp(
$help );
1247 if ( $wgAPICacheHelpTimeout > 0 ) {
1248 $cached =
$wgMemc->get( $key );
1254 if ( $wgAPICacheHelpTimeout > 0 ) {
1268 $msg = parent::makeHelpMsg();
1270 $astriks = str_repeat(
'*** ', 14 );
1271 $msg .=
"\n\n$astriks Modules $astriks\n\n";
1273 foreach ( $this->mModuleMgr->getNames(
'action' )
as $name ) {
1274 $module = $this->mModuleMgr->getModule(
$name );
1277 $msg2 = $module->makeHelpMsg();
1278 if ( $msg2 !==
false ) {
1284 $msg .=
"\n$astriks Permissions $astriks\n\n";
1285 foreach ( self::$mRights
as $right => $rightMsg ) {
1288 "\nGranted to:\n " . str_replace(
'*',
'all', implode(
', ', $groups ) ) .
"\n\n";
1291 $msg .=
"\n$astriks Formats $astriks\n\n";
1292 foreach ( $this->mModuleMgr->getNames(
'format' )
as $name ) {
1293 $module = $this->mModuleMgr->getModule(
$name );
1295 $msg2 = $module->makeHelpMsg();
1296 if ( $msg2 !==
false ) {
1302 $msg .=
"\n*** Credits: ***\n " . implode(
"\n ", $this->
getCredits() ) .
"\n";
1314 $modulePrefix = $module->getModulePrefix();
1315 if ( strval( $modulePrefix ) !==
'' ) {
1316 $modulePrefix =
"($modulePrefix) ";
1319 return "* $paramName={$module->getModuleName()} $modulePrefix*";
1329 if ( !isset( $this->mCanApiHighLimits ) ) {
1330 $this->mCanApiHighLimits = $this->
getUser()->isAllowed(
'apihighlimits' );
1422 public function __construct( $message, $codestr, $code = 0, $extradata =
null ) {
1423 parent::__construct( $message, $code );
1424 $this->mCodestr = $codestr;
1425 $this->mExtraData = $extradata;
1440 'code' => $this->mCodestr,
1441 'info' => $this->getMessage()
1443 if ( is_array( $this->mExtraData ) ) {
1454 return "{$this->getCodeString()}: {$this->getMessage()}";
getDescription()
See ApiBase for description.
dieUsageMsgOrDebug( $error)
Will only set a warning instead of failing if the global $wgDebugAPI is set to true.
executeActionWithErrorHandling()
Execute an action, and in case of an error, erase whatever partial results have been accumulated,...
This is the main API class, used for both external and internal processing.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
WebRequest clone which takes values from a provided array.
see documentation in includes Linker php for Linker::makeImageLink & $time
getContext()
Get the RequestContext object.
getCredits()
Returns an array of strings with credits for the API.
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
getModules()
Get the array mapping module names to class names.
getParamsUsed()
Get the request parameters used in the course of the preceding execute() request.
static setContent(&$arr, $value, $subElemName=null)
Adds a content element to an array.
getVal( $name, $default=null)
Get a request value, and register the fact that it was used, for logging.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
wfGetLB( $wiki=false)
Get a load balancer object.
dieUsageMsg( $error)
Output the error message related to a certain array.
static $Modules
List of available modules: action name => module class.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
handleCORS()
Check the &origin= query parameter against the Origin: HTTP header and respond appropriately.
static handleApiBeforeMainException(Exception $e)
Handle an exception from the ApiBeforeMain hook.
return false if a UserGetRights hook might remove the named right $right
getShowVersions()
Check whether the user wants us to show version information in the API help.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfMsgReplaceArgs( $message, $args)
Replace message parameter keys on the given formatted output.
getRequest()
Get the WebRequest object.
encodeRequestLogValue( $s)
Encode a value in a format suitable for a space-separated log line.
getUser()
Get the User object.
makeHelpMsg()
Override the parent to generate help messages for all available modules.
static matchOrigin( $value, $rules, $exceptions)
Attempt to match an Origin header against a set of rules and a set of exceptions.
static $mRights
List of user roles that are specifically relevant to the API.
This abstract class implements many basic API functions, and is the base of all API classes.
getModule()
Get the API module object.
profileOut()
End module profiling.
An IContextSource implementation which will inherit context from another source but allow individual ...
wfMemcKey()
Get a cache key.
getParamDescription()
See ApiBase for description.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
setupExecuteAction()
Set up for the execution.
This class represents the result of the API operations.
This exception will be thrown when dieUsage is called to stop module execution.
addFormat( $name, $class)
Add or overwrite an output format for this ApiMain.
getOutput()
Get the OutputPage object.
getResult()
Get the ApiResult object associated with current request.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
checkMaxLag( $module, $params)
Check the max lag if necessary.
setCacheControl( $directives)
Set directives (key/value pairs) for the Cache-Control header.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
getAllowedParams()
See ApiBase for description.
setupExternalResponse( $module, $params)
Check POST for external response and setup result printer.
createPrinterByName( $format)
Create an instance of an output formatter by its name.
getModuleManager()
Overrides to return this instance's module manager.
when a variable name is used in a it is silently declared as a new masking the global
setContext(IContextSource $context)
Set the IContextSource object.
canApiHighLimits()
Check whether the current user is allowed to use high limits.
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
processing should stop and the error should be shown to the user * false
This class holds a list of modules and handles instantiation.
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
checkAsserts( $params)
Check asserts of the user's rights.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
static appendDebugInfoToApiResult(IContextSource $context, ApiResult $result)
Append the debug info to given ApiResult.
Allows to change the fields on the form that will be generated $name
static wildcardToRegex( $wildcard)
Helper function to convert wildcard string into a regex '*' => '.
checkExecutePermissions( $module)
Check for sufficient permissions to execute.
dieUsage( $description, $errorCode, $httpRespCode=0, $extradata=null)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
dieReadOnly()
Helper function for readonly errors.
__construct( $context=null, $enableWrite=false)
Constructs an instance of ApiMain that utilizes the module and format specified by $request.
reportUnusedParams()
Report unused parameters, so the client gets a hint in case it gave us parameters we don't know,...
execute()
Execute api request.
logRequest( $time)
Log the preceding request.
static $Formats
List of available formats: format name => format class.
substituteResultWithError( $e)
Replace the result data with the information about an exception.
static getMain()
Static methods.
static getMessage( $code)
Get the message associated with HTTP response code $code.
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
getCheck( $name)
Get a boolean request value, and register the fact that the parameter was used, for logging.
wfReportTime()
Returns a script tag that stores the amount of time it took MediaWiki to handle the request in millis...
profileIn()
Start module profiling.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
static makeHelpMsgHeader( $module, $paramName)
setWarning( $warning)
Set warning section for this module.
static isEveryoneAllowed( $right)
Check if all users have the given permission.
__construct( $message, $codestr, $code=0, $extradata=null)
const API_DEFAULT_FORMAT
When no format parameter is given, this format will be used.
addModule( $name, $class)
Add or overwrite a module in this ApiMain instance.
setHelp( $help=true)
Sets whether the pretty-printer should format bold and $italics$.
printResult( $isError)
Print results using the current printer.
getUpload( $name)
Get a request upload, and register the fact that it was used, for logging.
static rollbackMasterChangesAndLog(Exception $e)
If there are any open database transactions, roll them back and log the stack trace of the exception ...
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
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
getModuleName()
Get the name of the module being executed by this instance.
executeAction()
Execute the actual module, without any error handling.
setupModule()
Set up the module for response.
static logException(Exception $e)
Log an exception to the exception log (if enabled).
handleException(Exception $e)
Handle an exception as an API response.
isInternalMode()
Return true if the API was started by other PHP code using FauxRequest.
setCacheMaxAge( $maxage)
Set how long the response should be cached.
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 incomplete not yet checked for validity & $retval
setCacheMode( $mode)
Set the type of caching headers which will be sent.
const TS_RFC2822
RFC 2822 format, for E-mail and HTTP headers.
getPrinter()
Get the result formatter object.
if(!function_exists('version_compare')||version_compare(phpversion(), '5.3.2')< 0)
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
static getVersion( $flags='')
Return a string of the MediaWiki version with SVN revision if available.
getFormats()
Returns the list of supported formats in form ( 'format' => 'ClassName' )