MediaWiki  master
ApiBase.php
Go to the documentation of this file.
1 <?php
37 
52 abstract class ApiBase extends ContextSource {
53 
55 
57  private $hookContainer;
58 
60  private $hookRunner;
61 
68  public const PARAM_DFLT = ParamValidator::PARAM_DEFAULT;
69  public const PARAM_ISMULTI = ParamValidator::PARAM_ISMULTI;
70  public const PARAM_TYPE = ParamValidator::PARAM_TYPE;
71  public const PARAM_MAX = IntegerDef::PARAM_MAX;
72  public const PARAM_MAX2 = IntegerDef::PARAM_MAX2;
73  public const PARAM_MIN = IntegerDef::PARAM_MIN;
74  public const PARAM_ALLOW_DUPLICATES = ParamValidator::PARAM_ALLOW_DUPLICATES;
75  public const PARAM_DEPRECATED = ParamValidator::PARAM_DEPRECATED;
76  public const PARAM_REQUIRED = ParamValidator::PARAM_REQUIRED;
77  public const PARAM_SUBMODULE_MAP = SubmoduleDef::PARAM_SUBMODULE_MAP;
78  public const PARAM_SUBMODULE_PARAM_PREFIX = SubmoduleDef::PARAM_SUBMODULE_PARAM_PREFIX;
79  public const PARAM_ALL = ParamValidator::PARAM_ALL;
80  public const PARAM_EXTRA_NAMESPACES = NamespaceDef::PARAM_EXTRA_NAMESPACES;
81  public const PARAM_SENSITIVE = ParamValidator::PARAM_SENSITIVE;
82  public const PARAM_DEPRECATED_VALUES = EnumDef::PARAM_DEPRECATED_VALUES;
83  public const PARAM_ISMULTI_LIMIT1 = ParamValidator::PARAM_ISMULTI_LIMIT1;
84  public const PARAM_ISMULTI_LIMIT2 = ParamValidator::PARAM_ISMULTI_LIMIT2;
85  public const PARAM_MAX_BYTES = StringDef::PARAM_MAX_BYTES;
86  public const PARAM_MAX_CHARS = StringDef::PARAM_MAX_CHARS;
87 
92  public const PARAM_RANGE_ENFORCE = 'api-param-range-enforce';
93 
106  public const PARAM_HELP_MSG = 'api-param-help-msg';
107 
113  public const PARAM_HELP_MSG_APPEND = 'api-param-help-msg-append';
114 
123  public const PARAM_HELP_MSG_INFO = 'api-param-help-msg-info';
124 
130  public const PARAM_VALUE_LINKS = 'api-param-value-links';
131 
139  public const PARAM_HELP_MSG_PER_VALUE = 'api-param-help-msg-per-value';
140 
157  public const PARAM_TEMPLATE_VARS = 'param-template-vars';
158 
161  public const ALL_DEFAULT_STRING = '*';
162 
164  public const LIMIT_BIG1 = 500;
166  public const LIMIT_BIG2 = 5000;
168  public const LIMIT_SML1 = 50;
170  public const LIMIT_SML2 = 500;
171 
177  public const GET_VALUES_FOR_HELP = 1;
178 
180  private static $extensionInfo = null;
181 
183  private static $filterIDsCache = [];
184 
186  private static $blockMsgMap = [
187  'blockedtext' => [ 'apierror-blocked', 'blocked' ],
188  'blockedtext-partial' => [ 'apierror-blocked-partial', 'blocked' ],
189  'autoblockedtext' => [ 'apierror-autoblocked', 'autoblocked' ],
190  'systemblockedtext' => [ 'apierror-systemblocked', 'blocked' ],
191  'blockedtext-composite' => [ 'apierror-blocked', 'blocked' ],
192  ];
193 
195  private $mMainModule;
198  private $mReplicaDB = null;
202  private $mParamCache = [];
204  private $mModuleSource = false;
205 
212  public function __construct( ApiMain $mainModule, $moduleName, $modulePrefix = '' ) {
213  $this->mMainModule = $mainModule;
214  $this->mModuleName = $moduleName;
215  $this->mModulePrefix = $modulePrefix;
216 
217  if ( !$this->isMain() ) {
218  $this->setContext( $mainModule->getContext() );
219  }
220  }
221 
222  /************************************************************************/
243  abstract public function execute();
244 
251  public function getModuleManager() {
252  return null;
253  }
254 
265  public function getCustomPrinter() {
266  return null;
267  }
268 
281  protected function getExamplesMessages() {
282  return [];
283  }
284 
291  public function getHelpUrls() {
292  return [];
293  }
294 
308  protected function getAllowedParams( /* $flags = 0 */ ) {
309  // int $flags is not declared because it causes "Strict standards"
310  // warning. Most derived classes do not implement it.
311  return [];
312  }
313 
319  public function shouldCheckMaxlag() {
320  return true;
321  }
322 
328  public function isReadMode() {
329  return true;
330  }
331 
344  public function isWriteMode() {
345  return false;
346  }
347 
353  public function mustBePosted() {
354  return $this->needsToken() !== false;
355  }
356 
363  public function isDeprecated() {
364  return false;
365  }
366 
374  public function isInternal() {
375  return false;
376  }
377 
397  public function needsToken() {
398  return false;
399  }
400 
411  protected function getWebUITokenSalt( array $params ) {
412  return null;
413  }
414 
428  public function getConditionalRequestData( $condition ) {
429  return null;
430  }
431 
434  /************************************************************************/
443  public function getModuleName() {
444  return $this->mModuleName;
445  }
446 
451  public function getModulePrefix() {
452  return $this->mModulePrefix;
453  }
454 
459  public function getMain() {
460  return $this->mMainModule;
461  }
462 
468  public function isMain() {
469  return $this === $this->mMainModule;
470  }
471 
478  public function getParent() {
479  return $this->isMain() ? null : $this->getMain();
480  }
481 
492  public function lacksSameOriginSecurity() {
493  // Main module has this method overridden
494  // Safety - avoid infinite loop:
495  if ( $this->isMain() ) {
496  self::dieDebug( __METHOD__, 'base method was called on main module.' );
497  }
498 
499  return $this->getMain()->lacksSameOriginSecurity();
500  }
501 
508  public function getModulePath() {
509  if ( $this->isMain() ) {
510  return 'main';
511  } elseif ( $this->getParent()->isMain() ) {
512  return $this->getModuleName();
513  } else {
514  return $this->getParent()->getModulePath() . '+' . $this->getModuleName();
515  }
516  }
517 
526  public function getModuleFromPath( $path ) {
527  $module = $this->getMain();
528  if ( $path === 'main' ) {
529  return $module;
530  }
531 
532  $parts = explode( '+', $path );
533  if ( count( $parts ) === 1 ) {
534  // In case the '+' was typed into URL, it resolves as a space
535  $parts = explode( ' ', $path );
536  }
537 
538  $count = count( $parts );
539  for ( $i = 0; $i < $count; $i++ ) {
540  $parent = $module;
541  $manager = $parent->getModuleManager();
542  if ( $manager === null ) {
543  $errorPath = implode( '+', array_slice( $parts, 0, $i ) );
544  $this->dieWithError( [ 'apierror-badmodule-nosubmodules', $errorPath ], 'badmodule' );
545  }
546  $module = $manager->getModule( $parts[$i] );
547 
548  if ( $module === null ) {
549  $errorPath = $i ? implode( '+', array_slice( $parts, 0, $i ) ) : $parent->getModuleName();
550  $this->dieWithError(
551  [ 'apierror-badmodule-badsubmodule', $errorPath, wfEscapeWikiText( $parts[$i] ) ],
552  'badmodule'
553  );
554  }
555  }
556 
557  return $module;
558  }
559 
564  public function getResult() {
565  // Main module has getResult() method overridden
566  // Safety - avoid infinite loop:
567  if ( $this->isMain() ) {
568  self::dieDebug( __METHOD__, 'base method was called on main module. ' );
569  }
570 
571  return $this->getMain()->getResult();
572  }
573 
579  public function getErrorFormatter() {
580  // Main module has getErrorFormatter() method overridden
581  // Safety - avoid infinite loop:
582  if ( $this->isMain() ) {
583  self::dieDebug( __METHOD__, 'base method was called on main module. ' );
584  }
585 
586  return $this->getMain()->getErrorFormatter();
587  }
588 
594  protected function getDB() {
595  if ( !isset( $this->mReplicaDB ) ) {
596  $this->mReplicaDB = wfGetDB( DB_REPLICA, 'api' );
597  }
598 
599  return $this->mReplicaDB;
600  }
601 
606  public function getContinuationManager() {
607  // Main module has getContinuationManager() method overridden
608  // Safety - avoid infinite loop:
609  if ( $this->isMain() ) {
610  self::dieDebug( __METHOD__, 'base method was called on main module. ' );
611  }
612 
613  return $this->getMain()->getContinuationManager();
614  }
615 
620  public function setContinuationManager( ApiContinuationManager $manager = null ) {
621  // Main module has setContinuationManager() method overridden
622  // Safety - avoid infinite loop:
623  if ( $this->isMain() ) {
624  self::dieDebug( __METHOD__, 'base method was called on main module. ' );
625  }
626 
627  $this->getMain()->setContinuationManager( $manager );
628  }
629 
636  protected function getPermissionManager(): PermissionManager {
637  return MediaWikiServices::getInstance()->getPermissionManager();
638  }
639 
646  protected function getHookContainer() {
647  if ( !$this->hookContainer ) {
648  $this->hookContainer = MediaWikiServices::getInstance()->getHookContainer();
649  }
650  return $this->hookContainer;
651  }
652 
661  protected function getHookRunner() {
662  if ( !$this->hookRunner ) {
663  $this->hookRunner = new ApiHookRunner( $this->getHookContainer() );
664  }
665  return $this->hookRunner;
666  }
667 
670  /************************************************************************/
683  public function dynamicParameterDocumentation() {
684  return null;
685  }
686 
694  public function encodeParamName( $paramName ) {
695  if ( is_array( $paramName ) ) {
696  return array_map( function ( $name ) {
697  return $this->mModulePrefix . $name;
698  }, $paramName );
699  } else {
700  return $this->mModulePrefix . $paramName;
701  }
702  }
703 
716  public function extractRequestParams( $options = [] ) {
717  if ( is_bool( $options ) ) {
718  $options = [ 'parseLimit' => $options ];
719  }
720  $options += [
721  'parseLimit' => true,
722  'safeMode' => false,
723  ];
724 
725  $parseLimit = (bool)$options['parseLimit'];
726  $cacheKey = (int)$parseLimit;
727 
728  // Cache parameters, for performance and to avoid T26564.
729  if ( !isset( $this->mParamCache[$cacheKey] ) ) {
730  $params = $this->getFinalParams() ?: [];
731  $results = [];
732  $warned = [];
733 
734  // Process all non-templates and save templates for secondary
735  // processing.
736  $toProcess = [];
737  foreach ( $params as $paramName => $paramSettings ) {
738  if ( isset( $paramSettings[self::PARAM_TEMPLATE_VARS] ) ) {
739  $toProcess[] = [ $paramName, $paramSettings[self::PARAM_TEMPLATE_VARS], $paramSettings ];
740  } else {
741  try {
742  $results[$paramName] = $this->getParameterFromSettings(
743  $paramName, $paramSettings, $parseLimit
744  );
745  } catch ( ApiUsageException $ex ) {
746  $results[$paramName] = $ex;
747  }
748  }
749  }
750 
751  // Now process all the templates by successively replacing the
752  // placeholders with all client-supplied values.
753  // This bit duplicates JavaScript logic in
754  // ApiSandbox.PageLayout.prototype.updateTemplatedParams().
755  // If you update this, see if that needs updating too.
756  while ( $toProcess ) {
757  list( $name, $targets, $settings ) = array_shift( $toProcess );
758 
759  foreach ( $targets as $placeholder => $target ) {
760  if ( !array_key_exists( $target, $results ) ) {
761  // The target wasn't processed yet, try the next one.
762  // If all hit this case, the parameter has no expansions.
763  continue;
764  }
765  if ( !is_array( $results[$target] ) || !$results[$target] ) {
766  // The target was processed but has no (valid) values.
767  // That means it has no expansions.
768  break;
769  }
770 
771  // Expand this target in the name and all other targets,
772  // then requeue if there are more targets left or put in
773  // $results if all are done.
774  unset( $targets[$placeholder] );
775  $placeholder = '{' . $placeholder . '}';
776  // @phan-suppress-next-line PhanTypeNoAccessiblePropertiesForeach
777  foreach ( $results[$target] as $value ) {
778  if ( !preg_match( '/^[^{}]*$/', $value ) ) {
779  // Skip values that make invalid parameter names.
780  $encTargetName = $this->encodeParamName( $target );
781  if ( !isset( $warned[$encTargetName][$value] ) ) {
782  $warned[$encTargetName][$value] = true;
783  $this->addWarning( [
784  'apiwarn-ignoring-invalid-templated-value',
785  wfEscapeWikiText( $encTargetName ),
786  wfEscapeWikiText( $value ),
787  ] );
788  }
789  continue;
790  }
791 
792  $newName = str_replace( $placeholder, $value, $name );
793  if ( !$targets ) {
794  try {
795  $results[$newName] = $this->getParameterFromSettings(
796  $newName,
797  $settings,
798  $parseLimit
799  );
800  } catch ( ApiUsageException $ex ) {
801  $results[$newName] = $ex;
802  }
803  } else {
804  $newTargets = [];
805  foreach ( $targets as $k => $v ) {
806  $newTargets[$k] = str_replace( $placeholder, $value, $v );
807  }
808  $toProcess[] = [ $newName, $newTargets, $settings ];
809  }
810  }
811  break;
812  }
813  }
814 
815  $this->mParamCache[$cacheKey] = $results;
816  }
817 
818  $ret = $this->mParamCache[$cacheKey];
819  if ( !$options['safeMode'] ) {
820  foreach ( $ret as $v ) {
821  if ( $v instanceof ApiUsageException ) {
822  throw $v;
823  }
824  }
825  }
826 
827  return $this->mParamCache[$cacheKey];
828  }
829 
836  protected function getParameter( $paramName, $parseLimit = true ) {
837  $ret = $this->extractRequestParams( [
838  'parseLimit' => $parseLimit,
839  'safeMode' => true,
840  ] )[$paramName];
841  if ( $ret instanceof ApiUsageException ) {
842  throw $ret;
843  }
844  return $ret;
845  }
846 
853  public function requireOnlyOneParameter( $params, ...$required ) {
854  $intersection = array_intersect( array_keys( array_filter( $params,
855  [ $this, 'parameterNotEmpty' ] ) ), $required );
856 
857  if ( count( $intersection ) > 1 ) {
858  $this->dieWithError( [
859  'apierror-invalidparammix',
860  Message::listParam( array_map(
861  function ( $p ) {
862  return '<var>' . $this->encodeParamName( $p ) . '</var>';
863  },
864  array_values( $intersection )
865  ) ),
866  count( $intersection ),
867  ] );
868  } elseif ( count( $intersection ) == 0 ) {
869  $this->dieWithError( [
870  'apierror-missingparam-one-of',
871  Message::listParam( array_map(
872  function ( $p ) {
873  return '<var>' . $this->encodeParamName( $p ) . '</var>';
874  },
875  $required
876  ) ),
877  count( $required ),
878  ], 'missingparam' );
879  }
880  }
881 
888  public function requireMaxOneParameter( $params, ...$required ) {
889  $intersection = array_intersect( array_keys( array_filter( $params,
890  [ $this, 'parameterNotEmpty' ] ) ), $required );
891 
892  if ( count( $intersection ) > 1 ) {
893  $this->dieWithError( [
894  'apierror-invalidparammix',
895  Message::listParam( array_map(
896  function ( $p ) {
897  return '<var>' . $this->encodeParamName( $p ) . '</var>';
898  },
899  array_values( $intersection )
900  ) ),
901  count( $intersection ),
902  ] );
903  }
904  }
905 
913  public function requireAtLeastOneParameter( $params, ...$required ) {
914  $intersection = array_intersect(
915  array_keys( array_filter( $params, [ $this, 'parameterNotEmpty' ] ) ),
916  $required
917  );
918 
919  if ( count( $intersection ) == 0 ) {
920  $this->dieWithError( [
921  'apierror-missingparam-at-least-one-of',
922  Message::listParam( array_map(
923  function ( $p ) {
924  return '<var>' . $this->encodeParamName( $p ) . '</var>';
925  },
926  $required
927  ) ),
928  count( $required ),
929  ], 'missingparam' );
930  }
931  }
932 
940  public function requirePostedParameters( $params, $prefix = 'prefix' ) {
941  // Skip if $wgDebugAPI is set or we're in internal mode
942  if ( $this->getConfig()->get( 'DebugAPI' ) || $this->getMain()->isInternalMode() ) {
943  return;
944  }
945 
946  $queryValues = $this->getRequest()->getQueryValuesOnly();
947  $badParams = [];
948  foreach ( $params as $param ) {
949  if ( $prefix !== 'noprefix' ) {
950  $param = $this->encodeParamName( $param );
951  }
952  if ( array_key_exists( $param, $queryValues ) ) {
953  $badParams[] = $param;
954  }
955  }
956 
957  if ( $badParams ) {
958  $this->dieWithError(
959  [ 'apierror-mustpostparams', implode( ', ', $badParams ), count( $badParams ) ]
960  );
961  }
962  }
963 
970  private function parameterNotEmpty( $x ) {
971  return $x !== null && $x !== false;
972  }
973 
985  public function getTitleOrPageId( $params, $load = false ) {
986  $this->requireOnlyOneParameter( $params, 'title', 'pageid' );
987 
988  $pageObj = null;
989  if ( isset( $params['title'] ) ) {
990  $titleObj = Title::newFromText( $params['title'] );
991  if ( !$titleObj || $titleObj->isExternal() ) {
992  $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['title'] ) ] );
993  }
994  if ( !$titleObj->canExist() ) {
995  $this->dieWithError( 'apierror-pagecannotexist' );
996  }
997  $pageObj = WikiPage::factory( $titleObj );
998  if ( $load !== false ) {
999  $pageObj->loadPageData( $load );
1000  }
1001  } elseif ( isset( $params['pageid'] ) ) {
1002  if ( $load === false ) {
1003  $load = 'fromdb';
1004  }
1005  $pageObj = WikiPage::newFromID( $params['pageid'], $load );
1006  if ( !$pageObj ) {
1007  $this->dieWithError( [ 'apierror-nosuchpageid', $params['pageid'] ] );
1008  }
1009  }
1010 
1011  return $pageObj;
1012  }
1013 
1022  public function getTitleFromTitleOrPageId( $params ) {
1023  $this->requireOnlyOneParameter( $params, 'title', 'pageid' );
1024 
1025  $titleObj = null;
1026  if ( isset( $params['title'] ) ) {
1027  $titleObj = Title::newFromText( $params['title'] );
1028  if ( !$titleObj || $titleObj->isExternal() ) {
1029  $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['title'] ) ] );
1030  }
1031  return $titleObj;
1032  } elseif ( isset( $params['pageid'] ) ) {
1033  $titleObj = Title::newFromID( $params['pageid'] );
1034  if ( !$titleObj ) {
1035  $this->dieWithError( [ 'apierror-nosuchpageid', $params['pageid'] ] );
1036  }
1037  }
1038 
1039  return $titleObj;
1040  }
1041 
1051  protected function getParameterFromSettings( $name, $settings, $parseLimit ) {
1052  $validator = $this->getMain()->getParamValidator();
1053  $value = $validator->getValue( $this, $name, $settings, [
1054  'parse-limit' => $parseLimit,
1055  ] );
1056 
1057  // @todo Deprecate and remove this, if possible.
1058  if ( $parseLimit && isset( $settings[ParamValidator::PARAM_TYPE] ) &&
1059  $settings[ParamValidator::PARAM_TYPE] === 'limit' &&
1060  $this->getMain()->getVal( $this->encodeParamName( $name ) ) === 'max'
1061  ) {
1062  $this->getResult()->addParsedLimit( $this->getModuleName(), $value );
1063  }
1064 
1065  return $value;
1066  }
1067 
1077  public function handleParamNormalization( $paramName, $value, $rawValue ) {
1078  $this->addWarning( [ 'apiwarn-badutf8', $paramName ] );
1079  }
1080 
1090  final public function validateToken( $token, array $params ) {
1091  $tokenType = $this->needsToken();
1093  if ( !isset( $salts[$tokenType] ) ) {
1094  throw new MWException(
1095  "Module '{$this->getModuleName()}' tried to use token type '$tokenType' " .
1096  'without registering it'
1097  );
1098  }
1099 
1100  $tokenObj = ApiQueryTokens::getToken(
1101  $this->getUser(), $this->getRequest()->getSession(), $salts[$tokenType]
1102  );
1103  if ( $tokenObj->match( $token ) ) {
1104  return true;
1105  }
1106 
1107  $webUiSalt = $this->getWebUITokenSalt( $params );
1108  if ( $webUiSalt !== null && $this->getUser()->matchEditToken(
1109  $token,
1110  $webUiSalt,
1111  $this->getRequest()
1112  ) ) {
1113  return true;
1114  }
1115 
1116  return false;
1117  }
1118 
1121  /************************************************************************/
1132  public function getWatchlistUser( $params ) {
1133  if ( $params['owner'] !== null && $params['token'] !== null ) {
1134  $user = User::newFromName( $params['owner'], false );
1135  if ( !( $user && $user->getId() ) ) {
1136  $this->dieWithError(
1137  [ 'nosuchusershort', wfEscapeWikiText( $params['owner'] ) ], 'bad_wlowner'
1138  );
1139  }
1140  $token = $user->getOption( 'watchlisttoken' );
1141  if ( $token == '' || !hash_equals( $token, $params['token'] ) ) {
1142  $this->dieWithError( 'apierror-bad-watchlist-token', 'bad_wltoken' );
1143  }
1144  } else {
1145  if ( !$this->getUser()->isLoggedIn() ) {
1146  $this->dieWithError( 'watchlistanontext', 'notloggedin' );
1147  }
1148  $this->checkUserRightsAny( 'viewmywatchlist' );
1149  $user = $this->getUser();
1150  }
1151 
1152  return $user;
1153  }
1154 
1167  public static function makeMessage( $msg, IContextSource $context, array $params = null ) {
1168  if ( is_string( $msg ) ) {
1169  $msg = wfMessage( $msg );
1170  } elseif ( is_array( $msg ) ) {
1171  $msg = wfMessage( ...$msg );
1172  }
1173  if ( !$msg instanceof Message ) {
1174  return null;
1175  }
1176 
1177  $msg->setContext( $context );
1178  if ( $params ) {
1179  $msg->params( $params );
1180  }
1181 
1182  return $msg;
1183  }
1184 
1192  public function errorArrayToStatus( array $errors, User $user = null ) {
1193  if ( $user === null ) {
1194  $user = $this->getUser();
1195  }
1196 
1197  $status = Status::newGood();
1198  foreach ( $errors as $error ) {
1199  if ( !is_array( $error ) ) {
1200  $error = [ $error ];
1201  }
1202  if ( is_string( $error[0] ) && isset( self::$blockMsgMap[$error[0]] ) && $user->getBlock() ) {
1203  list( $msg, $code ) = self::$blockMsgMap[$error[0]];
1204  $status->fatal( ApiMessage::create( $msg, $code,
1205  [ 'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
1206  ) );
1207  } else {
1208  $status->fatal( ...$error );
1209  }
1210  }
1211  return $status;
1212  }
1213 
1220  public function addBlockInfoToStatus( StatusValue $status, User $user = null ) {
1221  if ( $user === null ) {
1222  $user = $this->getUser();
1223  }
1224 
1225  foreach ( self::$blockMsgMap as $msg => list( $apiMsg, $code ) ) {
1226  if ( $status->hasMessage( $msg ) && $user->getBlock() ) {
1227  $status->replaceMessage( $msg, ApiMessage::create( $apiMsg, $code,
1228  [ 'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
1229  ) );
1230  }
1231  }
1232  }
1233 
1238  protected function useTransactionalTimeLimit() {
1239  if ( $this->getRequest()->wasPosted() ) {
1241  }
1242  }
1243 
1252  protected function filterIDs( $fields, array $ids ) {
1253  $min = INF;
1254  $max = 0;
1255  foreach ( $fields as list( $table, $field ) ) {
1256  if ( isset( self::$filterIDsCache[$table][$field] ) ) {
1257  $row = self::$filterIDsCache[$table][$field];
1258  } else {
1259  $row = $this->getDB()->selectRow(
1260  $table,
1261  [
1262  'min_id' => "MIN($field)",
1263  'max_id' => "MAX($field)",
1264  ],
1265  '',
1266  __METHOD__
1267  );
1268  self::$filterIDsCache[$table][$field] = $row;
1269  }
1270  $min = min( $min, $row->min_id );
1271  $max = max( $max, $row->max_id );
1272  }
1273  return array_filter( $ids, function ( $id ) use ( $min, $max ) {
1274  return ( is_int( $id ) && $id >= 0 || ctype_digit( $id ) )
1275  && $id >= $min && $id <= $max;
1276  } );
1277  }
1278 
1281  /************************************************************************/
1300  public function addWarning( $msg, $code = null, $data = null ) {
1301  $this->getErrorFormatter()->addWarning( $this->getModulePath(), $msg, $code, $data );
1302  }
1303 
1314  public function addDeprecation( $msg, $feature, $data = [] ) {
1315  $data = (array)$data;
1316  if ( $feature !== null ) {
1317  $data['feature'] = $feature;
1318  $this->logFeatureUsage( $feature );
1319  }
1320  $this->addWarning( $msg, 'deprecation', $data );
1321 
1322  // No real need to deduplicate here, ApiErrorFormatter does that for
1323  // us (assuming the hook is deterministic).
1324  $msgs = [ $this->msg( 'api-usage-mailinglist-ref' ) ];
1325  $this->getHookRunner()->onApiDeprecationHelp( $msgs );
1326  if ( count( $msgs ) > 1 ) {
1327  $key = '$' . implode( ' $', range( 1, count( $msgs ) ) );
1328  $msg = ( new RawMessage( $key ) )->params( $msgs );
1329  } else {
1330  $msg = reset( $msgs );
1331  }
1332  $this->getMain()->addWarning( $msg, 'deprecation-help' );
1333  }
1334 
1347  public function addError( $msg, $code = null, $data = null ) {
1348  $this->getErrorFormatter()->addError( $this->getModulePath(), $msg, $code, $data );
1349  }
1350 
1360  public function addMessagesFromStatus(
1361  StatusValue $status, $types = [ 'warning', 'error' ], array $filter = []
1362  ) {
1363  $this->getErrorFormatter()->addMessagesFromStatus(
1364  $this->getModulePath(), $status, $types, $filter
1365  );
1366  }
1367 
1381  public function dieWithError( $msg, $code = null, $data = null, $httpCode = null ) {
1382  throw ApiUsageException::newWithMessage( $this, $msg, $code, $data, $httpCode );
1383  }
1384 
1393  public function dieWithException( Throwable $exception, array $options = [] ) {
1394  $this->dieWithError(
1395  // @phan-suppress-next-line PhanTypeMismatchArgument
1396  $this->getErrorFormatter()->getMessageFromException( $exception, $options )
1397  );
1398  }
1399 
1408  public function dieBlocked( AbstractBlock $block ) {
1409  // Die using the appropriate message depending on block type
1410  if ( $block->getType() == DatabaseBlock::TYPE_AUTO ) {
1411  $this->dieWithError(
1412  'apierror-autoblocked',
1413  'autoblocked',
1414  [ 'blockinfo' => $this->getBlockDetails( $block ) ]
1415  );
1416  } elseif ( !$block->isSitewide() ) {
1417  $this->dieWithError(
1418  'apierror-blocked-partial',
1419  'blocked',
1420  [ 'blockinfo' => $this->getBlockDetails( $block ) ]
1421  );
1422  } else {
1423  $this->dieWithError(
1424  'apierror-blocked',
1425  'blocked',
1426  [ 'blockinfo' => $this->getBlockDetails( $block ) ]
1427  );
1428  }
1429  }
1430 
1439  public function dieStatus( StatusValue $status ) {
1440  if ( $status->isGood() ) {
1441  throw new MWException( 'Successful status passed to ApiBase::dieStatus' );
1442  }
1443 
1444  // ApiUsageException needs a fatal status, but this method has
1445  // historically accepted any non-good status. Convert it if necessary.
1446  $status->setOK( false );
1447  if ( !$status->getErrorsByType( 'error' ) ) {
1448  $newStatus = Status::newGood();
1449  foreach ( $status->getErrorsByType( 'warning' ) as $err ) {
1450  $newStatus->fatal( $err['message'], ...$err['params'] );
1451  }
1452  if ( !$newStatus->getErrorsByType( 'error' ) ) {
1453  $newStatus->fatal( 'unknownerror-nocode' );
1454  }
1455  $status = $newStatus;
1456  }
1457 
1458  $this->addBlockInfoToStatus( $status );
1459  throw new ApiUsageException( $this, $status );
1460  }
1461 
1467  public function dieReadOnly() {
1468  $this->dieWithError(
1469  'apierror-readonly',
1470  'readonly',
1471  [ 'readonlyreason' => wfReadOnlyReason() ]
1472  );
1473  }
1474 
1483  public function checkUserRightsAny( $rights, $user = null ) {
1484  if ( !$user ) {
1485  $user = $this->getUser();
1486  }
1487  $rights = (array)$rights;
1488  if ( !$this->getPermissionManager()
1489  ->userHasAnyRight( $user, ...$rights )
1490  ) {
1491  $this->dieWithError( [ 'apierror-permissiondenied', $this->msg( "action-{$rights[0]}" ) ] );
1492  }
1493  }
1494 
1508  public function checkTitleUserPermissions(
1509  LinkTarget $linkTarget,
1510  $actions,
1511  array $options = []
1512  ) {
1513  $user = $options['user'] ?? $this->getUser();
1514 
1515  $errors = [];
1516  foreach ( (array)$actions as $action ) {
1517  $errors = array_merge(
1518  $errors,
1519  $this->getPermissionManager()->getPermissionErrors( $action, $user, $linkTarget )
1520  );
1521  }
1522 
1523  if ( $errors ) {
1524  if ( !empty( $options['autoblock'] ) ) {
1525  $user->spreadAnyEditBlock();
1526  }
1527 
1528  $this->dieStatus( $this->errorArrayToStatus( $errors, $user ) );
1529  }
1530  }
1531 
1543  public function dieWithErrorOrDebug( $msg, $code = null, $data = null, $httpCode = null ) {
1544  if ( $this->getConfig()->get( 'DebugAPI' ) !== true ) {
1545  $this->dieWithError( $msg, $code, $data, $httpCode );
1546  } else {
1547  $this->addWarning( $msg, $code, $data );
1548  }
1549  }
1550 
1561  protected function dieContinueUsageIf( $condition ) {
1562  if ( $condition ) {
1563  $this->dieWithError( 'apierror-badcontinue' );
1564  }
1565  }
1566 
1573  protected static function dieDebug( $method, $message ) {
1574  throw new MWException( "Internal error in $method: $message" );
1575  }
1576 
1583  public function logFeatureUsage( $feature ) {
1584  static $loggedFeatures = [];
1585 
1586  // Only log each feature once per request. We can get multiple calls from calls to
1587  // extractRequestParams() with different values for 'parseLimit', for example.
1588  if ( isset( $loggedFeatures[$feature] ) ) {
1589  return;
1590  }
1591  $loggedFeatures[$feature] = true;
1592 
1593  $request = $this->getRequest();
1594  $ctx = [
1595  'feature' => $feature,
1596  // Spaces to underscores in 'username' for historical reasons.
1597  'username' => str_replace( ' ', '_', $this->getUser()->getName() ),
1598  'clientip' => $request->getIP(),
1599  'referer' => (string)$request->getHeader( 'Referer' ),
1600  'agent' => $this->getMain()->getUserAgent(),
1601  ];
1602 
1603  // Text string is deprecated. Remove (or replace with just $feature) in MW 1.34.
1604  $s = '"' . addslashes( $ctx['feature'] ) . '"' .
1605  ' "' . wfUrlencode( $ctx['username'] ) . '"' .
1606  ' "' . $ctx['clientip'] . '"' .
1607  ' "' . addslashes( $ctx['referer'] ) . '"' .
1608  ' "' . addslashes( $ctx['agent'] ) . '"';
1609 
1610  wfDebugLog( 'api-feature-usage', $s, 'private', $ctx );
1611  }
1612 
1615  /************************************************************************/
1630  protected function getSummaryMessage() {
1631  return "apihelp-{$this->getModulePath()}-summary";
1632  }
1633 
1644  protected function getExtendedDescription() {
1645  return [ [
1646  "apihelp-{$this->getModulePath()}-extended-description",
1647  'api-help-no-extended-description',
1648  ] ];
1649  }
1650 
1658  public function getFinalSummary() {
1659  $msg = self::makeMessage( $this->getSummaryMessage(), $this->getContext(), [
1660  $this->getModulePrefix(),
1661  $this->getModuleName(),
1662  $this->getModulePath(),
1663  ] );
1664  return $msg;
1665  }
1666 
1674  public function getFinalDescription() {
1675  $summary = self::makeMessage( $this->getSummaryMessage(), $this->getContext(), [
1676  $this->getModulePrefix(),
1677  $this->getModuleName(),
1678  $this->getModulePath(),
1679  ] );
1680  $extendedDescription = self::makeMessage(
1681  $this->getExtendedDescription(), $this->getContext(), [
1682  $this->getModulePrefix(),
1683  $this->getModuleName(),
1684  $this->getModulePath(),
1685  ]
1686  );
1687 
1688  $msgs = [ $summary, $extendedDescription ];
1689 
1690  $this->getHookRunner()->onAPIGetDescriptionMessages( $this, $msgs );
1691 
1692  return $msgs;
1693  }
1694 
1703  public function getFinalParams( $flags = 0 ) {
1704  // @phan-suppress-next-line PhanParamTooMany
1705  $params = $this->getAllowedParams( $flags );
1706  if ( !$params ) {
1707  $params = [];
1708  }
1709 
1710  if ( $this->needsToken() ) {
1711  $params['token'] = [
1712  self::PARAM_TYPE => 'string',
1713  self::PARAM_REQUIRED => true,
1714  self::PARAM_SENSITIVE => true,
1715  self::PARAM_HELP_MSG => [
1716  'api-help-param-token',
1717  $this->needsToken(),
1718  ],
1719  ] + ( $params['token'] ?? [] );
1720  }
1721 
1722  $this->getHookRunner()->onAPIGetAllowedParams( $this, $params, $flags );
1723 
1724  return $params;
1725  }
1726 
1734  public function getFinalParamDescription() {
1735  $prefix = $this->getModulePrefix();
1736  $name = $this->getModuleName();
1737  $path = $this->getModulePath();
1738 
1739  $params = $this->getFinalParams( self::GET_VALUES_FOR_HELP );
1740  $msgs = [];
1741  foreach ( $params as $param => $settings ) {
1742  if ( !is_array( $settings ) ) {
1743  $settings = [];
1744  }
1745 
1746  if ( isset( $settings[self::PARAM_HELP_MSG] ) ) {
1747  $msg = $settings[self::PARAM_HELP_MSG];
1748  } else {
1749  $msg = $this->msg( "apihelp-{$path}-param-{$param}" );
1750  }
1751  $msg = self::makeMessage( $msg, $this->getContext(),
1752  [ $prefix, $param, $name, $path ] );
1753  if ( !$msg ) {
1754  self::dieDebug( __METHOD__,
1755  'Value in ApiBase::PARAM_HELP_MSG is not valid' );
1756  }
1757  $msgs[$param] = [ $msg ];
1758 
1759  if ( isset( $settings[self::PARAM_TYPE] ) &&
1760  $settings[self::PARAM_TYPE] === 'submodule'
1761  ) {
1762  if ( isset( $settings[self::PARAM_SUBMODULE_MAP] ) ) {
1763  $map = $settings[self::PARAM_SUBMODULE_MAP];
1764  } else {
1765  $prefix = $this->isMain() ? '' : ( $this->getModulePath() . '+' );
1766  $map = [];
1767  foreach ( $this->getModuleManager()->getNames( $param ) as $submoduleName ) {
1768  $map[$submoduleName] = $prefix . $submoduleName;
1769  }
1770  }
1771 
1772  $submodules = [];
1773  $submoduleFlags = []; // for sorting: higher flags are sorted later
1774  $submoduleNames = []; // for sorting: lexicographical, ascending
1775  foreach ( $map as $v => $m ) {
1776  $isDeprecated = false;
1777  $isInternal = false;
1778  $summary = null;
1779  try {
1780  $submod = $this->getModuleFromPath( $m );
1781  if ( $submod ) {
1782  $summary = $submod->getFinalSummary();
1783  $isDeprecated = $submod->isDeprecated();
1784  $isInternal = $submod->isInternal();
1785  }
1786  } catch ( ApiUsageException $ex ) {
1787  // Ignore
1788  }
1789  if ( $summary ) {
1790  $key = $summary->getKey();
1791  $params = $summary->getParams();
1792  } else {
1793  $key = 'api-help-undocumented-module';
1794  $params = [ $m ];
1795  }
1796  $m = new ApiHelpParamValueMessage(
1797  "[[Special:ApiHelp/$m|$v]]",
1798  $key,
1799  $params,
1800  $isDeprecated,
1801  $isInternal
1802  );
1803  $submodules[] = $m->setContext( $this->getContext() );
1804  $submoduleFlags[] = ( $isDeprecated ? 1 : 0 ) | ( $isInternal ? 2 : 0 );
1805  $submoduleNames[] = $v;
1806  }
1807  // sort $submodules by $submoduleFlags and $submoduleNames
1808  array_multisort( $submoduleFlags, $submoduleNames, $submodules );
1809  $msgs[$param] = array_merge( $msgs[$param], $submodules );
1810  } elseif ( isset( $settings[self::PARAM_HELP_MSG_PER_VALUE] ) ) {
1811  if ( !is_array( $settings[self::PARAM_HELP_MSG_PER_VALUE] ) ) {
1812  self::dieDebug( __METHOD__,
1813  'ApiBase::PARAM_HELP_MSG_PER_VALUE is not valid' );
1814  }
1815  if ( !is_array( $settings[self::PARAM_TYPE] ) ) {
1816  self::dieDebug( __METHOD__,
1817  'ApiBase::PARAM_HELP_MSG_PER_VALUE may only be used when ' .
1818  'ApiBase::PARAM_TYPE is an array' );
1819  }
1820 
1821  $valueMsgs = $settings[self::PARAM_HELP_MSG_PER_VALUE];
1822  $deprecatedValues = $settings[self::PARAM_DEPRECATED_VALUES] ?? [];
1823 
1824  foreach ( $settings[self::PARAM_TYPE] as $value ) {
1825  if ( isset( $valueMsgs[$value] ) ) {
1826  $msg = $valueMsgs[$value];
1827  } else {
1828  $msg = "apihelp-{$path}-paramvalue-{$param}-{$value}";
1829  }
1830  $m = self::makeMessage( $msg, $this->getContext(),
1831  [ $prefix, $param, $name, $path, $value ] );
1832  if ( $m ) {
1833  $m = new ApiHelpParamValueMessage(
1834  $value,
1835  // @phan-suppress-next-line PhanTypeMismatchArgument
1836  [ $m->getKey(), 'api-help-param-no-description' ],
1837  $m->getParams(),
1838  isset( $deprecatedValues[$value] )
1839  );
1840  $msgs[$param][] = $m->setContext( $this->getContext() );
1841  } else {
1842  self::dieDebug( __METHOD__,
1843  "Value in ApiBase::PARAM_HELP_MSG_PER_VALUE for $value is not valid" );
1844  }
1845  }
1846  }
1847 
1848  if ( isset( $settings[self::PARAM_HELP_MSG_APPEND] ) ) {
1849  if ( !is_array( $settings[self::PARAM_HELP_MSG_APPEND] ) ) {
1850  self::dieDebug( __METHOD__,
1851  'Value for ApiBase::PARAM_HELP_MSG_APPEND is not an array' );
1852  }
1853  foreach ( $settings[self::PARAM_HELP_MSG_APPEND] as $m ) {
1854  $m = self::makeMessage( $m, $this->getContext(),
1855  [ $prefix, $param, $name, $path ] );
1856  if ( $m ) {
1857  $msgs[$param][] = $m;
1858  } else {
1859  self::dieDebug( __METHOD__,
1860  'Value in ApiBase::PARAM_HELP_MSG_APPEND is not valid' );
1861  }
1862  }
1863  }
1864  }
1865 
1866  $this->getHookRunner()->onAPIGetParamDescriptionMessages( $this, $msgs );
1867 
1868  return $msgs;
1869  }
1870 
1880  protected function getHelpFlags() {
1881  $flags = [];
1882 
1883  if ( $this->isDeprecated() ) {
1884  $flags[] = 'deprecated';
1885  }
1886  if ( $this->isInternal() ) {
1887  $flags[] = 'internal';
1888  }
1889  if ( $this->isReadMode() ) {
1890  $flags[] = 'readrights';
1891  }
1892  if ( $this->isWriteMode() ) {
1893  $flags[] = 'writerights';
1894  }
1895  if ( $this->mustBePosted() ) {
1896  $flags[] = 'mustbeposted';
1897  }
1898 
1899  return $flags;
1900  }
1901 
1913  protected function getModuleSourceInfo() {
1914  global $IP;
1915 
1916  if ( $this->mModuleSource !== false ) {
1917  return $this->mModuleSource;
1918  }
1919 
1920  // First, try to find where the module comes from...
1921  $rClass = new ReflectionClass( $this );
1922  $path = $rClass->getFileName();
1923  if ( !$path ) {
1924  // No path known?
1925  $this->mModuleSource = null;
1926  return null;
1927  }
1928  $path = realpath( $path ) ?: $path;
1929 
1930  // Build map of extension directories to extension info
1931  if ( self::$extensionInfo === null ) {
1932  $extDir = $this->getConfig()->get( 'ExtensionDirectory' );
1933  self::$extensionInfo = [
1934  realpath( __DIR__ ) ?: __DIR__ => [
1935  'path' => $IP,
1936  'name' => 'MediaWiki',
1937  'license-name' => 'GPL-2.0-or-later',
1938  ],
1939  realpath( "$IP/extensions" ) ?: "$IP/extensions" => null,
1940  realpath( $extDir ) ?: $extDir => null,
1941  ];
1942  $keep = [
1943  'path' => null,
1944  'name' => null,
1945  'namemsg' => null,
1946  'license-name' => null,
1947  ];
1949  foreach ( $credits as $group ) {
1950  foreach ( $group as $ext ) {
1951  if ( !isset( $ext['path'] ) || !isset( $ext['name'] ) ) {
1952  // This shouldn't happen, but does anyway.
1953  continue;
1954  }
1955 
1956  $extpath = $ext['path'];
1957  if ( !is_dir( $extpath ) ) {
1958  $extpath = dirname( $extpath );
1959  }
1960  self::$extensionInfo[realpath( $extpath ) ?: $extpath] =
1961  array_intersect_key( $ext, $keep );
1962  }
1963  }
1964  }
1965 
1966  // Now traverse parent directories until we find a match or run out of
1967  // parents.
1968  do {
1969  if ( array_key_exists( $path, self::$extensionInfo ) ) {
1970  // Found it!
1971  $this->mModuleSource = self::$extensionInfo[$path];
1972  return $this->mModuleSource;
1973  }
1974 
1975  $oldpath = $path;
1976  $path = dirname( $path );
1977  } while ( $path !== $oldpath );
1978 
1979  // No idea what extension this might be.
1980  $this->mModuleSource = null;
1981  return null;
1982  }
1983 
1996  public function modifyHelp( array &$help, array $options, array &$tocData ) {
1997  }
1998 
2001  /************************************************************************/
2014  protected function explodeMultiValue( $value, $limit ) {
2015  wfDeprecated( __METHOD__, '1.35' );
2016  return ParamValidator::explodeMultiValue( $value, $limit );
2017  }
2018 
2037  protected function parseMultiValue( $valueName, $value, $allowMultiple, $allowedValues,
2038  $allSpecifier = null, $limit1 = null, $limit2 = null
2039  ) {
2040  wfDeprecated( __METHOD__, '1.35' );
2041 
2042  if ( ( $value === '' || $value === "\x1f" ) && $allowMultiple ) {
2043  return [];
2044  }
2045  $limit1 = $limit1 ?: self::LIMIT_SML1;
2046  $limit2 = $limit2 ?: self::LIMIT_SML2;
2047 
2048  // This is a bit awkward, but we want to avoid calling canApiHighLimits()
2049  // because it unstubs $wgUser
2050  $valuesList = $this->explodeMultiValue( $value, $limit2 + 1 );
2051  $sizeLimit = count( $valuesList ) > $limit1 && $this->mMainModule->canApiHighLimits()
2052  ? $limit2
2053  : $limit1;
2054 
2055  if ( $allowMultiple && is_array( $allowedValues ) && $allSpecifier &&
2056  count( $valuesList ) === 1 && $valuesList[0] === $allSpecifier
2057  ) {
2058  return $allowedValues;
2059  }
2060 
2061  if ( count( $valuesList ) > $sizeLimit ) {
2062  $this->dieWithError(
2063  [ 'apierror-toomanyvalues', $valueName, $sizeLimit ],
2064  "too-many-$valueName"
2065  );
2066  }
2067 
2068  if ( !$allowMultiple && count( $valuesList ) != 1 ) {
2069  // T35482 - Allow entries with | in them for non-multiple values
2070  if ( in_array( $value, $allowedValues, true ) ) {
2071  return $value;
2072  }
2073 
2074  $values = array_map( function ( $v ) {
2075  return '<kbd>' . wfEscapeWikiText( $v ) . '</kbd>';
2076  }, $allowedValues );
2077  $this->dieWithError( [
2078  'apierror-multival-only-one-of',
2079  $valueName,
2080  Message::listParam( $values ),
2081  count( $values ),
2082  ], "multival_$valueName" );
2083  }
2084 
2085  if ( is_array( $allowedValues ) ) {
2086  // Check for unknown values
2087  $unknown = array_map( 'wfEscapeWikiText', array_diff( $valuesList, $allowedValues ) );
2088  if ( count( $unknown ) ) {
2089  if ( $allowMultiple ) {
2090  $this->addWarning( [
2091  'apiwarn-unrecognizedvalues',
2092  $valueName,
2093  Message::listParam( $unknown, 'comma' ),
2094  count( $unknown ),
2095  ] );
2096  } else {
2097  $this->dieWithError(
2098  [ 'apierror-unrecognizedvalue', $valueName, wfEscapeWikiText( $valuesList[0] ) ],
2099  "unknown_$valueName"
2100  );
2101  }
2102  }
2103  // Now throw them out
2104  $valuesList = array_intersect( $valuesList, $allowedValues );
2105  }
2106 
2107  return $allowMultiple ? $valuesList : $valuesList[0];
2108  }
2109 
2121  protected function validateLimit( $name, &$value, $min, $max, $botMax = null,
2122  $enforceLimits = false
2123  ) {
2124  wfDeprecated( __METHOD__, '1.35' );
2125  $value = $this->getMain()->getParamValidator()->validateValue(
2126  $this, $name, $value, [
2127  ParamValidator::PARAM_TYPE => 'limit',
2128  IntegerDef::PARAM_MIN => $min,
2129  IntegerDef::PARAM_MAX => $max,
2130  IntegerDef::PARAM_MAX2 => $botMax,
2131  IntegerDef::PARAM_IGNORE_RANGE => !$enforceLimits,
2132  ]
2133  );
2134  }
2135 
2143  protected function validateTimestamp( $value, $encParamName ) {
2144  wfDeprecated( __METHOD__, '1.35' );
2145 
2146  // Sigh.
2147  $name = $encParamName;
2148  $p = (string)$this->getModulePrefix();
2149  $l = strlen( $p );
2150  if ( $l && substr( $name, 0, $l ) === $p ) {
2151  $name = substr( $name, $l );
2152  }
2153 
2154  return $this->getMain()->getParamValidator()->validateValue(
2155  $this, $name, $value, [
2156  ParamValidator::PARAM_TYPE => 'timestamp',
2157  ]
2158  );
2159  }
2160 
2163 }
2164 
ApiMain
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:48
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:37
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:70
ApiBase\PARAM_SUBMODULE_MAP
const PARAM_SUBMODULE_MAP
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:77
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:328
ApiUsageException
Exception used to abort API execution with an error.
Definition: ApiUsageException.php:29
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:45
ApiBase\$mMainModule
ApiMain $mMainModule
Definition: ApiBase.php:195
StatusValue
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: StatusValue.php:43
ApiBase\getParent
getParent()
Get the parent of this module Stable to override.
Definition: ApiBase.php:478
ApiBase\addWarning
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
Definition: ApiBase.php:1300
ApiBase\getSummaryMessage
getSummaryMessage()
Return the summary message.
Definition: ApiBase.php:1630
ApiUsageException\newWithMessage
static newWithMessage(?ApiBase $module, $msg, $code=null, $data=null, $httpCode=0, Throwable $previous=null)
Definition: ApiUsageException.php:68
ApiBase\getFinalParams
getFinalParams( $flags=0)
Get final list of parameters, after hooks have had a chance to tweak it as needed.
Definition: ApiBase.php:1703
ApiBase\PARAM_REQUIRED
const PARAM_REQUIRED
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:76
StatusValue\getErrorsByType
getErrorsByType( $type)
Returns a list of status messages of the given type.
Definition: StatusValue.php:244
ApiBase\$hookContainer
HookContainer $hookContainer
Definition: ApiBase.php:57
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:160
ApiBase\parameterNotEmpty
parameterNotEmpty( $x)
Callback function used in requireOnlyOneParameter to check whether required parameters are set.
Definition: ApiBase.php:970
ApiBase\$mModuleSource
array null bool $mModuleSource
Definition: ApiBase.php:204
ApiBase\validateToken
validateToken( $token, array $params)
Validate the supplied token.
Definition: ApiBase.php:1090
ApiContinuationManager
This manages continuation state.
Definition: ApiContinuationManager.php:26
ApiBase\dieWithError
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
Definition: ApiBase.php:1381
ApiBase\PARAM_HELP_MSG
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:106
ApiBase\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiBase.php:281
StatusValue\replaceMessage
replaceMessage( $source, $dest)
If the specified source message exists, replace it with the specified destination message,...
Definition: StatusValue.php:290
ApiBase\PARAM_ALL
const PARAM_ALL
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:79
ApiBase\validateTimestamp
validateTimestamp( $value, $encParamName)
Validate and normalize parameters of type 'timestamp'.
Definition: ApiBase.php:2143
ApiBase\$extensionInfo
static array $extensionInfo
Maps extension paths to info arrays.
Definition: ApiBase.php:180
ApiBase\getTitleOrPageId
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
Definition: ApiBase.php:985
ApiBase\PARAM_TYPE
const PARAM_TYPE
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:70
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:564
ApiBase\__construct
__construct(ApiMain $mainModule, $moduleName, $modulePrefix='')
Stable to call.
Definition: ApiBase.php:212
ApiBase\getParameterFromSettings
getParameterFromSettings( $name, $settings, $parseLimit)
Using the settings determine the value for the given parameter.
Definition: ApiBase.php:1051
ApiBase\$blockMsgMap
static $blockMsgMap
$var array Map of web UI block messages to corresponding API messages and codes
Definition: ApiBase.php:186
wfUrlencode
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
Definition: GlobalFunctions.php:308
ApiBase\mustBePosted
mustBePosted()
Indicates whether this module must be called with a POST request Stable to override.
Definition: ApiBase.php:353
ApiBase\logFeatureUsage
logFeatureUsage( $feature)
Write logging information for API features to a debug log, for usage analysis.
Definition: ApiBase.php:1583
ApiBase\checkUserRightsAny
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
Definition: ApiBase.php:1483
ApiBase\shouldCheckMaxlag
shouldCheckMaxlag()
Indicates if this module needs maxlag to be checked Stable to override.
Definition: ApiBase.php:319
ApiBase\dieWithErrorOrDebug
dieWithErrorOrDebug( $msg, $code=null, $data=null, $httpCode=null)
Will only set a warning instead of failing if the global $wgDebugAPI is set to true.
Definition: ApiBase.php:1543
ApiBase\setContinuationManager
setContinuationManager(ApiContinuationManager $manager=null)
Set the continuation manager.
Definition: ApiBase.php:620
Wikimedia\ParamValidator\TypeDef\EnumDef
Type definition for enumeration types.
Definition: EnumDef.php:32
ApiBase\getExtendedDescription
getExtendedDescription()
Return the extended help text message.
Definition: ApiBase.php:1644
ApiBase\PARAM_ISMULTI_LIMIT1
const PARAM_ISMULTI_LIMIT1
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:83
User\newFromName
static newFromName( $name, $validate='valid')
Definition: User.php:542
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1220
ApiBase\addBlockInfoToStatus
addBlockInfoToStatus(StatusValue $status, User $user=null)
Add block info to block messages in a Status.
Definition: ApiBase.php:1220
ApiBase\getHookContainer
getHookContainer()
Get a HookContainer, for running extension hooks or for hook metadata.
Definition: ApiBase.php:646
$s
$s
Definition: mergeMessageFileList.php:184
ApiBase\dieBlocked
dieBlocked(AbstractBlock $block)
Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die wit...
Definition: ApiBase.php:1408
ApiBase\getDB
getDB()
Gets a default replica DB connection object Stable to override.
Definition: ApiBase.php:594
ApiBase\addMessagesFromStatus
addMessagesFromStatus(StatusValue $status, $types=[ 'warning', 'error'], array $filter=[])
Add warnings and/or errors from a Status.
Definition: ApiBase.php:1360
ApiBase\makeMessage
static makeMessage( $msg, IContextSource $context, array $params=null)
Create a Message from a string or array.
Definition: ApiBase.php:1167
ContextSource\getRequest
getRequest()
Definition: ContextSource.php:79
ApiBase\dynamicParameterDocumentation
dynamicParameterDocumentation()
Indicate if the module supports dynamically-determined parameters that cannot be included in self::ge...
Definition: ApiBase.php:683
ApiBase\modifyHelp
modifyHelp(array &$help, array $options, array &$tocData)
Called from ApiHelp before the pieces are joined together and returned.
Definition: ApiBase.php:1996
ApiBase\PARAM_ALLOW_DUPLICATES
const PARAM_ALLOW_DUPLICATES
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:74
ContextSource\getUser
getUser()
Stable to override.
Definition: ContextSource.php:134
MediaWiki\Api\ApiHookRunner
This class provides an implementation of the hook interfaces used by the core Action API,...
Definition: ApiHookRunner.php:53
StatusValue\setOK
setOK( $ok)
Change operation status.
Definition: StatusValue.php:158
ApiBase\PARAM_DEPRECATED_VALUES
const PARAM_DEPRECATED_VALUES
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:82
ApiBase\lacksSameOriginSecurity
lacksSameOriginSecurity()
Returns true if the current request breaks the same-origin policy.
Definition: ApiBase.php:492
ApiBase\PARAM_HELP_MSG_APPEND
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
Definition: ApiBase.php:113
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:989
ApiBase\getWebUITokenSalt
getWebUITokenSalt(array $params)
Fetch the salt used in the Web UI corresponding to this module.
Definition: ApiBase.php:411
Message\listParam
static listParam(array $list, $type='text')
Definition: Message.php:1112
ApiBase\isMain
isMain()
Returns true if this module is the main module ($this === $this->mMainModule), false otherwise.
Definition: ApiBase.php:468
ApiBase\isReadMode
isReadMode()
Indicates whether this module requires read rights Stable to override.
Definition: ApiBase.php:328
ApiBase
This abstract class implements many basic API functions, and is the base of all API classes.
Definition: ApiBase.php:52
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
ApiBase\getModuleFromPath
getModuleFromPath( $path)
Get a module from its module path.
Definition: ApiBase.php:526
ApiBase\getFinalParamDescription
getFinalParamDescription()
Get final parameter descriptions, after hooks have had a chance to tweak it as needed.
Definition: ApiBase.php:1734
ApiBase\PARAM_SENSITIVE
const PARAM_SENSITIVE
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:81
ApiBase\PARAM_ISMULTI_LIMIT2
const PARAM_ISMULTI_LIMIT2
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:84
ExtensionRegistry\getInstance
static getInstance()
Definition: ExtensionRegistry.php:136
ApiBase\getFinalSummary
getFinalSummary()
Get final module summary.
Definition: ApiBase.php:1658
ApiBase\PARAM_DEPRECATED
const PARAM_DEPRECATED
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:75
ApiBase\explodeMultiValue
explodeMultiValue( $value, $limit)
Split a multi-valued parameter string, like explode()
Definition: ApiBase.php:2014
MediaWiki\Block\DatabaseBlock
A DatabaseBlock (unlike a SystemBlock) is stored in the database, may give rise to autoblocks and may...
Definition: DatabaseBlock.php:52
ApiBase\PARAM_MIN
const PARAM_MIN
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:73
StatusValue\isGood
isGood()
Returns whether the operation completed and didn't have any error or warnings.
Definition: StatusValue.php:122
MWException
MediaWiki exception.
Definition: MWException.php:29
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:159
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Definition: GlobalFunctions.php:1027
ApiBase\getCustomPrinter
getCustomPrinter()
If the module may only be used with a certain format module, it should override this method to return...
Definition: ApiBase.php:265
ApiBase\getFinalDescription
getFinalDescription()
Get final module description, after hooks have had a chance to tweak it as needed.
Definition: ApiBase.php:1674
wfTransactionalTimeLimit
wfTransactionalTimeLimit()
Set PHP's time limit to the larger of php.ini or $wgTransactionalTimeLimit.
Definition: GlobalFunctions.php:2650
ApiBase\getModulePath
getModulePath()
Get the path to this module.
Definition: ApiBase.php:508
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2475
ApiBase\LIMIT_BIG1
const LIMIT_BIG1
Fast query, standard limit.
Definition: ApiBase.php:164
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:31
ApiQueryTokens\getTokenTypeSalts
static getTokenTypeSalts()
Get the salts for known token types.
Definition: ApiQueryTokens.php:66
ApiBase\$hookRunner
ApiHookRunner $hookRunner
Definition: ApiBase.php:60
ApiBase\PARAM_MAX
const PARAM_MAX
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:71
ApiBase\extractRequestParams
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:716
ApiBase\handleParamNormalization
handleParamNormalization( $paramName, $value, $rawValue)
Handle when a parameter was Unicode-normalized.
Definition: ApiBase.php:1077
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
ApiBase\isDeprecated
isDeprecated()
Indicates whether this module is deprecated.
Definition: ApiBase.php:363
ApiBase\requireAtLeastOneParameter
requireAtLeastOneParameter( $params,... $required)
Die if none of a certain set of parameters is set and not false.
Definition: ApiBase.php:913
ApiBase\$mReplicaDB
$mReplicaDB
Definition: ApiBase.php:198
MediaWiki\Block\AbstractBlock\getType
getType()
Get the type of target for this particular block.
Definition: AbstractBlock.php:436
MediaWiki\Block\AbstractBlock\isSitewide
isSitewide( $x=null)
Indicates that the block is a sitewide block.
Definition: AbstractBlock.php:216
ApiMessage\create
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
Definition: ApiMessage.php:42
ApiBase\PARAM_EXTRA_NAMESPACES
const PARAM_EXTRA_NAMESPACES
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:80
ApiBase\ALL_DEFAULT_STRING
const ALL_DEFAULT_STRING
Definition: ApiBase.php:161
ContextSource\setContext
setContext(IContextSource $context)
Definition: ContextSource.php:61
Wikimedia\ParamValidator\TypeDef\StringDef
Type definition for string types.
Definition: StringDef.php:24
ApiBase\getHelpUrls
getHelpUrls()
Return links to more detailed help pages about the module.
Definition: ApiBase.php:291
ApiBlockInfoTrait
trait ApiBlockInfoTrait
Definition: ApiBlockInfoTrait.php:28
ApiBase\needsToken
needsToken()
Returns the token type this module requires in order to execute.
Definition: ApiBase.php:397
ApiBase\getModulePrefix
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
Definition: ApiBase.php:451
ApiBase\$mModuleName
string $mModuleName
Definition: ApiBase.php:197
ApiBase\getContinuationManager
getContinuationManager()
Get the continuation manager.
Definition: ApiBase.php:606
ContextSource\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:187
ApiBase\validateLimit
validateLimit( $name, &$value, $min, $max, $botMax=null, $enforceLimits=false)
Validate the value against the minimum and user/bot maximum limits.
Definition: ApiBase.php:2121
ApiBase\addError
addError( $msg, $code=null, $data=null)
Add an error for this module without aborting.
Definition: ApiBase.php:1347
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition: PermissionManager.php:49
ApiBase\getWatchlistUser
getWatchlistUser( $params)
Gets the user for whom to get the watchlist.
Definition: ApiBase.php:1132
ApiBase\requireOnlyOneParameter
requireOnlyOneParameter( $params,... $required)
Die if none or more than one of a certain set of parameters is set and not false.
Definition: ApiBase.php:853
ApiBase\requireMaxOneParameter
requireMaxOneParameter( $params,... $required)
Die if more than one of a certain set of parameters is set and not false.
Definition: ApiBase.php:888
ApiBase\dieContinueUsageIf
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
Definition: ApiBase.php:1561
SpecialVersion\getCredits
static getCredits(ExtensionRegistry $reg, Config $conf)
Definition: SpecialVersion.php:62
ApiBase\addDeprecation
addDeprecation( $msg, $feature, $data=[])
Add a deprecation warning for this module.
Definition: ApiBase.php:1314
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:82
ApiBase\LIMIT_SML2
const LIMIT_SML2
Slow query, apihighlimits limit.
Definition: ApiBase.php:170
ApiBase\encodeParamName
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
Definition: ApiBase.php:694
ApiBase\dieReadOnly
dieReadOnly()
Helper function for readonly errors.
Definition: ApiBase.php:1467
ApiBase\GET_VALUES_FOR_HELP
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
Definition: ApiBase.php:177
WikiPage\newFromID
static newFromID( $id, $from='fromdb')
Constructor from a page id.
Definition: WikiPage.php:174
ApiBase\getPermissionManager
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
Definition: ApiBase.php:636
ApiBase\useTransactionalTimeLimit
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
Definition: ApiBase.php:1238
ApiBase\getConditionalRequestData
getConditionalRequestData( $condition)
Returns data for HTTP conditional request mechanisms.
Definition: ApiBase.php:428
ApiBase\isWriteMode
isWriteMode()
Indicates whether this module requires write mode.
Definition: ApiBase.php:344
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1494
ApiBase\PARAM_HELP_MSG_INFO
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
Definition: ApiBase.php:123
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
ApiBase\PARAM_RANGE_ENFORCE
const PARAM_RANGE_ENFORCE
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:92
ApiBase\PARAM_VALUE_LINKS
const PARAM_VALUE_LINKS
Deprecated and unused.
Definition: ApiBase.php:130
Wikimedia\ParamValidator\TypeDef\IntegerDef
Type definition for integer types.
Definition: IntegerDef.php:23
ApiBase\PARAM_TEMPLATE_VARS
const PARAM_TEMPLATE_VARS
(array) Indicate that this is a templated parameter, and specify replacements.
Definition: ApiBase.php:157
ApiBase\filterIDs
filterIDs( $fields, array $ids)
Filter out-of-range values from a list of positive integer IDs.
Definition: ApiBase.php:1252
ApiBase\LIMIT_BIG2
const LIMIT_BIG2
Fast query, apihighlimits limit.
Definition: ApiBase.php:166
wfReadOnlyReason
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
Definition: GlobalFunctions.php:1139
ApiQueryTokens\getToken
static getToken(User $user, MediaWiki\Session\Session $session, $salt)
Get a token from a salt.
Definition: ApiQueryTokens.php:99
ApiBase\getModuleManager
getModuleManager()
Get the module manager, or null if this module has no sub-modules.
Definition: ApiBase.php:251
Wikimedia\ParamValidator\ParamValidator::TypeDef\NamespaceDef
Type definition for namespace types.
Definition: NamespaceDef.php:18
ApiBase\isInternal
isInternal()
Indicates whether this module is "internal" Internal API modules are not (yet) intended for 3rd party...
Definition: ApiBase.php:374
ApiBase\getModuleSourceInfo
getModuleSourceInfo()
Returns information about the source of this module, if known.
Definition: ApiBase.php:1913
$path
$path
Definition: NoLocalSettings.php:25
ApiBase\PARAM_DFLT
const PARAM_DFLT
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:68
ApiBase\getParameter
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
Definition: ApiBase.php:836
ApiBase\dieWithException
dieWithException(Throwable $exception, array $options=[])
Abort execution with an error derived from a throwable.
Definition: ApiBase.php:1393
ApiBase\dieStatus
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
Definition: ApiBase.php:1439
ApiBase\getModuleName
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:443
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:69
Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:161
ApiBase\PARAM_MAX2
const PARAM_MAX2
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:72
StatusValue\hasMessage
hasMessage( $message)
Returns true if the specified message is present as a warning or error.
Definition: StatusValue.php:262
ApiBase\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiBase.php:308
ApiBase\parseMultiValue
parseMultiValue( $valueName, $value, $allowMultiple, $allowedValues, $allSpecifier=null, $limit1=null, $limit2=null)
Return an array of values that were given in a 'a|b|c' notation, after it optionally validates them a...
Definition: ApiBase.php:2037
$help
$help
Definition: mcc.php:32
ApiBase\getMain
getMain()
Get the main module.
Definition: ApiBase.php:459
$ext
if(!is_readable( $file)) $ext
Definition: router.php:48
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:45
ApiBase\PARAM_MAX_CHARS
const PARAM_MAX_CHARS
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:86
MediaWiki\Block\AbstractBlock
Definition: AbstractBlock.php:38
ApiBase\checkTitleUserPermissions
checkTitleUserPermissions(LinkTarget $linkTarget, $actions, array $options=[])
Helper function for permission-denied errors.
Definition: ApiBase.php:1508
ApiBase\getTitleFromTitleOrPageId
getTitleFromTitleOrPageId( $params)
Get a Title object from a title or pageid param, if possible.
Definition: ApiBase.php:1022
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
ApiBase\$mModulePrefix
string $mModulePrefix
Definition: ApiBase.php:197
RawMessage
Variant of the Message class.
Definition: RawMessage.php:35
ApiBase\PARAM_HELP_MSG_PER_VALUE
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
Definition: ApiBase.php:139
ApiBase\PARAM_SUBMODULE_PARAM_PREFIX
const PARAM_SUBMODULE_PARAM_PREFIX
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:78
ApiBase\$mParamCache
array $mParamCache
Definition: ApiBase.php:202
ApiBase\PARAM_MAX_BYTES
const PARAM_MAX_BYTES
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:85
ApiHelpParamValueMessage
Message subclass that prepends wikitext for API help.
Definition: ApiHelpParamValueMessage.php:34
ApiBase\getHookRunner
getHookRunner()
Get an ApiHookRunner for running core API hooks.
Definition: ApiBase.php:661
$IP
$IP
Definition: WebStart.php:49
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:56
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:472
ApiBase\dieDebug
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition: ApiBase.php:1573
ApiBase\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
ApiBase\errorArrayToStatus
errorArrayToStatus(array $errors, User $user=null)
Turn an array of message keys or key+param arrays into a Status.
Definition: ApiBase.php:1192
ApiBase\getErrorFormatter
getErrorFormatter()
Get the error formatter Stable to override.
Definition: ApiBase.php:579
MediaWiki\Api\Validator\SubmoduleDef
Type definition for submodule types.
Definition: SubmoduleDef.php:17
ApiBase\requirePostedParameters
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...
Definition: ApiBase.php:940
Wikimedia\ParamValidator\ParamValidator
Service for formatting and validating API parameters.
Definition: ParamValidator.php:42
ApiBase\LIMIT_SML1
const LIMIT_SML1
Slow query, standard limit.
Definition: ApiBase.php:168
ApiBase\getHelpFlags
getHelpFlags()
Generates the list of flags for the help screen and for action=paraminfo.
Definition: ApiBase.php:1880
ApiBase\$filterIDsCache
static stdClass[][] $filterIDsCache
Cache for self::filterIDs()
Definition: ApiBase.php:183