210 $this->mMainModule = $mainModule;
211 $this->mModuleName = $moduleName;
212 $this->mModulePrefix = $modulePrefix;
240 abstract public function execute();
281 if ( !is_array( $examples ) ) {
282 $examples = [ $examples ];
283 } elseif ( $examples && ( count( $examples ) & 1 ) == 0 &&
284 array_keys( $examples ) === range( 0, count( $examples ) - 1 ) &&
285 !preg_match(
'/^\s*api\.php\?/', $examples[0] )
290 $examplesCount = count( $examples );
291 for ( $i = 0; $i < $examplesCount; $i += 2 ) {
292 $tmp[$examples[$i + 1]] = $examples[$i];
297 foreach ( $examples
as $k => $v ) {
298 if ( is_numeric( $k ) ) {
303 $msg = self::escapeWikiText( $v );
304 if ( is_array( $msg ) ) {
305 $msg = implode(
' ', $msg );
309 $qs = preg_replace(
'/^\s*api\.php\?/',
'', $qs );
310 $ret[$qs] = $this->
msg(
'api-help-fallback-example', [ $msg ] );
512 return $this->
getMain()->lacksSameOriginSecurity();
541 if (
$path ===
'main' ) {
545 $parts = explode(
'+',
$path );
546 if ( count( $parts ) === 1 ) {
548 $parts = explode(
' ',
$path );
552 for ( $i = 0; $i <
$count; $i++ ) {
554 $manager = $parent->getModuleManager();
555 if ( $manager === null ) {
556 $errorPath = implode(
'+', array_slice( $parts, 0, $i ) );
557 $this->
dieUsage(
"The module \"$errorPath\" has no submodules",
'badmodule' );
559 $module = $manager->getModule( $parts[$i] );
561 if ( $module === null ) {
562 $errorPath = $i ? implode(
'+', array_slice( $parts, 0, $i ) ) : $parent->getModuleName();
564 "The module \"$errorPath\" does not have a submodule \"{$parts[$i]}\"",
584 return $this->
getMain()->getResult();
598 return $this->
getMain()->getErrorFormatter();
606 if ( !isset( $this->mSlaveDB ) ) {
624 return $this->
getMain()->getContinuationManager();
638 $this->
getMain()->setContinuationManager( $manager );
666 return $this->mModulePrefix . $paramName;
680 if ( !isset( $this->mParamCache[$parseLimit] ) ) {
685 foreach (
$params as $paramName => $paramSettings ) {
687 $paramName, $paramSettings, $parseLimit );
690 $this->mParamCache[$parseLimit] = $results;
693 return $this->mParamCache[$parseLimit];
715 $required = func_get_args();
716 array_shift( $required );
719 $intersection = array_intersect( array_keys( array_filter(
$params,
720 [ $this,
'parameterNotEmpty' ] ) ), $required );
722 if ( count( $intersection ) > 1 ) {
724 "The parameters {$p}" . implode(
", {$p}", $intersection ) .
' can not be used together',
726 } elseif ( count( $intersection ) == 0 ) {
728 "One of the parameters {$p}" . implode(
", {$p}", $required ) .
' is required',
741 $required = func_get_args();
742 array_shift( $required );
745 $intersection = array_intersect( array_keys( array_filter(
$params,
746 [ $this,
'parameterNotEmpty' ] ) ), $required );
748 if ( count( $intersection ) > 1 ) {
750 "The parameters {$p}" . implode(
", {$p}", $intersection ) .
' can not be used together',
764 $required = func_get_args();
765 array_shift( $required );
768 $intersection = array_intersect(
769 array_keys( array_filter(
$params, [ $this,
'parameterNotEmpty' ] ) ),
773 if ( count( $intersection ) == 0 ) {
774 $this->
dieUsage(
"At least one of the parameters {$p}" .
775 implode(
", {$p}", $required ) .
' is required',
"{$p}missingparam" );
788 if ( $this->
getConfig()->
get(
'DebugAPI' ) || $this->
getMain()->isInternalMode() ) {
792 $queryValues = $this->
getRequest()->getQueryValues();
795 if ( $prefix !==
'noprefix' ) {
798 if ( array_key_exists( $param, $queryValues ) ) {
799 $badParams[] = $param;
805 'The following parameters were found in the query string, but must be in the POST body: '
806 . join(
', ', $badParams ),
819 return !is_null( $x ) && $x !==
false;
837 if ( isset(
$params[
'title'] ) ) {
839 if ( !$titleObj || $titleObj->isExternal() ) {
842 if ( !$titleObj->canExist() ) {
843 $this->
dieUsage(
"Namespace doesn't allow actual pages",
'pagecannotexist' );
846 if ( $load !==
false ) {
847 $pageObj->loadPageData( $load );
849 } elseif ( isset(
$params[
'pageid'] ) ) {
850 if ( $load ===
false ) {
874 switch ( $watchlist ) {
882 # If the user is already watching, don't bother checking
883 if ( $userWatching ) {
886 # If no user option was passed, use watchdefault and watchcreations
887 if ( is_null( $userOption ) ) {
888 return $this->
getUser()->getBoolOption(
'watchdefault' ) ||
889 $this->
getUser()->getBoolOption(
'watchcreations' ) && !$titleObj->exists();
892 # Watch the article based on the user preference
893 return $this->
getUser()->getBoolOption( $userOption );
896 return $userWatching;
899 return $userWatching;
916 if ( !is_array( $paramSettings ) ) {
917 $default = $paramSettings;
919 $type = gettype( $paramSettings );
924 $default = isset( $paramSettings[self::PARAM_DFLT] )
925 ? $paramSettings[self::PARAM_DFLT]
927 $multi = isset( $paramSettings[self::PARAM_ISMULTI] )
928 ? $paramSettings[self::PARAM_ISMULTI]
930 $type = isset( $paramSettings[self::PARAM_TYPE] )
931 ? $paramSettings[self::PARAM_TYPE]
933 $dupes = isset( $paramSettings[self::PARAM_ALLOW_DUPLICATES] )
934 ? $paramSettings[self::PARAM_ALLOW_DUPLICATES]
936 $deprecated = isset( $paramSettings[self::PARAM_DEPRECATED] )
937 ? $paramSettings[self::PARAM_DEPRECATED]
939 $required = isset( $paramSettings[self::PARAM_REQUIRED] )
940 ? $paramSettings[self::PARAM_REQUIRED]
944 if ( !isset(
$type ) ) {
945 if ( isset( $default ) ) {
946 $type = gettype( $default );
953 if (
$type ==
'boolean' ) {
954 if ( isset( $default ) && $default !==
false ) {
958 "Boolean param $encParamName's default is set to '$default'. " .
959 'Boolean parameters must default to false.'
964 } elseif (
$type ==
'upload' ) {
965 if ( isset( $default ) ) {
969 "File upload param $encParamName's default is set to " .
970 "'$default'. File upload parameters may not have a default." );
976 if ( !
$value->exists() ) {
980 $value = $this->
getMain()->getRequest()->unsetVal( $encParamName );
983 "File upload param $encParamName is not a file upload; " .
984 'be sure to use multipart/form-data for your POST and include ' .
985 'a filename in the Content-Disposition header.',
986 "badupload_{$encParamName}"
991 $value = $this->
getMain()->getVal( $encParamName, $default );
997 if ( isset( $paramSettings[self::PARAM_SUBMODULE_MAP] ) ) {
998 $type = array_keys( $paramSettings[self::PARAM_SUBMODULE_MAP] );
1005 $rawValue =
$request->getRawVal( $encParamName );
1006 if ( $rawValue === null ) {
1007 $rawValue = $default;
1011 if ( isset(
$value ) && substr( $rawValue, 0, 1 ) ===
"\x1f" ) {
1015 $value = join(
"\x1f",
$request->normalizeUnicode( explode(
"\x1f", $rawValue ) ) );
1018 "U+001F multi-value separation may only be used for multi-valued parameters.",
1019 'badvalue_notmultivalue'
1025 if ( $rawValue !==
$value ) {
1030 if ( isset(
$value ) && ( $multi || is_array(
$type ) ) ) {
1042 if ( !is_array(
$type ) ) {
1049 if ( $required &&
$value ===
'' ) {
1050 $this->
dieUsageMsg( [
'missingparam', $paramName ] );
1054 $min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : null;
1055 $max = isset( $paramSettings[self::PARAM_MAX] ) ? $paramSettings[self::PARAM_MAX] : null;
1056 $enforceLimits = isset( $paramSettings[self::PARAM_RANGE_ENFORCE] )
1057 ? $paramSettings[self::PARAM_RANGE_ENFORCE] :
false;
1059 if ( is_array(
$value ) ) {
1061 if ( !is_null( $min ) || !is_null( $max ) ) {
1063 $this->
validateLimit( $paramName, $v, $min, $max, null, $enforceLimits );
1068 if ( !is_null( $min ) || !is_null( $max ) ) {
1074 if ( !$parseLimit ) {
1078 if ( !isset( $paramSettings[self::PARAM_MAX] )
1079 || !isset( $paramSettings[self::PARAM_MAX2] )
1083 "MAX1 or MAX2 are not defined for the limit $encParamName"
1087 ApiBase::dieDebug( __METHOD__,
"Multi-values not supported for $encParamName" );
1089 $min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : 0;
1092 ? $paramSettings[self::PARAM_MAX2]
1093 : $paramSettings[self::PARAM_MAX];
1101 $paramSettings[self::PARAM_MAX],
1102 $paramSettings[self::PARAM_MAX2]
1108 ApiBase::dieDebug( __METHOD__,
"Multi-values not supported for $encParamName" );
1112 if ( is_array(
$value ) ) {
1113 foreach (
$value as $key => $val ) {
1121 if ( is_array(
$value ) ) {
1122 foreach (
$value as $key => $val ) {
1133 if ( !is_array(
$value ) && !$multi ) {
1137 if ( !$tagsStatus->isGood() ) {
1142 ApiBase::dieDebug( __METHOD__,
"Param $encParamName's type is unknown - $type" );
1147 if ( !$dupes && is_array(
$value ) ) {
1152 if ( $deprecated &&
$value !==
false ) {
1153 $this->
setWarning(
"The $encParamName parameter has been deprecated." );
1155 $feature = $encParamName;
1157 while ( !$m->isMain() ) {
1158 $p = $m->getParent();
1159 $name = $m->getModuleName();
1160 $param = $p->encodeParamName( $p->getModuleManager()->getModuleGroup(
$name ) );
1161 $feature =
"{$param}={$name}&{$feature}";
1166 } elseif ( $required ) {
1167 $this->
dieUsageMsg( [
'missingparam', $paramName ] );
1183 "The value passed for '$encParamName' contains invalid or non-normalized data. "
1184 .
'Textual data should be valid, NFC-normalized Unicode without '
1185 .
'C0 control characters other than HT (\\t), LF (\\n), and CR (\\r).'
1197 if ( substr(
$value, 0, 1 ) ===
"\x1f" ) {
1221 if ( ( trim(
$value ) ===
'' || trim(
$value ) ===
"\x1f" ) && $allowMultiple ) {
1228 $sizeLimit = count( $valuesList ) > self::LIMIT_SML1 && $this->mMainModule->canApiHighLimits()
1232 if ( self::truncateArray( $valuesList, $sizeLimit ) ) {
1233 $this->
logFeatureUsage(
"too-many-$valueName-for-{$this->getModulePath()}" );
1234 $this->
setWarning(
"Too many values supplied for parameter '$valueName': " .
1235 "the limit is $sizeLimit" );
1238 if ( !$allowMultiple && count( $valuesList ) != 1 ) {
1240 if ( in_array(
$value, $allowedValues,
true ) ) {
1244 $possibleValues = is_array( $allowedValues )
1245 ?
"of '" . implode(
"', '", $allowedValues ) .
"'"
1248 "Only one $possibleValues is allowed for parameter '$valueName'",
1249 "multival_$valueName"
1253 if ( is_array( $allowedValues ) ) {
1255 $unknown = array_diff( $valuesList, $allowedValues );
1256 if ( count( $unknown ) ) {
1257 if ( $allowMultiple ) {
1258 $s = count( $unknown ) > 1 ?
's' :
'';
1259 $vals = implode(
', ', $unknown );
1260 $this->
setWarning(
"Unrecognized value$s for parameter '$valueName': $vals" );
1263 "Unrecognized value for parameter '$valueName': {$valuesList[0]}",
1264 "unknown_$valueName"
1269 $valuesList = array_intersect( $valuesList, $allowedValues );
1272 return $allowMultiple ? $valuesList : $valuesList[0];
1286 $enforceLimits =
false
1288 if ( !is_null( $min ) &&
$value < $min ) {
1289 $msg = $this->
encodeParamName( $paramName ) .
" may not be less than $min (set to $value)";
1290 $this->
warnOrDie( $msg, $enforceLimits );
1296 if ( $this->
getMain()->isInternalMode() ) {
1302 if ( !is_null( $max ) &&
$value > $max ) {
1303 if ( !is_null( $botMax ) && $this->
getMain()->canApiHighLimits() ) {
1304 if (
$value > $botMax ) {
1306 " may not be over $botMax (set to $value) for bots or sysops";
1307 $this->
warnOrDie( $msg, $enforceLimits );
1311 $msg = $this->
encodeParamName( $paramName ) .
" may not be over $max (set to $value) for users";
1312 $this->
warnOrDie( $msg, $enforceLimits );
1331 "Passing '$value' for timestamp parameter $encParamName has been deprecated." .
1332 ' If for some reason you need to explicitly specify the current time without' .
1333 ' calculating it client-side, use "now".'
1339 if (
$value ===
'now' ) {
1344 if ( $unixTimestamp ===
false ) {
1346 "Invalid value '$value' for timestamp parameter $encParamName",
1347 "badtimestamp_{$encParamName}"
1366 if ( !isset( $salts[$tokenType] ) ) {
1368 "Module '{$this->getModuleName()}' tried to use token type '$tokenType' " .
1369 'without registering it'
1376 if ( $tokenObj->match( $token ) ) {
1381 if ( $webUiSalt !== null && $this->
getUser()->matchEditToken(
1402 "Invalid value '$value' for user parameter $encParamName",
1403 "baduser_{$encParamName}"
1407 return $title->getText();
1423 protected function setWatch( $watch, $titleObj, $userOption = null ) {
1440 while ( count( $arr ) >
$limit ) {
1455 if ( !is_null(
$params[
'owner'] ) && !is_null(
$params[
'token'] ) ) {
1458 $this->
dieUsage(
'Specified user does not exist',
'bad_wlowner' );
1460 $token =
$user->getOption(
'watchlisttoken' );
1461 if ( $token ==
'' || !hash_equals( $token,
$params[
'token'] ) ) {
1463 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences',
1468 if ( !$this->
getUser()->isLoggedIn() ) {
1469 $this->
dieUsage(
'You must be logged-in to have a watchlist',
'notloggedin' );
1471 if ( !$this->
getUser()->isAllowed(
'viewmywatchlist' ) ) {
1472 $this->
dieUsage(
'You don\'t have permission to view your watchlist',
'permissiondenied' );
1488 if ( is_array( $v ) ) {
1489 return array_map(
'self::escapeWikiText', $v );
1492 '__' =>
'__',
'{' =>
'{',
'}' =>
'}',
1493 '[[Category:' =>
'[[:Category:',
1494 '[[File:' =>
'[[:File:',
'[[Image:' =>
'[[:Image:',
1512 if ( is_string( $msg ) ) {
1514 } elseif ( is_array( $msg ) ) {
1515 $msg = call_user_func_array(
'wfMessage', $msg );
1517 if ( !$msg instanceof
Message ) {
1521 $msg->setContext( $context );
1554 private function warnOrDie( $msg, $enforceLimits =
false ) {
1555 if ( $enforceLimits ) {
1556 $this->
dieUsage( $msg,
'integeroutofrange' );
1574 public function dieUsage( $description, $errorCode, $httpRespCode = 0, $extradata = null ) {
1595 'Your IP address has been blocked automatically, because it was used by a blocked user',
1602 'You have been blocked from editing',
1621 throw new MWException(
'Successful status passed to ApiBase::dieStatus' );
1624 $errors =
$status->getErrorsByType(
'error' );
1627 $errors =
$status->getErrorsByType(
'warning' );
1631 $errors = [ [
'message' =>
'unknownerror-nocode',
'params' => [] ] ];
1636 if ( $errors[0][
'message'] instanceof
Message ) {
1637 $msg = $errors[0][
'message'];
1639 $extraData = $msg->getApiData();
1640 $code = $msg->getApiCode();
1642 $code = $msg->getKey();
1645 $code = $errors[0][
'message'];
1653 return [
$code, $msg->inLanguage(
'en' )->useDatabase(
false )->plain() ];
1675 'unknownerror' => [
'code' =>
'unknownerror',
'info' =>
"Unknown error: \"\$1\"" ],
1676 'unknownerror-nocode' => [
'code' =>
'unknownerror',
'info' =>
'Unknown error' ],
1679 'ns-specialprotected' => [
1680 'code' =>
'unsupportednamespace',
1681 'info' =>
"Pages in the Special namespace can't be edited"
1683 'protectedinterface' => [
1684 'code' =>
'protectednamespace-interface',
1685 'info' =>
"You're not allowed to edit interface messages"
1687 'namespaceprotected' => [
1688 'code' =>
'protectednamespace',
1689 'info' =>
"You're not allowed to edit pages in the \"\$1\" namespace"
1691 'customcssprotected' => [
1692 'code' =>
'customcssprotected',
1693 'info' =>
"You're not allowed to edit custom CSS pages"
1695 'customjsprotected' => [
1696 'code' =>
'customjsprotected',
1697 'info' =>
"You're not allowed to edit custom JavaScript pages"
1699 'cascadeprotected' => [
1700 'code' =>
'cascadeprotected',
1701 'info' =>
"The page you're trying to edit is protected because it's included in a cascade-protected page"
1703 'protectedpagetext' => [
1704 'code' =>
'protectedpage',
1705 'info' =>
"The \"\$1\" right is required to edit this page"
1707 'protect-cantedit' => [
1708 'code' =>
'cantedit',
1709 'info' =>
"You can't protect this page because you can't edit it"
1711 'deleteprotected' => [
1712 'code' =>
'cantedit',
1713 'info' =>
"You can't delete this page because it has been protected"
1715 'badaccess-group0' => [
1716 'code' =>
'permissiondenied',
1717 'info' =>
'Permission denied'
1719 'badaccess-groups' => [
1720 'code' =>
'permissiondenied',
1721 'info' =>
'Permission denied'
1723 'titleprotected' => [
1724 'code' =>
'protectedtitle',
1725 'info' =>
'This title has been protected from creation'
1727 'nocreate-loggedin' => [
1728 'code' =>
'cantcreate',
1729 'info' =>
"You don't have permission to create new pages"
1732 'code' =>
'cantcreate-anon',
1733 'info' =>
"Anonymous users can't create new pages"
1735 'movenologintext' => [
1736 'code' =>
'cantmove-anon',
1737 'info' =>
"Anonymous users can't move pages"
1739 'movenotallowed' => [
1740 'code' =>
'cantmove',
1741 'info' =>
"You don't have permission to move pages"
1743 'confirmedittext' => [
1744 'code' =>
'confirmemail',
1745 'info' =>
'You must confirm your email address before you can edit'
1748 'code' =>
'blocked',
1749 'info' =>
'You have been blocked from editing'
1751 'autoblockedtext' => [
1752 'code' =>
'autoblocked',
1753 'info' =>
'Your IP address has been blocked automatically, because it was used by a blocked user'
1757 'actionthrottledtext' => [
1758 'code' =>
'ratelimited',
1759 'info' =>
"You've exceeded your rate limit. Please wait some time and try again"
1761 'alreadyrolled' => [
1762 'code' =>
'alreadyrolled',
1763 'info' =>
'The page you tried to rollback was already rolled back'
1766 'code' =>
'onlyauthor',
1767 'info' =>
'The page you tried to rollback only has one author'
1770 'code' =>
'readonly',
1771 'info' =>
'The wiki is currently in read-only mode'
1773 'sessionfailure' => [
1774 'code' =>
'badtoken',
1775 'info' =>
'Invalid token' ],
1777 'code' =>
'cantdelete',
1778 'info' =>
"Couldn't delete \"\$1\". Maybe it was deleted already by someone else"
1781 'code' =>
'missingtitle',
1782 'info' =>
"The page you requested doesn't exist"
1784 'selfmove' => [
'code' =>
'selfmove',
'info' =>
"Can't move a page to itself"
1786 'immobile_namespace' => [
1787 'code' =>
'immobilenamespace',
1788 'info' =>
'You tried to move pages from or to a namespace that is protected from moving'
1790 'articleexists' => [
1791 'code' =>
'articleexists',
1792 'info' =>
'The destination article already exists and is not a redirect to the source article'
1794 'protectedpage' => [
1795 'code' =>
'protectedpage',
1796 'info' =>
"You don't have permission to perform this move"
1799 'code' =>
'hookaborted',
1800 'info' =>
'The modification you tried to make was aborted by an extension hook'
1802 'cantmove-titleprotected' => [
1803 'code' =>
'protectedtitle',
1804 'info' =>
'The destination article has been protected from creation'
1806 'imagenocrossnamespace' => [
1807 'code' =>
'nonfilenamespace',
1808 'info' =>
"Can't move a file to a non-file namespace"
1810 'imagetypemismatch' => [
1811 'code' =>
'filetypemismatch',
1812 'info' =>
"The new file extension doesn't match its type"
1816 'ip_range_invalid' => [
'code' =>
'invalidrange',
'info' =>
'Invalid IP range' ],
1817 'range_block_disabled' => [
1818 'code' =>
'rangedisabled',
1819 'info' =>
'Blocking IP ranges has been disabled'
1821 'nosuchusershort' => [
1822 'code' =>
'nosuchuser',
1823 'info' =>
"The user you specified doesn't exist"
1825 'badipaddress' => [
'code' =>
'invalidip',
'info' =>
'Invalid IP address specified' ],
1826 'ipb_expiry_invalid' => [
'code' =>
'invalidexpiry',
'info' =>
'Invalid expiry time' ],
1827 'ipb_already_blocked' => [
1828 'code' =>
'alreadyblocked',
1829 'info' =>
'The user you tried to block was already blocked'
1831 'ipb_blocked_as_range' => [
1832 'code' =>
'blockedasrange',
1833 'info' =>
"IP address \"\$1\" was blocked as part of range \"\$2\". You can't unblock the IP individually, but you can unblock the range as a whole."
1835 'ipb_cant_unblock' => [
1836 'code' =>
'cantunblock',
1837 'info' =>
'The block you specified was not found. It may have been unblocked already'
1840 'code' =>
'cantsend',
1841 'info' =>
'You are not logged in, you do not have a confirmed email address, or you are not allowed to send email to other users, so you cannot send email'
1844 'code' =>
'ipbblocked',
1845 'info' =>
'You cannot block or unblock users while you are yourself blocked'
1847 'ipbnounblockself' => [
1848 'code' =>
'ipbnounblockself',
1849 'info' =>
'You are not allowed to unblock yourself'
1851 'usermaildisabled' => [
1852 'code' =>
'usermaildisabled',
1853 'info' =>
'User email has been disabled'
1855 'blockedemailuser' => [
1856 'code' =>
'blockedfrommail',
1857 'info' =>
'You have been blocked from sending email'
1860 'code' =>
'notarget',
1861 'info' =>
'You have not specified a valid target for this action'
1864 'code' =>
'noemail',
1865 'info' =>
'The user has not specified a valid email address, or has chosen not to receive email from other users'
1867 'rcpatroldisabled' => [
1868 'code' =>
'patroldisabled',
1869 'info' =>
'Patrolling is disabled on this wiki'
1871 'markedaspatrollederror-noautopatrol' => [
1872 'code' =>
'noautopatrol',
1873 'info' =>
"You don't have permission to patrol your own changes"
1875 'delete-toobig' => [
1876 'code' =>
'bigdelete',
1877 'info' =>
"You can't delete this page because it has more than \$1 revisions"
1879 'movenotallowedfile' => [
1880 'code' =>
'cantmovefile',
1881 'info' =>
"You don't have permission to move files"
1883 'userrights-no-interwiki' => [
1884 'code' =>
'nointerwikiuserrights',
1885 'info' =>
"You don't have permission to change user rights on other wikis"
1887 'userrights-nodatabase' => [
1888 'code' =>
'nosuchdatabase',
1889 'info' =>
"Database \"\$1\" does not exist or is not local"
1891 'nouserspecified' => [
'code' =>
'invaliduser',
'info' =>
"Invalid username \"\$1\"" ],
1892 'noname' => [
'code' =>
'invaliduser',
'info' =>
"Invalid username \"\$1\"" ],
1893 'summaryrequired' => [
'code' =>
'summaryrequired',
'info' =>
'Summary required' ],
1894 'import-rootpage-invalid' => [
1895 'code' =>
'import-rootpage-invalid',
1896 'info' =>
'Root page is an invalid title'
1898 'import-rootpage-nosubpage' => [
1899 'code' =>
'import-rootpage-nosubpage',
1900 'info' =>
'Namespace "$1" of the root page does not allow subpages'
1905 'code' =>
'readapidenied',
1906 'info' =>
'You need read permission to use this module'
1908 'writedisabled' => [
1909 'code' =>
'noapiwrite',
1910 'info' =>
"Editing of this wiki through the API is disabled. Make sure the \$wgEnableWriteAPI=true; statement is included in the wiki's LocalSettings.php file"
1912 'writerequired' => [
1913 'code' =>
'writeapidenied',
1914 'info' =>
"You're not allowed to edit this wiki through the API"
1916 'missingparam' => [
'code' =>
'no$1',
'info' =>
"The \$1 parameter must be set" ],
1917 'invalidtitle' => [
'code' =>
'invalidtitle',
'info' =>
"Bad title \"\$1\"" ],
1918 'nosuchpageid' => [
'code' =>
'nosuchpageid',
'info' =>
"There is no page with ID \$1" ],
1919 'nosuchrevid' => [
'code' =>
'nosuchrevid',
'info' =>
"There is no revision with ID \$1" ],
1920 'nosuchuser' => [
'code' =>
'nosuchuser',
'info' =>
"User \"\$1\" doesn't exist" ],
1921 'invaliduser' => [
'code' =>
'invaliduser',
'info' =>
"Invalid username \"\$1\"" ],
1922 'invalidexpiry' => [
'code' =>
'invalidexpiry',
'info' =>
"Invalid expiry time \"\$1\"" ],
1923 'pastexpiry' => [
'code' =>
'pastexpiry',
'info' =>
"Expiry time \"\$1\" is in the past" ],
1924 'create-titleexists' => [
1925 'code' =>
'create-titleexists',
1926 'info' =>
"Existing titles can't be protected with 'create'"
1928 'missingtitle-createonly' => [
1929 'code' =>
'missingtitle-createonly',
1930 'info' =>
"Missing titles can only be protected with 'create'"
1932 'cantblock' => [
'code' =>
'cantblock',
1933 'info' =>
"You don't have permission to block users"
1936 'code' =>
'canthide',
1937 'info' =>
"You don't have permission to hide user names from the block log"
1939 'cantblock-email' => [
1940 'code' =>
'cantblock-email',
1941 'info' =>
"You don't have permission to block users from sending email through the wiki"
1943 'unblock-notarget' => [
1944 'code' =>
'notarget',
1945 'info' =>
'Either the id or the user parameter must be set'
1947 'unblock-idanduser' => [
1948 'code' =>
'idanduser',
1949 'info' =>
"The id and user parameters can't be used together"
1952 'code' =>
'permissiondenied',
1953 'info' =>
"You don't have permission to unblock users"
1955 'cannotundelete' => [
1956 'code' =>
'cantundelete',
1957 'info' =>
"Couldn't undelete: the requested revisions may not exist, or may have been undeleted already"
1959 'permdenied-undelete' => [
1960 'code' =>
'permissiondenied',
1961 'info' =>
"You don't have permission to restore deleted revisions"
1963 'createonly-exists' => [
1964 'code' =>
'articleexists',
1965 'info' =>
'The article you tried to create has been created already'
1967 'nocreate-missing' => [
1968 'code' =>
'missingtitle',
1969 'info' =>
"The article you tried to edit doesn't exist"
1971 'cantchangecontentmodel' => [
1972 'code' =>
'cantchangecontentmodel',
1973 'info' =>
"You don't have permission to change the content model of a page"
1976 'code' =>
'nosuchrcid',
1977 'info' =>
"There is no change with rcid \"\$1\""
1980 'code' =>
'nosuchlogid',
1981 'info' =>
"There is no log entry with ID \"\$1\""
1983 'protect-invalidaction' => [
1984 'code' =>
'protect-invalidaction',
1985 'info' =>
"Invalid protection type \"\$1\""
1987 'protect-invalidlevel' => [
1988 'code' =>
'protect-invalidlevel',
1989 'info' =>
"Invalid protection level \"\$1\""
1991 'toofewexpiries' => [
1992 'code' =>
'toofewexpiries',
1993 'info' =>
"\$1 expiry timestamps were provided where \$2 were needed"
1996 'code' =>
'cantimport',
1997 'info' =>
"You don't have permission to import pages"
1999 'cantimport-upload' => [
2000 'code' =>
'cantimport-upload',
2001 'info' =>
"You don't have permission to import uploaded pages"
2003 'importnofile' => [
'code' =>
'nofile',
'info' =>
"You didn't upload a file" ],
2004 'importuploaderrorsize' => [
2005 'code' =>
'filetoobig',
2006 'info' =>
'The file you uploaded is bigger than the maximum upload size'
2008 'importuploaderrorpartial' => [
2009 'code' =>
'partialupload',
2010 'info' =>
'The file was only partially uploaded'
2012 'importuploaderrortemp' => [
2013 'code' =>
'notempdir',
2014 'info' =>
'The temporary upload directory is missing'
2016 'importcantopen' => [
2017 'code' =>
'cantopenfile',
2018 'info' =>
"Couldn't open the uploaded file"
2020 'import-noarticle' => [
2021 'code' =>
'badinterwiki',
2022 'info' =>
'Invalid interwiki title specified'
2024 'importbadinterwiki' => [
2025 'code' =>
'badinterwiki',
2026 'info' =>
'Invalid interwiki title specified'
2028 'import-unknownerror' => [
2029 'code' =>
'import-unknownerror',
2030 'info' =>
"Unknown error on import: \"\$1\""
2032 'cantoverwrite-sharedfile' => [
2033 'code' =>
'cantoverwrite-sharedfile',
2034 'info' =>
'The target file exists on a shared repository and you do not have permission to override it'
2036 'sharedfile-exists' => [
2037 'code' =>
'fileexists-sharedrepo-perm',
2038 'info' =>
'The target file exists on a shared repository. Use the ignorewarnings parameter to override it.'
2041 'code' =>
'mustbeposted',
2042 'info' =>
"The \$1 module requires a POST request"
2046 'info' =>
'Incorrect parameter - mutually exclusive values may not be supplied'
2048 'specialpage-cantexecute' => [
2049 'code' =>
'specialpage-cantexecute',
2050 'info' =>
"You don't have permission to view the results of this special page"
2052 'invalidoldimage' => [
2053 'code' =>
'invalidoldimage',
2054 'info' =>
'The oldimage parameter has invalid format'
2056 'nodeleteablefile' => [
2057 'code' =>
'nodeleteablefile',
2058 'info' =>
'No such old version of the file'
2060 'fileexists-forbidden' => [
2061 'code' =>
'fileexists-forbidden',
2062 'info' =>
'A file with name "$1" already exists, and cannot be overwritten.'
2064 'fileexists-shared-forbidden' => [
2065 'code' =>
'fileexists-shared-forbidden',
2066 'info' =>
'A file with name "$1" already exists in the shared file repository, and cannot be overwritten.'
2068 'filerevert-badversion' => [
2069 'code' =>
'filerevert-badversion',
2070 'info' =>
'There is no previous local version of this file with the provided timestamp.'
2074 'noimageredirect-anon' => [
2075 'code' =>
'noimageredirect-anon',
2076 'info' =>
"Anonymous users can't create image redirects"
2078 'noimageredirect-logged' => [
2079 'code' =>
'noimageredirect',
2080 'info' =>
"You don't have permission to create image redirects"
2083 'code' =>
'spamdetected',
2084 'info' =>
"Your edit was refused because it contained a spam fragment: \"\$1\""
2086 'contenttoobig' => [
2087 'code' =>
'contenttoobig',
2088 'info' =>
"The content you supplied exceeds the article size limit of \$1 kilobytes"
2090 'noedit-anon' => [
'code' =>
'noedit-anon',
'info' =>
"Anonymous users can't edit pages" ],
2091 'noedit' => [
'code' =>
'noedit',
'info' =>
"You don't have permission to edit pages" ],
2093 'code' =>
'pagedeleted',
2094 'info' =>
'The page has been deleted since you fetched its timestamp'
2097 'code' =>
'emptypage',
2098 'info' =>
'Creating new, empty pages is not allowed'
2100 'editconflict' => [
'code' =>
'editconflict',
'info' =>
'Edit conflict detected' ],
2101 'hashcheckfailed' => [
'code' =>
'badmd5',
'info' =>
'The supplied MD5 hash was incorrect' ],
2104 'info' =>
'One of the text, appendtext, prependtext and undo parameters must be set'
2106 'emptynewsection' => [
2107 'code' =>
'emptynewsection',
2108 'info' =>
'Creating empty new sections is not possible.'
2111 'code' =>
'revwrongpage',
2112 'info' =>
"r\$1 is not a revision of \"\$2\""
2115 'code' =>
'undofailure',
2116 'info' =>
'Undo failed due to conflicting intermediate edits'
2118 'content-not-allowed-here' => [
2119 'code' =>
'contentnotallowedhere',
2120 'info' =>
'Content model "$1" is not allowed at title "$2"'
2124 'edit-hook-aborted' => [
2125 'code' =>
'edit-hook-aborted',
2126 'info' =>
'Your edit was aborted by an ArticleSave hook'
2128 'edit-gone-missing' => [
2129 'code' =>
'edit-gone-missing',
2130 'info' =>
"The page you tried to edit doesn't seem to exist anymore"
2132 'edit-conflict' => [
'code' =>
'editconflict',
'info' =>
'Edit conflict detected' ],
2133 'edit-already-exists' => [
2134 'code' =>
'edit-already-exists',
2135 'info' =>
'It seems the page you tried to create already exist'
2139 'invalid-file-key' => [
'code' =>
'invalid-file-key',
'info' =>
'Not a valid file key' ],
2140 'nouploadmodule' => [
'code' =>
'nouploadmodule',
'info' =>
'No upload module set' ],
2141 'uploaddisabled' => [
2142 'code' =>
'uploaddisabled',
2143 'info' =>
'Uploads are not enabled. Make sure $wgEnableUploads is set to true in LocalSettings.php and the PHP ini setting file_uploads is true'
2145 'copyuploaddisabled' => [
2146 'code' =>
'copyuploaddisabled',
2147 'info' =>
'Uploads by URL is not enabled. Make sure $wgAllowCopyUploads is set to true in LocalSettings.php.'
2149 'copyuploadbaddomain' => [
2150 'code' =>
'copyuploadbaddomain',
2151 'info' =>
'Uploads by URL are not allowed from this domain.'
2153 'copyuploadbadurl' => [
2154 'code' =>
'copyuploadbadurl',
2155 'info' =>
'Upload not allowed from this URL.'
2158 'filename-tooshort' => [
2159 'code' =>
'filename-tooshort',
2160 'info' =>
'The filename is too short'
2162 'filename-toolong' => [
'code' =>
'filename-toolong',
'info' =>
'The filename is too long' ],
2163 'illegal-filename' => [
2164 'code' =>
'illegal-filename',
2165 'info' =>
'The filename is not allowed'
2167 'filetype-missing' => [
2168 'code' =>
'filetype-missing',
2169 'info' =>
'The file is missing an extension'
2172 'mustbeloggedin' => [
'code' =>
'mustbeloggedin',
'info' =>
'You must be logged in to $1.' ]
2182 $parsed = $this->
parseMsg( [
'readonlytext' ] );
2183 $this->
dieUsage( $parsed[
'info'], $parsed[
'code'], 0,
2193 # most of the time we send a 1 element, so we might as well send it as
2194 # a string and make this an array here.
2195 if ( is_string( $error ) ) {
2196 $error = [ $error ];
2198 $parsed = $this->
parseMsg( $error );
2199 $extraData = isset( $parsed[
'data'] ) ? $parsed[
'data'] : null;
2200 $this->
dieUsage( $parsed[
'info'], $parsed[
'code'], 0, $extraData );
2211 if ( $this->
getConfig()->
get(
'DebugAPI' ) !==
true ) {
2215 if ( is_string( $error ) ) {
2216 $error = [ $error ];
2218 $parsed = $this->
parseMsg( $error );
2219 $this->
setWarning(
'$wgDebugAPI: ' . $parsed[
'code'] .
' - ' . $parsed[
'info'] );
2232 'Invalid continue param. You should pass the original value returned by the previous query',
2247 if ( is_array( $error ) ) {
2248 $first = reset( $error );
2249 if ( is_array( $first ) ) {
2259 'code' => $msg->getApiCode(),
2260 'info' => $msg->inLanguage(
'en' )->useDatabase(
false )->text(),
2261 'data' => $msg->getApiData()
2265 $key = $msg->getKey();
2266 if ( isset( self::$messageMap[$key] ) ) {
2275 return $this->
parseMsg( [
'unknownerror', $key ] );
2284 protected static function dieDebug( $method, $message ) {
2285 throw new MWException(
"Internal error in $method: $message" );
2295 $s =
'"' . addslashes( $feature ) .
'"' .
2298 ' "' . addslashes(
$request->getHeader(
'Referer' ) ) .
'"' .
2299 ' "' . addslashes( $this->
getMain()->getUserAgent() ) .
'"';
2316 return "apihelp-{$this->getModulePath()}-description";
2328 Hooks::run(
'APIGetDescription', [ &$this, &$desc ] );
2329 $desc = self::escapeWikiText( $desc );
2330 if ( is_array( $desc ) ) {
2331 $desc = implode(
"\n", $desc );
2341 if ( !$msg->exists() ) {
2342 $msg = $this->
msg(
'api-help-fallback-description', $desc );
2346 Hooks::run(
'APIGetDescriptionMessages', [ $this, &$msgs ] );
2370 'api-help-param-token',
2394 Hooks::run(
'APIGetParamDescription', [ &$this, &$desc ] );
2399 $desc = self::escapeWikiText( $desc );
2403 foreach (
$params as $param => $settings ) {
2404 if ( !is_array( $settings ) ) {
2408 $d = isset( $desc[$param] ) ? $desc[$param] :
'';
2409 if ( is_array( $d ) ) {
2411 $d = array_map(
function (
$line ) {
2412 if ( preg_match(
'/^\s+(\S+)\s+-\s+(.+)$/',
$line, $m ) ) {
2413 $line =
"\n;{$m[1]}:{$m[2]}";
2417 $d = implode(
' ', $d );
2423 $msg = $this->
msg(
"apihelp-{$path}-param-{$param}" );
2424 if ( !$msg->exists() ) {
2425 $msg = $this->
msg(
'api-help-fallback-parameter', $d );
2431 self::dieDebug( __METHOD__,
2432 'Value in ApiBase::PARAM_HELP_MSG is not valid' );
2434 $msgs[$param] = [ $msg ];
2437 if ( !is_array( $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE] ) ) {
2438 self::dieDebug( __METHOD__,
2439 'ApiBase::PARAM_HELP_MSG_PER_VALUE is not valid' );
2442 self::dieDebug( __METHOD__,
2443 'ApiBase::PARAM_HELP_MSG_PER_VALUE may only be used when ' .
2444 'ApiBase::PARAM_TYPE is an array' );
2448 foreach ( $settings[ApiBase::PARAM_TYPE]
as $value ) {
2449 if ( isset( $valueMsgs[$value] ) ) {
2450 $msg = $valueMsgs[
$value];
2452 $msg =
"apihelp-{$path}-paramvalue-{$param}-{$value}";
2459 [ $m->getKey(),
'api-help-param-no-description' ],
2464 self::dieDebug( __METHOD__,
2465 "Value in ApiBase::PARAM_HELP_MSG_PER_VALUE for $value is not valid" );
2471 if ( !is_array( $settings[ApiBase::PARAM_HELP_MSG_APPEND] ) ) {
2472 self::dieDebug( __METHOD__,
2473 'Value for ApiBase::PARAM_HELP_MSG_APPEND is not an array' );
2475 foreach ( $settings[ApiBase::PARAM_HELP_MSG_APPEND]
as $m ) {
2479 $msgs[$param][] = $m;
2481 self::dieDebug( __METHOD__,
2482 'Value in ApiBase::PARAM_HELP_MSG_APPEND is not valid' );
2488 Hooks::run(
'APIGetParamDescriptionMessages', [ $this, &$msgs ] );
2515 $flags[] =
'writerights';
2518 $flags[] =
'mustbeposted';
2538 if ( $this->mModuleSource !==
false ) {
2543 $rClass =
new ReflectionClass( $this );
2544 $path = $rClass->getFileName();
2547 $this->mModuleSource = null;
2553 if ( self::$extensionInfo === null ) {
2554 $extDir = $this->
getConfig()->get(
'ExtensionDirectory' );
2555 self::$extensionInfo = [
2556 realpath( __DIR__ ) ?: __DIR__ => [
2558 'name' =>
'MediaWiki',
2559 'license-name' =>
'GPL-2.0+',
2561 realpath(
"$IP/extensions" ) ?:
"$IP/extensions" => null,
2562 realpath( $extDir ) ?: $extDir => null,
2568 'license-name' => null,
2570 foreach ( $this->
getConfig()->
get(
'ExtensionCredits' )
as $group ) {
2571 foreach ( $group
as $ext ) {
2572 if ( !isset( $ext[
'path'] ) || !isset( $ext[
'name'] ) ) {
2577 $extpath = $ext[
'path'];
2578 if ( !is_dir( $extpath ) ) {
2579 $extpath = dirname( $extpath );
2581 self::$extensionInfo[realpath( $extpath ) ?: $extpath] =
2582 array_intersect_key( $ext, $keep );
2586 $extpath = $ext[
'path'];
2587 if ( !is_dir( $extpath ) ) {
2588 $extpath = dirname( $extpath );
2590 self::$extensionInfo[realpath( $extpath ) ?: $extpath] =
2591 array_intersect_key( $ext, $keep );
2598 if ( array_key_exists(
$path, self::$extensionInfo ) ) {
2600 $this->mModuleSource = self::$extensionInfo[
$path];
2606 }
while (
$path !== $oldpath );
2609 $this->mModuleSource = null;
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
dieUsageMsgOrDebug($error)
Will only set a warning instead of failing if the global $wgDebugAPI is set to true.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
setContext(IContextSource $context)
Set the IContextSource object.
const PARAM_VALUE_LINKS
(string[]) When PARAM_TYPE is an array, this may be an array mapping those values to page titles whic...
getFinalParamDescription()
Get final parameter descriptions, after hooks have had a chance to tweak it as needed.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below...
getErrorFormatter()
Get the error formatter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
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
Interface for objects which can provide a MediaWiki context on request.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
isReadMode()
Indicates whether this module requires read rights.
the array() calling protocol came about after MediaWiki 1.4rc1.
validateTimestamp($value, $encParamName)
Validate and normalize of parameters of type 'timestamp'.
getResult()
Get the result object.
static $messageMap
Array that maps message keys to error messages.
getWatchlistUser($params)
Gets the user for whom to get the watchlist.
Message subclass that prepends wikitext for API help.
getParameter($paramName, $parseLimit=true)
Get a value for the given parameter.
explodeMultiValue($value, $limit)
Split a multi-valued parameter string, like explode()
getDescriptionMessage()
Return the description message.
getModuleProfileName($db=false)
getModuleSourceInfo()
Returns information about the source of this module, if known.
getCustomPrinter()
If the module may only be used with a certain format module, it should override this method to return...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
static array $extensionInfo
Maps extension paths to info arrays.
requireMaxOneParameter($params, $required)
Die if more than one of a certain set of parameters is set and not false.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getMain()
Get the main module.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
static escapeWikiText($v)
A subset of wfEscapeWikiText for BC texts.
getType()
Get the type of target for this particular block.
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
const LIMIT_BIG1
Fast query, standard limit.
getDB()
Gets a default replica DB connection object.
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
setWatch($watch, $titleObj, $userOption=null)
Set a watch (or unwatch) based the based on a watchlist parameter.
const PARAM_REQUIRED
(boolean) Is the parameter required?
getWatchlistValue($watchlist, $titleObj, $userOption=null)
Return true if we're to watch the page, false if not, null if no change.
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
lacksSameOriginSecurity()
Returns true if the current request breaks the same-origin policy.
extractRequestParams($parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user...
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
getParent()
Get the parent of this module.
requireOnlyOneParameter($params, $required)
Die if none or more than one of a certain set of parameters is set and not false. ...
static makeMessage($msg, IContextSource $context, array $params=null)
Create a Message from a string or array.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
Interface for messages with machine-readable data for use by the API.
wfUrlencode($s)
We want some things to be included as literal characters in our title URLs for prettiness, which urlencode encodes by default.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
isDeprecated()
Indicates whether this module is deprecated.
when a variable name is used in a it is silently declared as a new local masking the global
getHelpUrls()
Return links to more detailed help pages about the module.
needsToken()
Returns the token type this module requires in order to execute.
getConditionalRequestData($condition)
Returns data for HTTP conditional request mechanisms.
getParameterFromSettings($paramName, $paramSettings, $parseLimit)
Using the settings determine the value for the given parameter.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static getBlockInfo(Block $block)
Get basic info about a given block.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getRequest()
Get the WebRequest object.
wfMsgReplaceArgs($message, $args)
Replace message parameter keys on the given formatted output.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
wfDebugLog($logGroup, $text, $dest= 'all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not...
getTitleOrPageId($params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
const PARAM_SUBMODULE_PARAM_PREFIX
(string) When PARAM_TYPE is 'submodule', used to indicate the 'g' prefix added by ApiQueryGeneratorBa...
static truncateArray(&$arr, $limit)
Truncate an array to a certain length.
validateToken($token, array $params)
Validate the supplied token.
parameterNotEmpty($x)
Callback function used in requireOnlyOneParameter to check whether required parameters are set...
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"<
getErrorFromStatus($status, &$extraData=null)
Get error (as code, string) from a Status object.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
getHelpFlags()
Generates the list of flags for the help screen and for action=paraminfo.
const PARAM_RANGE_ENFORCE
(boolean) For PARAM_TYPE 'integer', enforce PARAM_MIN and PARAM_MAX?
getModulePath()
Get the path to this module.
getContinuationManager()
Get the continuation manager.
getConfig()
Get the Config object.
const LIMIT_SML2
Slow query, apihighlimits limit.
const PARAM_SUBMODULE_MAP
(string[]) When PARAM_TYPE is 'submodule', map parameter values to submodule paths.
getContext()
Get the base IContextSource object.
This is the main API class, used for both external and internal processing.
validateUser($value, $encParamName)
Validate and normalize of parameters of type 'user'.
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
isInternal()
Indicates whether this module is "internal" Internal API modules are not (yet) intended for 3rd party...
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
setContext(IContextSource $context)
Set the language and the title from a context object.
namespace and then decline to actually register it file or subcat img or subcat $title
dynamicParameterDocumentation()
Indicate if the module supports dynamically-determined parameters that cannot be included in self::ge...
getModuleName()
Get the name of the module being executed by this instance.
static dieReadOnly()
Helper function for readonly errors.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right, for PARAM_TYPE 'limit'.
setWarning($warning)
Set warning section for this module.
modifyHelp(array &$help, array $options, array &$tocData)
Called from ApiHelp before the pieces are joined together and returned.
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
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 modifiable & $code
dieContinueUsageIf($condition)
Die with the $prefix.
requirePostedParameters($params, $prefix= 'prefix')
Die if any of the specified parameters were found in the query part of the URL rather than the post b...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter...
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
handleParamNormalization($paramName, $value, $rawValue)
Handle when a parameter was Unicode-normalized.
const LIMIT_SML1
Slow query, standard limit.
getModuleManager()
Get the module manager, or null if this module has no sub-modules.
wfGetAllCallers($limit=3)
Return a string consisting of callers in the stack.
static getTokenTypeSalts()
Get the salts for known token types.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
mustBePosted()
Indicates whether this module must be called with a POST request.
error also a ContextSource you ll probably need to make sure the header is varied on $request
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
validateLimit($paramName, &$value, $min, $max, $botMax=null, $enforceLimits=false)
Validate the value against the minimum and user/bot maximum limits.
getDescription()
Returns the description string for this module.
parseMultiValue($valueName, $value, $allowMultiple, $allowedValues)
Return an array of values that were given in a 'a|b|c' notation, after it optionally validates them a...
static getToken(User $user, MediaWiki\Session\Session $session, $salt)
Get a token from a salt.
getFinalDescription()
Get final module description, after hooks have had a chance to tweak it as needed.
requireAtLeastOneParameter($params, $required)
Die if none of a certain set of parameters is set and not false.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
__construct(ApiMain $mainModule, $moduleName, $modulePrefix= '')
wfTransactionalTimeLimit()
Set PHP's time limit to the larger of php.ini or $wgTransactionalTimeLimit.
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...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired 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 inclusive $limit
getExamples()
Returns usage examples for this module.
dieBlocked(Block $block)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
static newFromID($id, $from= 'fromdb')
Constructor from a page id.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Extension of RawMessage implementing IApiMessage.
This abstract class implements many basic API functions, and is the base of all API classes...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getWebUITokenSalt(array $params)
Fetch the salt used in the Web UI corresponding to this module.
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
array null bool $mModuleSource
getParamDescription()
Returns an array of parameter descriptions.
getExamplesMessages()
Returns usage examples for this module.
parseMsg($error)
Return the error message related to a certain array.
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
static dieDebug($method, $message)
Internal code errors should be reported with this method.
logFeatureUsage($feature)
Write logging information for API features to a debug log, for usage analysis.
static doWatchOrUnwatch($watch, Title $title, User $user)
Watch or unwatch a page.
dieStatus($status)
Throw a UsageException based on the errors in the Status object.
shouldCheckMaxlag()
Indicates if this module needs maxlag to be checked.
static getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
encodeParamName($paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
setContinuationManager($manager)
Set the continuation manager.
warnOrDie($msg, $enforceLimits=false)
Adds a warning to the output, else dies.
getUser()
Get the User object.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
dieUsageMsg($error)
Output the error message related to a certain array.
const PARAM_ALLOW_DUPLICATES
(boolean) Allow the same value to be set more than once when PARAM_ISMULTI is true?
getModuleFromPath($path)
Get a module from its module path.
This exception will be thrown when dieUsage is called to stop module execution.
getFinalParams($flags=0)
Get final list of parameters, after hooks have had a chance to tweak it as needed.
isMain()
Returns true if this module is the main module ($this === $this->mMainModule), false otherwise...
isWriteMode()
Indicates whether this module requires write mode.
Allows to change the fields on the form that will be generated $name
static newFromSpecifier($value)
Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key...
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...