217 $this->mMainModule = $mainModule;
218 $this->mModuleName = $moduleName;
219 $this->mModulePrefix = $modulePrefix;
288 if ( !is_array( $examples ) ) {
289 $examples = [ $examples ];
290 } elseif ( $examples && ( count( $examples ) & 1 ) == 0 &&
291 array_keys( $examples ) === range( 0, count( $examples ) - 1 ) &&
292 !preg_match(
'/^\s*api\.php\?/', $examples[0] )
297 $examplesCount = count( $examples );
298 for ( $i = 0; $i < $examplesCount; $i += 2 ) {
299 $tmp[$examples[$i + 1]] = $examples[$i];
304 foreach ( $examples
as $k => $v ) {
305 if ( is_numeric( $k ) ) {
311 if ( is_array( $msg ) ) {
312 $msg = implode(
' ', $msg );
316 $qs = preg_replace(
'/^\s*api\.php\?/',
'', $qs );
317 $ret[$qs] = $this->
msg(
'api-help-fallback-example', [ $msg ] );
519 return $this->
getMain()->lacksSameOriginSecurity();
548 if (
$path ===
'main' ) {
552 $parts = explode(
'+',
$path );
553 if ( count( $parts ) === 1 ) {
555 $parts = explode(
' ',
$path );
559 for ( $i = 0; $i <
$count; $i++ ) {
561 $manager = $parent->getModuleManager();
562 if ( $manager ===
null ) {
563 $errorPath = implode(
'+', array_slice( $parts, 0, $i ) );
564 $this->
dieUsage(
"The module \"$errorPath\" has no submodules",
'badmodule' );
566 $module = $manager->getModule( $parts[$i] );
568 if ( $module ===
null ) {
569 $errorPath = $i ? implode(
'+', array_slice( $parts, 0, $i ) ) : $parent->getModuleName();
571 "The module \"$errorPath\" does not have a submodule \"{$parts[$i]}\"",
591 return $this->
getMain()->getResult();
605 return $this->
getMain()->getErrorFormatter();
613 if ( !isset( $this->mSlaveDB ) ) {
631 return $this->
getMain()->getContinuationManager();
645 $this->
getMain()->setContinuationManager( $manager );
673 return $this->mModulePrefix . $paramName;
687 if ( !isset( $this->mParamCache[$parseLimit] ) ) {
692 foreach (
$params as $paramName => $paramSettings ) {
694 $paramName, $paramSettings, $parseLimit );
697 $this->mParamCache[$parseLimit] = $results;
700 return $this->mParamCache[$parseLimit];
722 $required = func_get_args();
723 array_shift( $required );
726 $intersection = array_intersect( array_keys( array_filter(
$params,
727 [ $this,
'parameterNotEmpty' ] ) ), $required );
729 if ( count( $intersection ) > 1 ) {
731 "The parameters {$p}" . implode(
", {$p}", $intersection ) .
' can not be used together',
733 } elseif ( count( $intersection ) == 0 ) {
735 "One of the parameters {$p}" . implode(
", {$p}", $required ) .
' is required',
748 $required = func_get_args();
749 array_shift( $required );
752 $intersection = array_intersect( array_keys( array_filter(
$params,
753 [ $this,
'parameterNotEmpty' ] ) ), $required );
755 if ( count( $intersection ) > 1 ) {
757 "The parameters {$p}" . implode(
", {$p}", $intersection ) .
' can not be used together',
771 $required = func_get_args();
772 array_shift( $required );
775 $intersection = array_intersect(
776 array_keys( array_filter(
$params, [ $this,
'parameterNotEmpty' ] ) ),
780 if ( count( $intersection ) == 0 ) {
781 $this->
dieUsage(
"At least one of the parameters {$p}" .
782 implode(
", {$p}", $required ) .
' is required',
"{$p}missingparam" );
795 if ( $this->
getConfig()->
get(
'DebugAPI' ) || $this->
getMain()->isInternalMode() ) {
799 $queryValues = $this->
getRequest()->getQueryValues();
802 if ( $prefix !==
'noprefix' ) {
805 if ( array_key_exists( $param, $queryValues ) ) {
806 $badParams[] = $param;
812 'The following parameters were found in the query string, but must be in the POST body: '
813 . join(
', ', $badParams ),
826 return !is_null( $x ) && $x !==
false;
844 if ( isset(
$params[
'title'] ) ) {
845 $titleObj = Title::newFromText(
$params[
'title'] );
846 if ( !$titleObj || $titleObj->isExternal() ) {
849 if ( !$titleObj->canExist() ) {
850 $this->
dieUsage(
"Namespace doesn't allow actual pages",
'pagecannotexist' );
853 if ( $load !==
false ) {
854 $pageObj->loadPageData( $load );
856 } elseif ( isset(
$params[
'pageid'] ) ) {
857 if ( $load ===
false ) {
879 $userWatching = $this->
getUser()->isWatched( $titleObj, User::IGNORE_USER_RIGHTS );
881 switch ( $watchlist ) {
889 # If the user is already watching, don't bother checking
890 if ( $userWatching ) {
893 # If no user option was passed, use watchdefault and watchcreations
894 if ( is_null( $userOption ) ) {
895 return $this->
getUser()->getBoolOption(
'watchdefault' ) ||
896 $this->
getUser()->getBoolOption(
'watchcreations' ) && !$titleObj->exists();
899 # Watch the article based on the user preference
900 return $this->
getUser()->getBoolOption( $userOption );
903 return $userWatching;
906 return $userWatching;
923 if ( !is_array( $paramSettings ) ) {
924 $default = $paramSettings;
926 $type = gettype( $paramSettings );
931 $default = isset( $paramSettings[self::PARAM_DFLT] )
934 $multi = isset( $paramSettings[self::PARAM_ISMULTI] )
937 $type = isset( $paramSettings[self::PARAM_TYPE] )
940 $dupes = isset( $paramSettings[self::PARAM_ALLOW_DUPLICATES] )
943 $deprecated = isset( $paramSettings[self::PARAM_DEPRECATED] )
946 $required = isset( $paramSettings[self::PARAM_REQUIRED] )
951 if ( !isset(
$type ) ) {
952 if ( isset( $default ) ) {
953 $type = gettype( $default );
959 if (
$type ==
'password' || !empty( $paramSettings[self::PARAM_SENSITIVE] ) ) {
960 $this->
getMain()->markParamsSensitive( $encParamName );
964 if (
$type ==
'boolean' ) {
965 if ( isset( $default ) && $default !==
false ) {
969 "Boolean param $encParamName's default is set to '$default'. " .
970 'Boolean parameters must default to false.'
975 } elseif (
$type ==
'upload' ) {
976 if ( isset( $default ) ) {
980 "File upload param $encParamName's default is set to " .
981 "'$default'. File upload parameters may not have a default." );
987 if ( !
$value->exists() ) {
991 $value = $this->
getMain()->getRequest()->unsetVal( $encParamName );
994 "File upload param $encParamName is not a file upload; " .
995 'be sure to use multipart/form-data for your POST and include ' .
996 'a filename in the Content-Disposition header.',
997 "badupload_{$encParamName}"
1002 $value = $this->
getMain()->getVal( $encParamName, $default );
1005 $type = MWNamespace::getValidNamespaces();
1008 if ( isset( $paramSettings[self::PARAM_SUBMODULE_MAP] ) ) {
1009 $type = array_keys( $paramSettings[self::PARAM_SUBMODULE_MAP] );
1016 $rawValue =
$request->getRawVal( $encParamName );
1017 if ( $rawValue ===
null ) {
1018 $rawValue = $default;
1022 if ( isset(
$value ) && substr( $rawValue, 0, 1 ) ===
"\x1f" ) {
1026 $value = join(
"\x1f",
$request->normalizeUnicode( explode(
"\x1f", $rawValue ) ) );
1029 "U+001F multi-value separation may only be used for multi-valued parameters.",
1030 'badvalue_notmultivalue'
1036 if ( $rawValue !==
$value ) {
1041 if ( isset(
$value ) && ( $multi || is_array(
$type ) ) ) {
1053 if ( !is_array(
$type ) ) {
1060 if ( $required &&
$value ===
'' ) {
1061 $this->
dieUsageMsg( [
'missingparam', $paramName ] );
1065 $min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[
self::PARAM_MIN] :
null;
1066 $max = isset( $paramSettings[self::PARAM_MAX] ) ? $paramSettings[
self::PARAM_MAX] :
null;
1067 $enforceLimits = isset( $paramSettings[self::PARAM_RANGE_ENFORCE] )
1070 if ( is_array(
$value ) ) {
1072 if ( !is_null( $min ) || !is_null( $max ) ) {
1074 $this->
validateLimit( $paramName, $v, $min, $max,
null, $enforceLimits );
1079 if ( !is_null( $min ) || !is_null( $max ) ) {
1085 if ( !$parseLimit ) {
1089 if ( !isset( $paramSettings[self::PARAM_MAX] )
1090 || !isset( $paramSettings[self::PARAM_MAX2] )
1094 "MAX1 or MAX2 are not defined for the limit $encParamName"
1098 ApiBase::dieDebug( __METHOD__,
"Multi-values not supported for $encParamName" );
1100 $min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[
self::PARAM_MIN] : 0;
1112 $paramSettings[self::PARAM_MAX],
1113 $paramSettings[self::PARAM_MAX2]
1119 ApiBase::dieDebug( __METHOD__,
"Multi-values not supported for $encParamName" );
1123 if ( is_array(
$value ) ) {
1124 foreach (
$value as $key => $val ) {
1132 if ( is_array(
$value ) ) {
1133 foreach (
$value as $key => $val ) {
1144 if ( !is_array(
$value ) && !$multi ) {
1148 if ( !$tagsStatus->isGood() ) {
1153 ApiBase::dieDebug( __METHOD__,
"Param $encParamName's type is unknown - $type" );
1158 if ( !$dupes && is_array(
$value ) ) {
1163 if ( $deprecated &&
$value !==
false ) {
1164 $this->
setWarning(
"The $encParamName parameter has been deprecated." );
1166 $feature = $encParamName;
1168 while ( !$m->isMain() ) {
1169 $p = $m->getParent();
1170 $name = $m->getModuleName();
1171 $param = $p->encodeParamName( $p->getModuleManager()->getModuleGroup(
$name ) );
1172 $feature =
"{$param}={$name}&{$feature}";
1177 } elseif ( $required ) {
1178 $this->
dieUsageMsg( [
'missingparam', $paramName ] );
1194 "The value passed for '$encParamName' contains invalid or non-normalized data. "
1195 .
'Textual data should be valid, NFC-normalized Unicode without '
1196 .
'C0 control characters other than HT (\\t), LF (\\n), and CR (\\r).'
1208 if ( substr(
$value, 0, 1 ) ===
"\x1f" ) {
1232 if ( ( trim(
$value ) ===
'' || trim(
$value ) ===
"\x1f" ) && $allowMultiple ) {
1239 $sizeLimit = count( $valuesList ) > self::LIMIT_SML1 && $this->mMainModule->canApiHighLimits()
1243 if ( self::truncateArray( $valuesList, $sizeLimit ) ) {
1244 $this->
logFeatureUsage(
"too-many-$valueName-for-{$this->getModulePath()}" );
1245 $this->
setWarning(
"Too many values supplied for parameter '$valueName': " .
1246 "the limit is $sizeLimit" );
1249 if ( !$allowMultiple && count( $valuesList ) != 1 ) {
1251 if ( in_array(
$value, $allowedValues,
true ) ) {
1255 $possibleValues = is_array( $allowedValues )
1256 ?
"of '" . implode(
"', '", $allowedValues ) .
"'"
1259 "Only one $possibleValues is allowed for parameter '$valueName'",
1260 "multival_$valueName"
1264 if ( is_array( $allowedValues ) ) {
1266 $unknown = array_diff( $valuesList, $allowedValues );
1267 if ( count( $unknown ) ) {
1268 if ( $allowMultiple ) {
1269 $s = count( $unknown ) > 1 ?
's' :
'';
1270 $vals = implode(
', ', $unknown );
1271 $this->
setWarning(
"Unrecognized value$s for parameter '$valueName': $vals" );
1274 "Unrecognized value for parameter '$valueName': {$valuesList[0]}",
1275 "unknown_$valueName"
1280 $valuesList = array_intersect( $valuesList, $allowedValues );
1283 return $allowMultiple ? $valuesList : $valuesList[0];
1297 $enforceLimits =
false
1299 if ( !is_null( $min ) &&
$value < $min ) {
1300 $msg = $this->
encodeParamName( $paramName ) .
" may not be less than $min (set to $value)";
1301 $this->
warnOrDie( $msg, $enforceLimits );
1307 if ( $this->
getMain()->isInternalMode() ) {
1313 if ( !is_null( $max ) &&
$value > $max ) {
1314 if ( !is_null( $botMax ) && $this->
getMain()->canApiHighLimits() ) {
1315 if (
$value > $botMax ) {
1317 " may not be over $botMax (set to $value) for bots or sysops";
1318 $this->
warnOrDie( $msg, $enforceLimits );
1322 $msg = $this->
encodeParamName( $paramName ) .
" may not be over $max (set to $value) for users";
1323 $this->
warnOrDie( $msg, $enforceLimits );
1342 "Passing '$value' for timestamp parameter $encParamName has been deprecated." .
1343 ' If for some reason you need to explicitly specify the current time without' .
1344 ' calculating it client-side, use "now".'
1350 if (
$value ===
'now' ) {
1355 if ( $unixTimestamp ===
false ) {
1357 "Invalid value '$value' for timestamp parameter $encParamName",
1358 "badtimestamp_{$encParamName}"
1377 if ( !isset( $salts[$tokenType] ) ) {
1379 "Module '{$this->getModuleName()}' tried to use token type '$tokenType' " .
1380 'without registering it'
1387 if ( $tokenObj->match( $token ) ) {
1392 if ( $webUiSalt !==
null && $this->
getUser()->matchEditToken(
1413 "Invalid value '$value' for user parameter $encParamName",
1414 "baduser_{$encParamName}"
1418 return $title->getText();
1434 protected function setWatch( $watch, $titleObj, $userOption =
null ) {
1451 while ( count( $arr ) >
$limit ) {
1466 if ( !is_null(
$params[
'owner'] ) && !is_null(
$params[
'token'] ) ) {
1469 $this->
dieUsage(
'Specified user does not exist',
'bad_wlowner' );
1471 $token =
$user->getOption(
'watchlisttoken' );
1472 if ( $token ==
'' || !hash_equals( $token,
$params[
'token'] ) ) {
1474 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences',
1479 if ( !$this->
getUser()->isLoggedIn() ) {
1480 $this->
dieUsage(
'You must be logged-in to have a watchlist',
'notloggedin' );
1482 if ( !$this->
getUser()->isAllowed(
'viewmywatchlist' ) ) {
1483 $this->
dieUsage(
'You don\'t have permission to view your watchlist',
'permissiondenied' );
1499 if ( is_array( $v ) ) {
1500 return array_map(
'self::escapeWikiText', $v );
1503 '__' =>
'__',
'{' =>
'{',
'}' =>
'}',
1504 '[[Category:' =>
'[[:Category:',
1505 '[[File:' =>
'[[:File:',
'[[Image:' =>
'[[:Image:',
1523 if ( is_string( $msg ) ) {
1525 } elseif ( is_array( $msg ) ) {
1526 $msg = call_user_func_array(
'wfMessage', $msg );
1528 if ( !$msg instanceof
Message ) {
1565 private function warnOrDie( $msg, $enforceLimits =
false ) {
1566 if ( $enforceLimits ) {
1567 $this->
dieUsage( $msg,
'integeroutofrange' );
1585 public function dieUsage( $description, $errorCode, $httpRespCode = 0, $extradata =
null ) {
1606 'Your IP address has been blocked automatically, because it was used by a blocked user',
1613 'You have been blocked from editing',
1632 throw new MWException(
'Successful status passed to ApiBase::dieStatus' );
1635 $errors =
$status->getErrorsByType(
'error' );
1638 $errors =
$status->getErrorsByType(
'warning' );
1642 $errors = [ [
'message' =>
'unknownerror-nocode',
'params' => [] ] ];
1647 if ( $errors[0][
'message'] instanceof
Message ) {
1648 $msg = $errors[0][
'message'];
1650 $extraData = $msg->getApiData();
1651 $code = $msg->getApiCode();
1653 $code = $msg->getKey();
1656 $code = $errors[0][
'message'];
1664 return [
$code, $msg->inLanguage(
'en' )->useDatabase(
false )->plain() ];
1686 'unknownerror' => [
'code' =>
'unknownerror',
'info' =>
"Unknown error: \"\$1\"" ],
1687 'unknownerror-nocode' => [
'code' =>
'unknownerror',
'info' =>
'Unknown error' ],
1690 'ns-specialprotected' => [
1691 'code' =>
'unsupportednamespace',
1692 'info' =>
"Pages in the Special namespace can't be edited"
1694 'protectedinterface' => [
1695 'code' =>
'protectednamespace-interface',
1696 'info' =>
"You're not allowed to edit interface messages"
1698 'namespaceprotected' => [
1699 'code' =>
'protectednamespace',
1700 'info' =>
"You're not allowed to edit pages in the \"\$1\" namespace"
1702 'customcssprotected' => [
1703 'code' =>
'customcssprotected',
1704 'info' =>
"You're not allowed to edit custom CSS pages"
1706 'customjsprotected' => [
1707 'code' =>
'customjsprotected',
1708 'info' =>
"You're not allowed to edit custom JavaScript pages"
1710 'cascadeprotected' => [
1711 'code' =>
'cascadeprotected',
1712 'info' =>
"The page you're trying to edit is protected because it's included in a cascade-protected page"
1714 'protectedpagetext' => [
1715 'code' =>
'protectedpage',
1716 'info' =>
"The \"\$1\" right is required to edit this page"
1718 'protect-cantedit' => [
1719 'code' =>
'cantedit',
1720 'info' =>
"You can't protect this page because you can't edit it"
1722 'deleteprotected' => [
1723 'code' =>
'cantedit',
1724 'info' =>
"You can't delete this page because it has been protected"
1726 'badaccess-group0' => [
1727 'code' =>
'permissiondenied',
1728 'info' =>
'Permission denied'
1730 'badaccess-groups' => [
1731 'code' =>
'permissiondenied',
1732 'info' =>
'Permission denied'
1734 'titleprotected' => [
1735 'code' =>
'protectedtitle',
1736 'info' =>
'This title has been protected from creation'
1738 'nocreate-loggedin' => [
1739 'code' =>
'cantcreate',
1740 'info' =>
"You don't have permission to create new pages"
1743 'code' =>
'cantcreate-anon',
1744 'info' =>
"Anonymous users can't create new pages"
1746 'movenologintext' => [
1747 'code' =>
'cantmove-anon',
1748 'info' =>
"Anonymous users can't move pages"
1750 'movenotallowed' => [
1751 'code' =>
'cantmove',
1752 'info' =>
"You don't have permission to move pages"
1754 'confirmedittext' => [
1755 'code' =>
'confirmemail',
1756 'info' =>
'You must confirm your email address before you can edit'
1759 'code' =>
'blocked',
1760 'info' =>
'You have been blocked from editing'
1762 'autoblockedtext' => [
1763 'code' =>
'autoblocked',
1764 'info' =>
'Your IP address has been blocked automatically, because it was used by a blocked user'
1768 'actionthrottledtext' => [
1769 'code' =>
'ratelimited',
1770 'info' =>
"You've exceeded your rate limit. Please wait some time and try again"
1772 'alreadyrolled' => [
1773 'code' =>
'alreadyrolled',
1774 'info' =>
'The page you tried to rollback was already rolled back'
1777 'code' =>
'onlyauthor',
1778 'info' =>
'The page you tried to rollback only has one author'
1781 'code' =>
'readonly',
1782 'info' =>
'The wiki is currently in read-only mode'
1784 'sessionfailure' => [
1785 'code' =>
'badtoken',
1786 'info' =>
'Invalid token' ],
1788 'code' =>
'cantdelete',
1789 'info' =>
"Couldn't delete \"\$1\". Maybe it was deleted already by someone else"
1792 'code' =>
'missingtitle',
1793 'info' =>
"The page you requested doesn't exist"
1795 'selfmove' => [
'code' =>
'selfmove',
'info' =>
"Can't move a page to itself"
1797 'immobile_namespace' => [
1798 'code' =>
'immobilenamespace',
1799 'info' =>
'You tried to move pages from or to a namespace that is protected from moving'
1801 'articleexists' => [
1802 'code' =>
'articleexists',
1803 'info' =>
'The destination article already exists and is not a redirect to the source article'
1805 'protectedpage' => [
1806 'code' =>
'protectedpage',
1807 'info' =>
"You don't have permission to perform this move"
1810 'code' =>
'hookaborted',
1811 'info' =>
'The modification you tried to make was aborted by an extension hook'
1813 'cantmove-titleprotected' => [
1814 'code' =>
'protectedtitle',
1815 'info' =>
'The destination article has been protected from creation'
1817 'imagenocrossnamespace' => [
1818 'code' =>
'nonfilenamespace',
1819 'info' =>
"Can't move a file to a non-file namespace"
1821 'imagetypemismatch' => [
1822 'code' =>
'filetypemismatch',
1823 'info' =>
"The new file extension doesn't match its type"
1827 'ip_range_invalid' => [
'code' =>
'invalidrange',
'info' =>
'Invalid IP range' ],
1828 'range_block_disabled' => [
1829 'code' =>
'rangedisabled',
1830 'info' =>
'Blocking IP ranges has been disabled'
1832 'nosuchusershort' => [
1833 'code' =>
'nosuchuser',
1834 'info' =>
"The user you specified doesn't exist"
1836 'badipaddress' => [
'code' =>
'invalidip',
'info' =>
'Invalid IP address specified' ],
1837 'ipb_expiry_invalid' => [
'code' =>
'invalidexpiry',
'info' =>
'Invalid expiry time' ],
1838 'ipb_already_blocked' => [
1839 'code' =>
'alreadyblocked',
1840 'info' =>
'The user you tried to block was already blocked'
1842 'ipb_blocked_as_range' => [
1843 'code' =>
'blockedasrange',
1844 '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."
1846 'ipb_cant_unblock' => [
1847 'code' =>
'cantunblock',
1848 'info' =>
'The block you specified was not found. It may have been unblocked already'
1851 'code' =>
'cantsend',
1852 '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'
1855 'code' =>
'ipbblocked',
1856 'info' =>
'You cannot block or unblock users while you are yourself blocked'
1858 'ipbnounblockself' => [
1859 'code' =>
'ipbnounblockself',
1860 'info' =>
'You are not allowed to unblock yourself'
1862 'usermaildisabled' => [
1863 'code' =>
'usermaildisabled',
1864 'info' =>
'User email has been disabled'
1866 'blockedemailuser' => [
1867 'code' =>
'blockedfrommail',
1868 'info' =>
'You have been blocked from sending email'
1871 'code' =>
'notarget',
1872 'info' =>
'You have not specified a valid target for this action'
1875 'code' =>
'noemail',
1876 'info' =>
'The user has not specified a valid email address, or has chosen not to receive email from other users'
1878 'rcpatroldisabled' => [
1879 'code' =>
'patroldisabled',
1880 'info' =>
'Patrolling is disabled on this wiki'
1882 'markedaspatrollederror-noautopatrol' => [
1883 'code' =>
'noautopatrol',
1884 'info' =>
"You don't have permission to patrol your own changes"
1886 'delete-toobig' => [
1887 'code' =>
'bigdelete',
1888 'info' =>
"You can't delete this page because it has more than \$1 revisions"
1890 'movenotallowedfile' => [
1891 'code' =>
'cantmovefile',
1892 'info' =>
"You don't have permission to move files"
1894 'userrights-no-interwiki' => [
1895 'code' =>
'nointerwikiuserrights',
1896 'info' =>
"You don't have permission to change user rights on other wikis"
1898 'userrights-nodatabase' => [
1899 'code' =>
'nosuchdatabase',
1900 'info' =>
"Database \"\$1\" does not exist or is not local"
1902 'nouserspecified' => [
'code' =>
'invaliduser',
'info' =>
"Invalid username \"\$1\"" ],
1903 'noname' => [
'code' =>
'invaliduser',
'info' =>
"Invalid username \"\$1\"" ],
1904 'summaryrequired' => [
'code' =>
'summaryrequired',
'info' =>
'Summary required' ],
1905 'import-rootpage-invalid' => [
1906 'code' =>
'import-rootpage-invalid',
1907 'info' =>
'Root page is an invalid title'
1909 'import-rootpage-nosubpage' => [
1910 'code' =>
'import-rootpage-nosubpage',
1911 'info' =>
'Namespace "$1" of the root page does not allow subpages'
1916 'code' =>
'readapidenied',
1917 'info' =>
'You need read permission to use this module'
1919 'writedisabled' => [
1920 'code' =>
'noapiwrite',
1921 '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"
1923 'writerequired' => [
1924 'code' =>
'writeapidenied',
1925 'info' =>
"You're not allowed to edit this wiki through the API"
1927 'missingparam' => [
'code' =>
'no$1',
'info' =>
"The \$1 parameter must be set" ],
1928 'invalidtitle' => [
'code' =>
'invalidtitle',
'info' =>
"Bad title \"\$1\"" ],
1929 'nosuchpageid' => [
'code' =>
'nosuchpageid',
'info' =>
"There is no page with ID \$1" ],
1930 'nosuchrevid' => [
'code' =>
'nosuchrevid',
'info' =>
"There is no revision with ID \$1" ],
1931 'nosuchuser' => [
'code' =>
'nosuchuser',
'info' =>
"User \"\$1\" doesn't exist" ],
1932 'invaliduser' => [
'code' =>
'invaliduser',
'info' =>
"Invalid username \"\$1\"" ],
1933 'invalidexpiry' => [
'code' =>
'invalidexpiry',
'info' =>
"Invalid expiry time \"\$1\"" ],
1934 'pastexpiry' => [
'code' =>
'pastexpiry',
'info' =>
"Expiry time \"\$1\" is in the past" ],
1935 'create-titleexists' => [
1936 'code' =>
'create-titleexists',
1937 'info' =>
"Existing titles can't be protected with 'create'"
1939 'missingtitle-createonly' => [
1940 'code' =>
'missingtitle-createonly',
1941 'info' =>
"Missing titles can only be protected with 'create'"
1943 'cantblock' => [
'code' =>
'cantblock',
1944 'info' =>
"You don't have permission to block users"
1947 'code' =>
'canthide',
1948 'info' =>
"You don't have permission to hide user names from the block log"
1950 'cantblock-email' => [
1951 'code' =>
'cantblock-email',
1952 'info' =>
"You don't have permission to block users from sending email through the wiki"
1954 'unblock-notarget' => [
1955 'code' =>
'notarget',
1956 'info' =>
'Either the id or the user parameter must be set'
1958 'unblock-idanduser' => [
1959 'code' =>
'idanduser',
1960 'info' =>
"The id and user parameters can't be used together"
1963 'code' =>
'permissiondenied',
1964 'info' =>
"You don't have permission to unblock users"
1966 'cannotundelete' => [
1967 'code' =>
'cantundelete',
1968 'info' =>
"Couldn't undelete: the requested revisions may not exist, or may have been undeleted already"
1970 'permdenied-undelete' => [
1971 'code' =>
'permissiondenied',
1972 'info' =>
"You don't have permission to restore deleted revisions"
1974 'createonly-exists' => [
1975 'code' =>
'articleexists',
1976 'info' =>
'The article you tried to create has been created already'
1978 'nocreate-missing' => [
1979 'code' =>
'missingtitle',
1980 'info' =>
"The article you tried to edit doesn't exist"
1982 'cantchangecontentmodel' => [
1983 'code' =>
'cantchangecontentmodel',
1984 'info' =>
"You don't have permission to change the content model of a page"
1987 'code' =>
'nosuchrcid',
1988 'info' =>
"There is no change with rcid \"\$1\""
1991 'code' =>
'nosuchlogid',
1992 'info' =>
"There is no log entry with ID \"\$1\""
1994 'protect-invalidaction' => [
1995 'code' =>
'protect-invalidaction',
1996 'info' =>
"Invalid protection type \"\$1\""
1998 'protect-invalidlevel' => [
1999 'code' =>
'protect-invalidlevel',
2000 'info' =>
"Invalid protection level \"\$1\""
2002 'toofewexpiries' => [
2003 'code' =>
'toofewexpiries',
2004 'info' =>
"\$1 expiry timestamps were provided where \$2 were needed"
2007 'code' =>
'cantimport',
2008 'info' =>
"You don't have permission to import pages"
2010 'cantimport-upload' => [
2011 'code' =>
'cantimport-upload',
2012 'info' =>
"You don't have permission to import uploaded pages"
2014 'importnofile' => [
'code' =>
'nofile',
'info' =>
"You didn't upload a file" ],
2015 'importuploaderrorsize' => [
2016 'code' =>
'filetoobig',
2017 'info' =>
'The file you uploaded is bigger than the maximum upload size'
2019 'importuploaderrorpartial' => [
2020 'code' =>
'partialupload',
2021 'info' =>
'The file was only partially uploaded'
2023 'importuploaderrortemp' => [
2024 'code' =>
'notempdir',
2025 'info' =>
'The temporary upload directory is missing'
2027 'importcantopen' => [
2028 'code' =>
'cantopenfile',
2029 'info' =>
"Couldn't open the uploaded file"
2031 'import-noarticle' => [
2032 'code' =>
'badinterwiki',
2033 'info' =>
'Invalid interwiki title specified'
2035 'importbadinterwiki' => [
2036 'code' =>
'badinterwiki',
2037 'info' =>
'Invalid interwiki title specified'
2039 'import-unknownerror' => [
2040 'code' =>
'import-unknownerror',
2041 'info' =>
"Unknown error on import: \"\$1\""
2043 'cantoverwrite-sharedfile' => [
2044 'code' =>
'cantoverwrite-sharedfile',
2045 'info' =>
'The target file exists on a shared repository and you do not have permission to override it'
2047 'sharedfile-exists' => [
2048 'code' =>
'fileexists-sharedrepo-perm',
2049 'info' =>
'The target file exists on a shared repository. Use the ignorewarnings parameter to override it.'
2052 'code' =>
'mustbeposted',
2053 'info' =>
"The \$1 module requires a POST request"
2057 'info' =>
'Incorrect parameter - mutually exclusive values may not be supplied'
2059 'specialpage-cantexecute' => [
2060 'code' =>
'specialpage-cantexecute',
2061 'info' =>
"You don't have permission to view the results of this special page"
2063 'invalidoldimage' => [
2064 'code' =>
'invalidoldimage',
2065 'info' =>
'The oldimage parameter has invalid format'
2067 'nodeleteablefile' => [
2068 'code' =>
'nodeleteablefile',
2069 'info' =>
'No such old version of the file'
2071 'fileexists-forbidden' => [
2072 'code' =>
'fileexists-forbidden',
2073 'info' =>
'A file with name "$1" already exists, and cannot be overwritten.'
2075 'fileexists-shared-forbidden' => [
2076 'code' =>
'fileexists-shared-forbidden',
2077 'info' =>
'A file with name "$1" already exists in the shared file repository, and cannot be overwritten.'
2079 'filerevert-badversion' => [
2080 'code' =>
'filerevert-badversion',
2081 'info' =>
'There is no previous local version of this file with the provided timestamp.'
2085 'noimageredirect-anon' => [
2086 'code' =>
'noimageredirect-anon',
2087 'info' =>
"Anonymous users can't create image redirects"
2089 'noimageredirect-logged' => [
2090 'code' =>
'noimageredirect',
2091 'info' =>
"You don't have permission to create image redirects"
2094 'code' =>
'spamdetected',
2095 'info' =>
"Your edit was refused because it contained a spam fragment: \"\$1\""
2097 'contenttoobig' => [
2098 'code' =>
'contenttoobig',
2099 'info' =>
"The content you supplied exceeds the article size limit of \$1 kilobytes"
2101 'noedit-anon' => [
'code' =>
'noedit-anon',
'info' =>
"Anonymous users can't edit pages" ],
2102 'noedit' => [
'code' =>
'noedit',
'info' =>
"You don't have permission to edit pages" ],
2104 'code' =>
'pagedeleted',
2105 'info' =>
'The page has been deleted since you fetched its timestamp'
2108 'code' =>
'emptypage',
2109 'info' =>
'Creating new, empty pages is not allowed'
2111 'editconflict' => [
'code' =>
'editconflict',
'info' =>
'Edit conflict detected' ],
2112 'hashcheckfailed' => [
'code' =>
'badmd5',
'info' =>
'The supplied MD5 hash was incorrect' ],
2115 'info' =>
'One of the text, appendtext, prependtext and undo parameters must be set'
2117 'emptynewsection' => [
2118 'code' =>
'emptynewsection',
2119 'info' =>
'Creating empty new sections is not possible.'
2122 'code' =>
'revwrongpage',
2123 'info' =>
"r\$1 is not a revision of \"\$2\""
2126 'code' =>
'undofailure',
2127 'info' =>
'Undo failed due to conflicting intermediate edits'
2129 'content-not-allowed-here' => [
2130 'code' =>
'contentnotallowedhere',
2131 'info' =>
'Content model "$1" is not allowed at title "$2"'
2135 'edit-hook-aborted' => [
2136 'code' =>
'edit-hook-aborted',
2137 'info' =>
'Your edit was aborted by an ArticleSave hook'
2139 'edit-gone-missing' => [
2140 'code' =>
'edit-gone-missing',
2141 'info' =>
"The page you tried to edit doesn't seem to exist anymore"
2143 'edit-conflict' => [
'code' =>
'editconflict',
'info' =>
'Edit conflict detected' ],
2144 'edit-already-exists' => [
2145 'code' =>
'edit-already-exists',
2146 'info' =>
'It seems the page you tried to create already exist'
2150 'invalid-file-key' => [
'code' =>
'invalid-file-key',
'info' =>
'Not a valid file key' ],
2151 'nouploadmodule' => [
'code' =>
'nouploadmodule',
'info' =>
'No upload module set' ],
2152 'uploaddisabled' => [
2153 'code' =>
'uploaddisabled',
2154 'info' =>
'Uploads are not enabled. Make sure $wgEnableUploads is set to true in LocalSettings.php and the PHP ini setting file_uploads is true'
2156 'copyuploaddisabled' => [
2157 'code' =>
'copyuploaddisabled',
2158 'info' =>
'Uploads by URL is not enabled. Make sure $wgAllowCopyUploads is set to true in LocalSettings.php.'
2160 'copyuploadbaddomain' => [
2161 'code' =>
'copyuploadbaddomain',
2162 'info' =>
'Uploads by URL are not allowed from this domain.'
2164 'copyuploadbadurl' => [
2165 'code' =>
'copyuploadbadurl',
2166 'info' =>
'Upload not allowed from this URL.'
2169 'filename-tooshort' => [
2170 'code' =>
'filename-tooshort',
2171 'info' =>
'The filename is too short'
2173 'filename-toolong' => [
'code' =>
'filename-toolong',
'info' =>
'The filename is too long' ],
2174 'illegal-filename' => [
2175 'code' =>
'illegal-filename',
2176 'info' =>
'The filename is not allowed'
2178 'filetype-missing' => [
2179 'code' =>
'filetype-missing',
2180 'info' =>
'The file is missing an extension'
2183 'mustbeloggedin' => [
'code' =>
'mustbeloggedin',
'info' =>
'You must be logged in to $1.' ]
2193 $parsed = $this->
parseMsg( [
'readonlytext' ] );
2194 $this->
dieUsage( $parsed[
'info'], $parsed[
'code'], 0,
2204 # most of the time we send a 1 element, so we might as well send it as
2205 # a string and make this an array here.
2206 if ( is_string( $error ) ) {
2207 $error = [ $error ];
2209 $parsed = $this->
parseMsg( $error );
2210 $extraData = isset( $parsed[
'data'] ) ? $parsed[
'data'] :
null;
2211 $this->
dieUsage( $parsed[
'info'], $parsed[
'code'], 0, $extraData );
2222 if ( $this->
getConfig()->
get(
'DebugAPI' ) !==
true ) {
2226 if ( is_string( $error ) ) {
2227 $error = [ $error ];
2229 $parsed = $this->
parseMsg( $error );
2230 $this->
setWarning(
'$wgDebugAPI: ' . $parsed[
'code'] .
' - ' . $parsed[
'info'] );
2243 'Invalid continue param. You should pass the original value returned by the previous query',
2258 if ( is_array( $error ) ) {
2259 $first = reset( $error );
2260 if ( is_array( $first ) ) {
2266 $msg = Message::newFromSpecifier( $error );
2270 'code' => $msg->getApiCode(),
2271 'info' => $msg->inLanguage(
'en' )->useDatabase(
false )->text(),
2272 'data' => $msg->getApiData()
2276 $key = $msg->getKey();
2277 if ( isset( self::$messageMap[$key] ) ) {
2286 return $this->
parseMsg( [
'unknownerror', $key ] );
2295 protected static function dieDebug( $method, $message ) {
2296 throw new MWException(
"Internal error in $method: $message" );
2306 $s =
'"' . addslashes( $feature ) .
'"' .
2309 ' "' . addslashes(
$request->getHeader(
'Referer' ) ) .
'"' .
2310 ' "' . addslashes( $this->
getMain()->getUserAgent() ) .
'"';
2327 return "apihelp-{$this->getModulePath()}-description";
2339 Hooks::run(
'APIGetDescription', [ &$this, &$desc ] );
2341 if ( is_array( $desc ) ) {
2342 $desc = implode(
"\n", $desc );
2352 if ( !$msg->exists() ) {
2353 $msg = $this->
msg(
'api-help-fallback-description', $desc );
2357 Hooks::run(
'APIGetDescriptionMessages', [ $this, &$msgs ] );
2382 'api-help-param-token',
2388 Hooks::run(
'APIGetAllowedParams', [ &$this, &
$params,
$flags ] );
2406 Hooks::run(
'APIGetParamDescription', [ &$this, &$desc ] );
2415 foreach (
$params as $param => $settings ) {
2416 if ( !is_array( $settings ) ) {
2420 $d = isset( $desc[$param] ) ? $desc[$param] :
'';
2421 if ( is_array( $d ) ) {
2423 $d = array_map(
function (
$line ) {
2424 if ( preg_match(
'/^\s+(\S+)\s+-\s+(.+)$/',
$line, $m ) ) {
2425 $line =
"\n;{$m[1]}:{$m[2]}";
2429 $d = implode(
' ', $d );
2435 $msg = $this->
msg(
"apihelp-{$path}-param-{$param}" );
2436 if ( !$msg->exists() ) {
2437 $msg = $this->
msg(
'api-help-fallback-parameter', $d );
2444 'Value in ApiBase::PARAM_HELP_MSG is not valid' );
2446 $msgs[$param] = [ $msg ];
2451 'ApiBase::PARAM_HELP_MSG_PER_VALUE is not valid' );
2455 'ApiBase::PARAM_HELP_MSG_PER_VALUE may only be used when ' .
2456 'ApiBase::PARAM_TYPE is an array' );
2461 if ( isset( $valueMsgs[
$value] ) ) {
2462 $msg = $valueMsgs[
$value];
2464 $msg =
"apihelp-{$path}-paramvalue-{$param}-{$value}";
2471 [ $m->getKey(),
'api-help-param-no-description' ],
2474 $msgs[$param][] = $m->setContext( $this->
getContext() );
2477 "Value in ApiBase::PARAM_HELP_MSG_PER_VALUE for $value is not valid" );
2485 'Value for ApiBase::PARAM_HELP_MSG_APPEND is not an array' );
2491 $msgs[$param][] = $m;
2494 'Value in ApiBase::PARAM_HELP_MSG_APPEND is not valid' );
2500 Hooks::run(
'APIGetParamDescriptionMessages', [ $this, &$msgs ] );
2527 $flags[] =
'writerights';
2530 $flags[] =
'mustbeposted';
2550 if ( $this->mModuleSource !==
false ) {
2555 $rClass =
new ReflectionClass( $this );
2556 $path = $rClass->getFileName();
2559 $this->mModuleSource =
null;
2565 if ( self::$extensionInfo ===
null ) {
2566 $extDir = $this->
getConfig()->get(
'ExtensionDirectory' );
2567 self::$extensionInfo = [
2568 realpath( __DIR__ ) ?: __DIR__ => [
2570 'name' =>
'MediaWiki',
2571 'license-name' =>
'GPL-2.0+',
2573 realpath(
"$IP/extensions" ) ?:
"$IP/extensions" =>
null,
2574 realpath( $extDir ) ?: $extDir =>
null,
2580 'license-name' =>
null,
2582 foreach ( $this->
getConfig()->
get(
'ExtensionCredits' )
as $group ) {
2583 foreach ( $group
as $ext ) {
2584 if ( !isset(
$ext[
'path'] ) || !isset(
$ext[
'name'] ) ) {
2589 $extpath =
$ext[
'path'];
2590 if ( !is_dir( $extpath ) ) {
2591 $extpath = dirname( $extpath );
2593 self::$extensionInfo[realpath( $extpath ) ?: $extpath] =
2594 array_intersect_key(
$ext, $keep );
2598 $extpath =
$ext[
'path'];
2599 if ( !is_dir( $extpath ) ) {
2600 $extpath = dirname( $extpath );
2602 self::$extensionInfo[realpath( $extpath ) ?: $extpath] =
2603 array_intersect_key(
$ext, $keep );
2610 if ( array_key_exists(
$path, self::$extensionInfo ) ) {
2612 $this->mModuleSource = self::$extensionInfo[
$path];
2618 }
while (
$path !== $oldpath );
2621 $this->mModuleSource =
null;
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
wfGetAllCallers( $limit=3)
Return a string consisting of callers in the stack.
wfTransactionalTimeLimit()
Set PHP's time limit to the larger of php.ini or $wgTransactionalTimeLimit.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfMsgReplaceArgs( $message, $args)
Replace message parameter keys on the given formatted output.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
This abstract class implements many basic API functions, and is the base of all API classes.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
const PARAM_REQUIRED
(boolean) Is the parameter required?
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
const PARAM_SUBMODULE_MAP
(string[]) When PARAM_TYPE is 'submodule', map parameter values to submodule paths.
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
getModuleFromPath( $path)
Get a module from its module path.
getDB()
Gets a default replica DB connection object.
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
parameterNotEmpty( $x)
Callback function used in requireOnlyOneParameter to check whether required parameters are set.
static makeMessage( $msg, IContextSource $context, array $params=null)
Create a Message from a string or array.
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
getWatchlistUser( $params)
Gets the user for whom to get the watchlist.
getParamDescription()
Returns an array of parameter descriptions.
isDeprecated()
Indicates whether this module is deprecated.
dieContinueUsageIf( $condition)
Die with the $prefix.
array null bool $mModuleSource
getParent()
Get the parent of this module.
validateUser( $value, $encParamName)
Validate and normalize of parameters of type 'user'.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
getHelpUrls()
Return links to more detailed help pages about the module.
getErrorFromStatus( $status, &$extraData=null)
Get error (as code, string) from a Status object.
getModuleManager()
Get the module manager, or null if this module has no sub-modules.
getMain()
Get the main module.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getCustomPrinter()
If the module may only be used with a certain format module, it should override this method to return...
setWatch( $watch, $titleObj, $userOption=null)
Set a watch (or unwatch) based the based on a watchlist parameter.
const PARAM_SENSITIVE
(boolean) Is the parameter sensitive? Note 'password'-type fields are always sensitive regardless of ...
warnOrDie( $msg, $enforceLimits=false)
Adds a warning to the output, else dies.
parseMsg( $error)
Return the error message related to a certain array.
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
getErrorFormatter()
Get the error formatter.
isWriteMode()
Indicates whether this module requires write mode.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
isInternal()
Indicates whether this module is "internal" Internal API modules are not (yet) intended for 3rd party...
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...
getDescription()
Returns the description string for this module.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
dieReadOnly()
Helper function for readonly errors.
const PARAM_ALLOW_DUPLICATES
(boolean) Allow the same value to be set more than once when PARAM_ISMULTI is true?
modifyHelp(array &$help, array $options, array &$tocData)
Called from ApiHelp before the pieces are joined together and returned.
const PARAM_VALUE_LINKS
(string[]) When PARAM_TYPE is an array, this may be an array mapping those values to page titles whic...
__construct(ApiMain $mainModule, $moduleName, $modulePrefix='')
setContinuationManager( $manager)
Set the continuation manager.
getExamplesMessages()
Returns usage examples for this module.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
dieUsageMsg( $error)
Output the error message related to a certain array.
setWarning( $warning)
Set warning section for this module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getModuleSourceInfo()
Returns information about the source of this module, if known.
const PARAM_SUBMODULE_PARAM_PREFIX
(string) When PARAM_TYPE is 'submodule', used to indicate the 'g' prefix added by ApiQueryGeneratorBa...
static escapeWikiText( $v)
A subset of wfEscapeWikiText for BC texts.
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
mustBePosted()
Indicates whether this module must be called with a POST request.
getWebUITokenSalt(array $params)
Fetch the salt used in the Web UI corresponding to this module.
static array $extensionInfo
Maps extension paths to info arrays.
const LIMIT_BIG1
Fast query, standard limit.
isMain()
Returns true if this module is the main module ($this === $this->mMainModule), false otherwise.
const LIMIT_SML2
Slow query, apihighlimits limit.
handleParamNormalization( $paramName, $value, $rawValue)
Handle when a parameter was Unicode-normalized.
validateLimit( $paramName, &$value, $min, $max, $botMax=null, $enforceLimits=false)
Validate the value against the minimum and user/bot maximum limits.
getFinalDescription()
Get final module description, after hooks have had a chance to tweak it as needed.
static truncateArray(&$arr, $limit)
Truncate an array to a certain length.
getResult()
Get the result object.
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
needsToken()
Returns the token type this module requires in order to execute.
getDescriptionMessage()
Return the description message.
getParameterFromSettings( $paramName, $paramSettings, $parseLimit)
Using the settings determine the value for the given parameter.
getModulePath()
Get the path to this module.
const PARAM_RANGE_ENFORCE
(boolean) For PARAM_TYPE 'integer', enforce PARAM_MIN and PARAM_MAX?
logFeatureUsage( $feature)
Write logging information for API features to a debug log, for usage analysis.
shouldCheckMaxlag()
Indicates if this module needs maxlag to be checked.
getHelpFlags()
Generates the list of flags for the help screen and for action=paraminfo.
const LIMIT_SML1
Slow query, standard limit.
dieUsageMsgOrDebug( $error)
Will only set a warning instead of failing if the global $wgDebugAPI is set to true.
getFinalParams( $flags=0)
Get final list of parameters, after hooks have had a chance to tweak it as needed.
getWatchlistValue( $watchlist, $titleObj, $userOption=null)
Return true if we're to watch the page, false if not, null if no change.
static $messageMap
Array that maps message keys to error messages.
isReadMode()
Indicates whether this module requires read rights.
getExamples()
Returns usage examples for this module.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
requireAtLeastOneParameter( $params, $required)
Die if none of a certain set of parameters is set and not false.
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
validateTimestamp( $value, $encParamName)
Validate and normalize of parameters of type 'timestamp'.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
dieStatus( $status)
Throw a UsageException based on the errors in the Status object.
getFinalParamDescription()
Get final parameter descriptions, after hooks have had a chance to tweak it as needed.
dieBlocked(Block $block)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
dynamicParameterDocumentation()
Indicate if the module supports dynamically-determined parameters that cannot be included in self::ge...
getModuleProfileName( $db=false)
getContinuationManager()
Get the continuation manager.
explodeMultiValue( $value, $limit)
Split a multi-valued parameter string, like explode()
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
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...
validateToken( $token, array $params)
Validate the supplied token.
getConditionalRequestData( $condition)
Returns data for HTTP conditional request mechanisms.
requireOnlyOneParameter( $params, $required)
Die if none or more than one 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.
lacksSameOriginSecurity()
Returns true if the current request breaks the same-origin policy.
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...
Message subclass that prepends wikitext for API help.
This is the main API class, used for both external and internal processing.
static getTokenTypeSalts()
Get the salts for known token types.
static getToken(User $user, MediaWiki\Session\Session $session, $salt)
Get a token from a salt.
static getBlockInfo(Block $block)
Get basic info about a given block.
Extension of RawMessage implementing IApiMessage.
getType()
Get the type of target for this particular block.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
getUser()
Get the User object.
getRequest()
Get the WebRequest object.
getConfig()
Get the Config object.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
Set the IContextSource object.
The Message class provides methods which fulfil two basic services:
This exception will be thrown when dieUsage is called to stop module execution.
static doWatchOrUnwatch( $watch, Title $title, User $user)
Watch or unwatch a page.
static newFromID( $id, $from='fromdb')
Constructor from a page id.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
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
when a variable name is used in a it is silently declared as a new local masking the global
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 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
the array() calling protocol came about after MediaWiki 1.4rc1.
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
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' 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
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
namespace and then decline to actually register it file or subcat img or subcat $title
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
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 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
it s the revision text itself In either if gzip is the revision text is gzipped $flags
error also a ContextSource you ll probably need to make sure the header is varied on $request
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
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
Allows to change the fields on the form that will be generated $name
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
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
Interface for messages with machine-readable data for use by the API.
Interface for objects which can provide a MediaWiki context on request.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)