MediaWiki  master
ApiBase.php
Go to the documentation of this file.
1 <?php
40 
55 abstract class ApiBase extends ContextSource {
56 
58 
60  private $hookContainer;
61 
63  private $hookRunner;
64 
70  public const PARAM_DFLT = ParamValidator::PARAM_DEFAULT;
71  public const PARAM_ISMULTI = ParamValidator::PARAM_ISMULTI;
72  public const PARAM_TYPE = ParamValidator::PARAM_TYPE;
73  public const PARAM_MAX = IntegerDef::PARAM_MAX;
74  public const PARAM_MAX2 = IntegerDef::PARAM_MAX2;
75  public const PARAM_MIN = IntegerDef::PARAM_MIN;
76  public const PARAM_ALLOW_DUPLICATES = ParamValidator::PARAM_ALLOW_DUPLICATES;
77  public const PARAM_DEPRECATED = ParamValidator::PARAM_DEPRECATED;
78  public const PARAM_REQUIRED = ParamValidator::PARAM_REQUIRED;
79  public const PARAM_SUBMODULE_MAP = SubmoduleDef::PARAM_SUBMODULE_MAP;
80  public const PARAM_SUBMODULE_PARAM_PREFIX = SubmoduleDef::PARAM_SUBMODULE_PARAM_PREFIX;
81  public const PARAM_ALL = ParamValidator::PARAM_ALL;
82  public const PARAM_EXTRA_NAMESPACES = NamespaceDef::PARAM_EXTRA_NAMESPACES;
83  public const PARAM_SENSITIVE = ParamValidator::PARAM_SENSITIVE;
84  public const PARAM_DEPRECATED_VALUES = EnumDef::PARAM_DEPRECATED_VALUES;
85  public const PARAM_ISMULTI_LIMIT1 = ParamValidator::PARAM_ISMULTI_LIMIT1;
86  public const PARAM_ISMULTI_LIMIT2 = ParamValidator::PARAM_ISMULTI_LIMIT2;
87  public const PARAM_MAX_BYTES = StringDef::PARAM_MAX_BYTES;
88  public const PARAM_MAX_CHARS = StringDef::PARAM_MAX_CHARS;
95  public const PARAM_RANGE_ENFORCE = 'api-param-range-enforce';
96 
97  // region API-specific constants for ::getAllowedParams() arrays
105  public const PARAM_HELP_MSG = 'api-param-help-msg';
106 
112  public const PARAM_HELP_MSG_APPEND = 'api-param-help-msg-append';
113 
122  public const PARAM_HELP_MSG_INFO = 'api-param-help-msg-info';
123 
129  public const PARAM_VALUE_LINKS = 'api-param-value-links';
130 
138  public const PARAM_HELP_MSG_PER_VALUE = 'api-param-help-msg-per-value';
139 
156  public const PARAM_TEMPLATE_VARS = 'param-template-vars';
157 
158  // endregion -- end of API-specific constants for ::getAllowedParams() arrays
159 
160  public const ALL_DEFAULT_STRING = '*';
161 
163  public const LIMIT_BIG1 = 500;
165  public const LIMIT_BIG2 = 5000;
167  public const LIMIT_SML1 = 50;
169  public const LIMIT_SML2 = 500;
170 
176  public const GET_VALUES_FOR_HELP = 1;
177 
179  private static $extensionInfo = null;
180 
182  private static $filterIDsCache = [];
183 
185  private static $blockMsgMap = [
186  'blockedtext' => [ 'apierror-blocked', 'blocked' ],
187  'blockedtext-partial' => [ 'apierror-blocked-partial', 'blocked' ],
188  'autoblockedtext' => [ 'apierror-autoblocked', 'autoblocked' ],
189  'systemblockedtext' => [ 'apierror-systemblocked', 'blocked' ],
190  'blockedtext-composite' => [ 'apierror-blocked', 'blocked' ],
191  ];
192 
194  private $mMainModule;
197  private $mReplicaDB = null;
201  private $mParamCache = [];
203  private $mModuleSource = false;
204 
211  public function __construct( ApiMain $mainModule, $moduleName, $modulePrefix = '' ) {
212  $this->mMainModule = $mainModule;
213  $this->mModuleName = $moduleName;
214  $this->mModulePrefix = $modulePrefix;
215 
216  if ( !$this->isMain() ) {
217  $this->setContext( $mainModule->getContext() );
218  }
219  }
220 
221  /***************************************************************************/
222  // region Methods to implement
241  abstract public function execute();
242 
249  public function getModuleManager() {
250  return null;
251  }
252 
263  public function getCustomPrinter() {
264  return null;
265  }
266 
279  protected function getExamplesMessages() {
280  return [];
281  }
282 
289  public function getHelpUrls() {
290  return [];
291  }
292 
306  protected function getAllowedParams( /* $flags = 0 */ ) {
307  // int $flags is not declared because it causes "Strict standards"
308  // warning. Most derived classes do not implement it.
309  return [];
310  }
311 
317  public function shouldCheckMaxlag() {
318  return true;
319  }
320 
326  public function isReadMode() {
327  return true;
328  }
329 
342  public function isWriteMode() {
343  return false;
344  }
345 
351  public function mustBePosted() {
352  return $this->needsToken() !== false;
353  }
354 
361  public function isDeprecated() {
362  return false;
363  }
364 
372  public function isInternal() {
373  return false;
374  }
375 
395  public function needsToken() {
396  return false;
397  }
398 
409  protected function getWebUITokenSalt( array $params ) {
410  return null;
411  }
412 
426  public function getConditionalRequestData( $condition ) {
427  return null;
428  }
429 
430  // endregion -- end of methods to implement
431 
432  /***************************************************************************/
433  // region Data access methods
440  public function getModuleName() {
441  return $this->mModuleName;
442  }
443 
448  public function getModulePrefix() {
449  return $this->mModulePrefix;
450  }
451 
456  public function getMain() {
457  return $this->mMainModule;
458  }
459 
465  public function isMain() {
466  return $this === $this->mMainModule;
467  }
468 
475  public function getParent() {
476  return $this->isMain() ? null : $this->getMain();
477  }
478 
489  public function lacksSameOriginSecurity() {
490  // Main module has this method overridden
491  // Safety - avoid infinite loop:
492  if ( $this->isMain() ) {
493  self::dieDebug( __METHOD__, 'base method was called on main module.' );
494  }
495 
496  return $this->getMain()->lacksSameOriginSecurity();
497  }
498 
505  public function getModulePath() {
506  if ( $this->isMain() ) {
507  return 'main';
508  } elseif ( $this->getParent()->isMain() ) {
509  return $this->getModuleName();
510  } else {
511  return $this->getParent()->getModulePath() . '+' . $this->getModuleName();
512  }
513  }
514 
523  public function getModuleFromPath( $path ) {
524  $module = $this->getMain();
525  if ( $path === 'main' ) {
526  return $module;
527  }
528 
529  $parts = explode( '+', $path );
530  if ( count( $parts ) === 1 ) {
531  // In case the '+' was typed into URL, it resolves as a space
532  $parts = explode( ' ', $path );
533  }
534 
535  $count = count( $parts );
536  for ( $i = 0; $i < $count; $i++ ) {
537  $parent = $module;
538  $manager = $parent->getModuleManager();
539  if ( $manager === null ) {
540  $errorPath = implode( '+', array_slice( $parts, 0, $i ) );
541  $this->dieWithError( [ 'apierror-badmodule-nosubmodules', $errorPath ], 'badmodule' );
542  }
543  $module = $manager->getModule( $parts[$i] );
544 
545  if ( $module === null ) {
546  $errorPath = $i ? implode( '+', array_slice( $parts, 0, $i ) ) : $parent->getModuleName();
547  $this->dieWithError(
548  [ 'apierror-badmodule-badsubmodule', $errorPath, wfEscapeWikiText( $parts[$i] ) ],
549  'badmodule'
550  );
551  }
552  }
553 
554  return $module;
555  }
556 
561  public function getResult() {
562  // Main module has getResult() method overridden
563  // Safety - avoid infinite loop:
564  if ( $this->isMain() ) {
565  self::dieDebug( __METHOD__, 'base method was called on main module. ' );
566  }
567 
568  return $this->getMain()->getResult();
569  }
570 
575  public function getErrorFormatter() {
576  // Main module has getErrorFormatter() method overridden
577  // Safety - avoid infinite loop:
578  if ( $this->isMain() ) {
579  self::dieDebug( __METHOD__, 'base method was called on main module. ' );
580  }
581 
582  return $this->getMain()->getErrorFormatter();
583  }
584 
590  protected function getDB() {
591  if ( !isset( $this->mReplicaDB ) ) {
592  $this->mReplicaDB = wfGetDB( DB_REPLICA, 'api' );
593  }
594 
595  return $this->mReplicaDB;
596  }
597 
601  public function getContinuationManager() {
602  // Main module has getContinuationManager() method overridden
603  // Safety - avoid infinite loop:
604  if ( $this->isMain() ) {
605  self::dieDebug( __METHOD__, 'base method was called on main module. ' );
606  }
607 
608  return $this->getMain()->getContinuationManager();
609  }
610 
614  public function setContinuationManager( ApiContinuationManager $manager = null ) {
615  // Main module has setContinuationManager() method overridden
616  // Safety - avoid infinite loop:
617  if ( $this->isMain() ) {
618  self::dieDebug( __METHOD__, 'base method was called on main module. ' );
619  }
620 
621  $this->getMain()->setContinuationManager( $manager );
622  }
623 
630  protected function getPermissionManager(): PermissionManager {
631  return MediaWikiServices::getInstance()->getPermissionManager();
632  }
633 
642  return MediaWikiServices::getInstance()->getGroupPermissionsLookup();
643  }
644 
651  protected function getHookContainer() {
652  if ( !$this->hookContainer ) {
653  $this->hookContainer = MediaWikiServices::getInstance()->getHookContainer();
654  }
655  return $this->hookContainer;
656  }
657 
666  protected function getHookRunner() {
667  if ( !$this->hookRunner ) {
668  $this->hookRunner = new ApiHookRunner( $this->getHookContainer() );
669  }
670  return $this->hookRunner;
671  }
672 
673  // endregion -- end of data access methods
674 
675  /***************************************************************************/
676  // region Parameter handling
687  public function dynamicParameterDocumentation() {
688  return null;
689  }
690 
698  public function encodeParamName( $paramName ) {
699  if ( is_array( $paramName ) ) {
700  return array_map( function ( $name ) {
701  return $this->mModulePrefix . $name;
702  }, $paramName );
703  } else {
704  return $this->mModulePrefix . $paramName;
705  }
706  }
707 
720  public function extractRequestParams( $options = [] ) {
721  if ( is_bool( $options ) ) {
722  $options = [ 'parseLimit' => $options ];
723  }
724  $options += [
725  'parseLimit' => true,
726  'safeMode' => false,
727  ];
728 
729  $parseLimit = (bool)$options['parseLimit'];
730  $cacheKey = (int)$parseLimit;
731 
732  // Cache parameters, for performance and to avoid T26564.
733  if ( !isset( $this->mParamCache[$cacheKey] ) ) {
734  $params = $this->getFinalParams() ?: [];
735  $results = [];
736  $warned = [];
737 
738  // Process all non-templates and save templates for secondary
739  // processing.
740  $toProcess = [];
741  foreach ( $params as $paramName => $paramSettings ) {
742  if ( isset( $paramSettings[self::PARAM_TEMPLATE_VARS] ) ) {
743  $toProcess[] = [ $paramName, $paramSettings[self::PARAM_TEMPLATE_VARS], $paramSettings ];
744  } else {
745  try {
746  $results[$paramName] = $this->getParameterFromSettings(
747  $paramName, $paramSettings, $parseLimit
748  );
749  } catch ( ApiUsageException $ex ) {
750  $results[$paramName] = $ex;
751  }
752  }
753  }
754 
755  // Now process all the templates by successively replacing the
756  // placeholders with all client-supplied values.
757  // This bit duplicates JavaScript logic in
758  // ApiSandbox.PageLayout.prototype.updateTemplatedParams().
759  // If you update this, see if that needs updating too.
760  while ( $toProcess ) {
761  list( $name, $targets, $settings ) = array_shift( $toProcess );
762 
763  foreach ( $targets as $placeholder => $target ) {
764  if ( !array_key_exists( $target, $results ) ) {
765  // The target wasn't processed yet, try the next one.
766  // If all hit this case, the parameter has no expansions.
767  continue;
768  }
769  if ( !is_array( $results[$target] ) || !$results[$target] ) {
770  // The target was processed but has no (valid) values.
771  // That means it has no expansions.
772  break;
773  }
774 
775  // Expand this target in the name and all other targets,
776  // then requeue if there are more targets left or put in
777  // $results if all are done.
778  unset( $targets[$placeholder] );
779  $placeholder = '{' . $placeholder . '}';
780  // @phan-suppress-next-line PhanTypeNoAccessiblePropertiesForeach
781  foreach ( $results[$target] as $value ) {
782  if ( !preg_match( '/^[^{}]*$/', $value ) ) {
783  // Skip values that make invalid parameter names.
784  $encTargetName = $this->encodeParamName( $target );
785  if ( !isset( $warned[$encTargetName][$value] ) ) {
786  $warned[$encTargetName][$value] = true;
787  $this->addWarning( [
788  'apiwarn-ignoring-invalid-templated-value',
789  wfEscapeWikiText( $encTargetName ),
790  wfEscapeWikiText( $value ),
791  ] );
792  }
793  continue;
794  }
795 
796  $newName = str_replace( $placeholder, $value, $name );
797  if ( !$targets ) {
798  try {
799  $results[$newName] = $this->getParameterFromSettings(
800  $newName,
801  $settings,
802  $parseLimit
803  );
804  } catch ( ApiUsageException $ex ) {
805  $results[$newName] = $ex;
806  }
807  } else {
808  $newTargets = [];
809  foreach ( $targets as $k => $v ) {
810  $newTargets[$k] = str_replace( $placeholder, $value, $v );
811  }
812  $toProcess[] = [ $newName, $newTargets, $settings ];
813  }
814  }
815  break;
816  }
817  }
818 
819  $this->mParamCache[$cacheKey] = $results;
820  }
821 
822  $ret = $this->mParamCache[$cacheKey];
823  if ( !$options['safeMode'] ) {
824  foreach ( $ret as $v ) {
825  if ( $v instanceof ApiUsageException ) {
826  throw $v;
827  }
828  }
829  }
830 
831  return $this->mParamCache[$cacheKey];
832  }
833 
840  protected function getParameter( $paramName, $parseLimit = true ) {
841  $ret = $this->extractRequestParams( [
842  'parseLimit' => $parseLimit,
843  'safeMode' => true,
844  ] )[$paramName];
845  if ( $ret instanceof ApiUsageException ) {
846  throw $ret;
847  }
848  return $ret;
849  }
850 
857  public function requireOnlyOneParameter( $params, ...$required ) {
858  $intersection = array_intersect( array_keys( array_filter( $params,
859  [ $this, 'parameterNotEmpty' ] ) ), $required );
860 
861  if ( count( $intersection ) > 1 ) {
862  $this->dieWithError( [
863  'apierror-invalidparammix',
864  Message::listParam( array_map(
865  function ( $p ) {
866  return '<var>' . $this->encodeParamName( $p ) . '</var>';
867  },
868  array_values( $intersection )
869  ) ),
870  count( $intersection ),
871  ] );
872  } elseif ( count( $intersection ) == 0 ) {
873  $this->dieWithError( [
874  'apierror-missingparam-one-of',
875  Message::listParam( array_map(
876  function ( $p ) {
877  return '<var>' . $this->encodeParamName( $p ) . '</var>';
878  },
879  $required
880  ) ),
881  count( $required ),
882  ], 'missingparam' );
883  }
884  }
885 
892  public function requireMaxOneParameter( $params, ...$required ) {
893  $intersection = array_intersect( array_keys( array_filter( $params,
894  [ $this, 'parameterNotEmpty' ] ) ), $required );
895 
896  if ( count( $intersection ) > 1 ) {
897  $this->dieWithError( [
898  'apierror-invalidparammix',
899  Message::listParam( array_map(
900  function ( $p ) {
901  return '<var>' . $this->encodeParamName( $p ) . '</var>';
902  },
903  array_values( $intersection )
904  ) ),
905  count( $intersection ),
906  ] );
907  }
908  }
909 
917  public function requireAtLeastOneParameter( $params, ...$required ) {
918  $intersection = array_intersect(
919  array_keys( array_filter( $params, [ $this, 'parameterNotEmpty' ] ) ),
920  $required
921  );
922 
923  if ( count( $intersection ) == 0 ) {
924  $this->dieWithError( [
925  'apierror-missingparam-at-least-one-of',
926  Message::listParam( array_map(
927  function ( $p ) {
928  return '<var>' . $this->encodeParamName( $p ) . '</var>';
929  },
930  $required
931  ) ),
932  count( $required ),
933  ], 'missingparam' );
934  }
935  }
936 
944  public function requirePostedParameters( $params, $prefix = 'prefix' ) {
945  // Skip if $wgDebugAPI is set or we're in internal mode
946  if ( $this->getConfig()->get( 'DebugAPI' ) || $this->getMain()->isInternalMode() ) {
947  return;
948  }
949 
950  $queryValues = $this->getRequest()->getQueryValuesOnly();
951  $badParams = [];
952  foreach ( $params as $param ) {
953  if ( $prefix !== 'noprefix' ) {
954  $param = $this->encodeParamName( $param );
955  }
956  if ( array_key_exists( $param, $queryValues ) ) {
957  $badParams[] = $param;
958  }
959  }
960 
961  if ( $badParams ) {
962  $this->dieWithError(
963  [ 'apierror-mustpostparams', implode( ', ', $badParams ), count( $badParams ) ]
964  );
965  }
966  }
967 
974  private function parameterNotEmpty( $x ) {
975  return $x !== null && $x !== false;
976  }
977 
989  public function getTitleOrPageId( $params, $load = false ) {
990  $this->requireOnlyOneParameter( $params, 'title', 'pageid' );
991 
992  $pageObj = null;
993  if ( isset( $params['title'] ) ) {
994  $titleObj = Title::newFromText( $params['title'] );
995  if ( !$titleObj || $titleObj->isExternal() ) {
996  $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['title'] ) ] );
997  }
998  if ( !$titleObj->canExist() ) {
999  $this->dieWithError( 'apierror-pagecannotexist' );
1000  }
1001  $pageObj = WikiPage::factory( $titleObj );
1002  if ( $load !== false ) {
1003  $pageObj->loadPageData( $load );
1004  }
1005  } elseif ( isset( $params['pageid'] ) ) {
1006  if ( $load === false ) {
1007  $load = 'fromdb';
1008  }
1009  $pageObj = WikiPage::newFromID( $params['pageid'], $load );
1010  if ( !$pageObj ) {
1011  $this->dieWithError( [ 'apierror-nosuchpageid', $params['pageid'] ] );
1012  }
1013  }
1014 
1015  return $pageObj;
1016  }
1017 
1026  public function getTitleFromTitleOrPageId( $params ) {
1027  $this->requireOnlyOneParameter( $params, 'title', 'pageid' );
1028 
1029  $titleObj = null;
1030  if ( isset( $params['title'] ) ) {
1031  $titleObj = Title::newFromText( $params['title'] );
1032  if ( !$titleObj || $titleObj->isExternal() ) {
1033  $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['title'] ) ] );
1034  }
1035  return $titleObj;
1036  } elseif ( isset( $params['pageid'] ) ) {
1037  $titleObj = Title::newFromID( $params['pageid'] );
1038  if ( !$titleObj ) {
1039  $this->dieWithError( [ 'apierror-nosuchpageid', $params['pageid'] ] );
1040  }
1041  }
1042 
1043  return $titleObj;
1044  }
1045 
1055  protected function getParameterFromSettings( $name, $settings, $parseLimit ) {
1056  $validator = $this->getMain()->getParamValidator();
1057  $value = $validator->getValue( $this, $name, $settings, [
1058  'parse-limit' => $parseLimit,
1059  'raw' => ( $settings[ParamValidator::PARAM_TYPE] ?? '' ) === 'raw',
1060  ] );
1061 
1062  // @todo Deprecate and remove this, if possible.
1063  if ( $parseLimit && isset( $settings[ParamValidator::PARAM_TYPE] ) &&
1064  $settings[ParamValidator::PARAM_TYPE] === 'limit' &&
1065  $this->getMain()->getVal( $this->encodeParamName( $name ) ) === 'max'
1066  ) {
1067  $this->getResult()->addParsedLimit( $this->getModuleName(), $value );
1068  }
1069 
1070  return $value;
1071  }
1072 
1082  public function handleParamNormalization( $paramName, $value, $rawValue ) {
1083  $this->addWarning( [ 'apiwarn-badutf8', $paramName ] );
1084  }
1085 
1095  final public function validateToken( $token, array $params ) {
1096  $tokenType = $this->needsToken();
1098  if ( !isset( $salts[$tokenType] ) ) {
1099  throw new MWException(
1100  "Module '{$this->getModuleName()}' tried to use token type '$tokenType' " .
1101  'without registering it'
1102  );
1103  }
1104 
1105  $tokenObj = ApiQueryTokens::getToken(
1106  $this->getUser(), $this->getRequest()->getSession(), $salts[$tokenType]
1107  );
1108  if ( $tokenObj->match( $token ) ) {
1109  return true;
1110  }
1111 
1112  $webUiSalt = $this->getWebUITokenSalt( $params );
1113  if ( $webUiSalt !== null && $this->getUser()->matchEditToken(
1114  $token,
1115  $webUiSalt,
1116  $this->getRequest()
1117  ) ) {
1118  return true;
1119  }
1120 
1121  return false;
1122  }
1123 
1124  // endregion -- end of parameter handling
1125 
1126  /***************************************************************************/
1127  // region Utility methods
1136  public function getWatchlistUser( $params ) {
1137  if ( $params['owner'] !== null && $params['token'] !== null ) {
1138  $user = User::newFromName( $params['owner'], false );
1139  if ( !( $user && $user->getId() ) ) {
1140  $this->dieWithError(
1141  [ 'nosuchusershort', wfEscapeWikiText( $params['owner'] ) ], 'bad_wlowner'
1142  );
1143  }
1144  $token = $user->getOption( 'watchlisttoken' );
1145  if ( $token == '' || !hash_equals( $token, $params['token'] ) ) {
1146  $this->dieWithError( 'apierror-bad-watchlist-token', 'bad_wltoken' );
1147  }
1148  } else {
1149  if ( !$this->getUser()->isRegistered() ) {
1150  $this->dieWithError( 'watchlistanontext', 'notloggedin' );
1151  }
1152  $this->checkUserRightsAny( 'viewmywatchlist' );
1153  $user = $this->getUser();
1154  }
1155 
1156  return $user;
1157  }
1158 
1171  public static function makeMessage( $msg, IContextSource $context, array $params = null ) {
1172  if ( is_string( $msg ) ) {
1173  $msg = wfMessage( $msg );
1174  } elseif ( is_array( $msg ) ) {
1175  $msg = wfMessage( ...$msg );
1176  }
1177  if ( !$msg instanceof Message ) {
1178  return null;
1179  }
1180 
1181  $msg->setContext( $context );
1182  if ( $params ) {
1183  $msg->params( $params );
1184  }
1185 
1186  return $msg;
1187  }
1188 
1196  public function errorArrayToStatus( array $errors, User $user = null ) {
1197  if ( $user === null ) {
1198  $user = $this->getUser();
1199  }
1200 
1201  $status = Status::newGood();
1202  foreach ( $errors as $error ) {
1203  if ( !is_array( $error ) ) {
1204  $error = [ $error ];
1205  }
1206  if ( is_string( $error[0] ) && isset( self::$blockMsgMap[$error[0]] ) && $user->getBlock() ) {
1207  list( $msg, $code ) = self::$blockMsgMap[$error[0]];
1208  $status->fatal( ApiMessage::create( $msg, $code,
1209  [ 'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
1210  ) );
1211  } else {
1212  $status->fatal( ...$error );
1213  }
1214  }
1215  return $status;
1216  }
1217 
1224  public function addBlockInfoToStatus( StatusValue $status, User $user = null ) {
1225  if ( $user === null ) {
1226  $user = $this->getUser();
1227  }
1228 
1229  foreach ( self::$blockMsgMap as $msg => list( $apiMsg, $code ) ) {
1230  if ( $status->hasMessage( $msg ) && $user->getBlock() ) {
1231  $status->replaceMessage( $msg, ApiMessage::create( $apiMsg, $code,
1232  [ 'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
1233  ) );
1234  }
1235  }
1236  }
1237 
1242  protected function useTransactionalTimeLimit() {
1243  if ( $this->getRequest()->wasPosted() ) {
1245  }
1246  }
1247 
1256  protected function filterIDs( $fields, array $ids ) {
1257  $min = INF;
1258  $max = 0;
1259  foreach ( $fields as list( $table, $field ) ) {
1260  if ( isset( self::$filterIDsCache[$table][$field] ) ) {
1261  $row = self::$filterIDsCache[$table][$field];
1262  } else {
1263  $row = $this->getDB()->selectRow(
1264  $table,
1265  [
1266  'min_id' => "MIN($field)",
1267  'max_id' => "MAX($field)",
1268  ],
1269  '',
1270  __METHOD__
1271  );
1272  self::$filterIDsCache[$table][$field] = $row;
1273  }
1274  $min = min( $min, $row->min_id );
1275  $max = max( $max, $row->max_id );
1276  }
1277  return array_filter( $ids, static function ( $id ) use ( $min, $max ) {
1278  return ( is_int( $id ) && $id >= 0 || ctype_digit( $id ) )
1279  && $id >= $min && $id <= $max;
1280  } );
1281  }
1282 
1283  // endregion -- end of utility methods
1284 
1285  /***************************************************************************/
1286  // region Warning and error reporting
1303  public function addWarning( $msg, $code = null, $data = null ) {
1304  $this->getErrorFormatter()->addWarning( $this->getModulePath(), $msg, $code, $data );
1305  }
1306 
1317  public function addDeprecation( $msg, $feature, $data = [] ) {
1318  $data = (array)$data;
1319  if ( $feature !== null ) {
1320  $data['feature'] = $feature;
1321  $this->logFeatureUsage( $feature );
1322  }
1323  $this->addWarning( $msg, 'deprecation', $data );
1324 
1325  // No real need to deduplicate here, ApiErrorFormatter does that for
1326  // us (assuming the hook is deterministic).
1327  $msgs = [ $this->msg( 'api-usage-mailinglist-ref' ) ];
1328  $this->getHookRunner()->onApiDeprecationHelp( $msgs );
1329  if ( count( $msgs ) > 1 ) {
1330  $key = '$' . implode( ' $', range( 1, count( $msgs ) ) );
1331  $msg = ( new RawMessage( $key ) )->params( $msgs );
1332  } else {
1333  $msg = reset( $msgs );
1334  }
1335  $this->getMain()->addWarning( $msg, 'deprecation-help' );
1336  }
1337 
1350  public function addError( $msg, $code = null, $data = null ) {
1351  $this->getErrorFormatter()->addError( $this->getModulePath(), $msg, $code, $data );
1352  }
1353 
1363  public function addMessagesFromStatus(
1364  StatusValue $status, $types = [ 'warning', 'error' ], array $filter = []
1365  ) {
1366  $this->getErrorFormatter()->addMessagesFromStatus(
1367  $this->getModulePath(), $status, $types, $filter
1368  );
1369  }
1370 
1384  public function dieWithError( $msg, $code = null, $data = null, $httpCode = null ) {
1385  throw ApiUsageException::newWithMessage( $this, $msg, $code, $data, $httpCode );
1386  }
1387 
1396  public function dieWithException( Throwable $exception, array $options = [] ) {
1397  $this->dieWithError(
1398  // @phan-suppress-next-line PhanTypeMismatchArgument
1399  $this->getErrorFormatter()->getMessageFromException( $exception, $options )
1400  );
1401  }
1402 
1411  public function dieBlocked( AbstractBlock $block ) {
1412  // Die using the appropriate message depending on block type
1413  if ( $block->getType() == DatabaseBlock::TYPE_AUTO ) {
1414  $this->dieWithError(
1415  'apierror-autoblocked',
1416  'autoblocked',
1417  [ 'blockinfo' => $this->getBlockDetails( $block ) ]
1418  );
1419  } elseif ( !$block->isSitewide() ) {
1420  $this->dieWithError(
1421  'apierror-blocked-partial',
1422  'blocked',
1423  [ 'blockinfo' => $this->getBlockDetails( $block ) ]
1424  );
1425  } else {
1426  $this->dieWithError(
1427  'apierror-blocked',
1428  'blocked',
1429  [ 'blockinfo' => $this->getBlockDetails( $block ) ]
1430  );
1431  }
1432  }
1433 
1442  public function dieStatus( StatusValue $status ) {
1443  if ( $status->isGood() ) {
1444  throw new MWException( 'Successful status passed to ApiBase::dieStatus' );
1445  }
1446 
1447  // ApiUsageException needs a fatal status, but this method has
1448  // historically accepted any non-good status. Convert it if necessary.
1449  $status->setOK( false );
1450  if ( !$status->getErrorsByType( 'error' ) ) {
1451  $newStatus = Status::newGood();
1452  foreach ( $status->getErrorsByType( 'warning' ) as $err ) {
1453  $newStatus->fatal( $err['message'], ...$err['params'] );
1454  }
1455  if ( !$newStatus->getErrorsByType( 'error' ) ) {
1456  $newStatus->fatal( 'unknownerror-nocode' );
1457  }
1458  $status = $newStatus;
1459  }
1460 
1461  $this->addBlockInfoToStatus( $status );
1462  throw new ApiUsageException( $this, $status );
1463  }
1464 
1470  public function dieReadOnly() {
1471  $this->dieWithError(
1472  'apierror-readonly',
1473  'readonly',
1474  [ 'readonlyreason' => wfReadOnlyReason() ]
1475  );
1476  }
1477 
1486  public function checkUserRightsAny( $rights, $user = null ) {
1487  $authority = $this->getAuthority();
1488  if ( $user !== null ) {
1489  wfDeprecatedMsg( __METHOD__ . ': $user parameter is deprecated', '1.36' );
1490  $authority = $user;
1491  }
1492  $rights = (array)$rights;
1493  if ( !$authority->isAllowedAny( ...$rights ) ) {
1494  $this->dieWithError( [ 'apierror-permissiondenied', $this->msg( "action-{$rights[0]}" ) ] );
1495  }
1496  }
1497 
1512  public function checkTitleUserPermissions(
1513  $pageIdentity,
1514  $actions,
1515  array $options = []
1516  ) {
1517  if ( !$pageIdentity instanceof PageIdentity ) {
1518  wfDeprecatedMsg( __METHOD__ . ': passing LinkTarget as $pageIdentity parameter is deprecated',
1519  '1.36' );
1520  $pageIdentity = Title::castFromLinkTarget( $pageIdentity );
1521  }
1522  $status = new PermissionStatus();
1523  foreach ( (array)$actions as $action ) {
1524  if ( $this->isWriteMode() ) {
1525  $this->getAuthority()->authorizeWrite( $action, $pageIdentity, $status );
1526  } else {
1527  $this->getAuthority()->authorizeRead( $action, $pageIdentity, $status );
1528  }
1529  }
1530  if ( !$status->isGood() ) {
1531  if ( !empty( $options['autoblock'] ) ) {
1532  $this->getUser()->spreadAnyEditBlock();
1533  }
1534  $this->dieStatus( $status );
1535  }
1536  }
1537 
1549  public function dieWithErrorOrDebug( $msg, $code = null, $data = null, $httpCode = null ) {
1550  if ( $this->getConfig()->get( 'DebugAPI' ) !== true ) {
1551  $this->dieWithError( $msg, $code, $data, $httpCode );
1552  } else {
1553  $this->addWarning( $msg, $code, $data );
1554  }
1555  }
1556 
1567  protected function dieContinueUsageIf( $condition ) {
1568  if ( $condition ) {
1569  $this->dieWithError( 'apierror-badcontinue' );
1570  }
1571  }
1572 
1579  protected static function dieDebug( $method, $message ) {
1580  throw new MWException( "Internal error in $method: $message" );
1581  }
1582 
1589  public function logFeatureUsage( $feature ) {
1590  static $loggedFeatures = [];
1591 
1592  // Only log each feature once per request. We can get multiple calls from calls to
1593  // extractRequestParams() with different values for 'parseLimit', for example.
1594  if ( isset( $loggedFeatures[$feature] ) ) {
1595  return;
1596  }
1597  $loggedFeatures[$feature] = true;
1598 
1599  $request = $this->getRequest();
1600  $ctx = [
1601  'feature' => $feature,
1602  // Spaces to underscores in 'username' for historical reasons.
1603  'username' => str_replace( ' ', '_', $this->getUser()->getName() ),
1604  'clientip' => $request->getIP(),
1605  'referer' => (string)$request->getHeader( 'Referer' ),
1606  'agent' => $this->getMain()->getUserAgent(),
1607  ];
1608 
1609  // Text string is deprecated. Remove (or replace with just $feature) in MW 1.34.
1610  $s = '"' . addslashes( $ctx['feature'] ) . '"' .
1611  ' "' . wfUrlencode( $ctx['username'] ) . '"' .
1612  ' "' . $ctx['clientip'] . '"' .
1613  ' "' . addslashes( $ctx['referer'] ) . '"' .
1614  ' "' . addslashes( $ctx['agent'] ) . '"';
1615 
1616  wfDebugLog( 'api-feature-usage', $s, 'private', $ctx );
1617  }
1618 
1619  // endregion -- end of warning and error reporting
1620 
1621  /***************************************************************************/
1622  // region Help message generation
1635  protected function getSummaryMessage() {
1636  return "apihelp-{$this->getModulePath()}-summary";
1637  }
1638 
1649  protected function getExtendedDescription() {
1650  return [ [
1651  "apihelp-{$this->getModulePath()}-extended-description",
1652  'api-help-no-extended-description',
1653  ] ];
1654  }
1655 
1663  public function getFinalSummary() {
1664  $msg = self::makeMessage( $this->getSummaryMessage(), $this->getContext(), [
1665  $this->getModulePrefix(),
1666  $this->getModuleName(),
1667  $this->getModulePath(),
1668  ] );
1669  return $msg;
1670  }
1671 
1679  public function getFinalDescription() {
1680  $summary = self::makeMessage( $this->getSummaryMessage(), $this->getContext(), [
1681  $this->getModulePrefix(),
1682  $this->getModuleName(),
1683  $this->getModulePath(),
1684  ] );
1685  $extendedDescription = self::makeMessage(
1686  $this->getExtendedDescription(), $this->getContext(), [
1687  $this->getModulePrefix(),
1688  $this->getModuleName(),
1689  $this->getModulePath(),
1690  ]
1691  );
1692 
1693  $msgs = [ $summary, $extendedDescription ];
1694 
1695  $this->getHookRunner()->onAPIGetDescriptionMessages( $this, $msgs );
1696 
1697  return $msgs;
1698  }
1699 
1708  public function getFinalParams( $flags = 0 ) {
1709  // @phan-suppress-next-line PhanParamTooMany
1710  $params = $this->getAllowedParams( $flags );
1711  if ( !$params ) {
1712  $params = [];
1713  }
1714 
1715  if ( $this->needsToken() ) {
1716  $params['token'] = [
1717  self::PARAM_TYPE => 'string',
1718  self::PARAM_REQUIRED => true,
1719  self::PARAM_SENSITIVE => true,
1720  self::PARAM_HELP_MSG => [
1721  'api-help-param-token',
1722  $this->needsToken(),
1723  ],
1724  ] + ( $params['token'] ?? [] );
1725  }
1726 
1727  $this->getHookRunner()->onAPIGetAllowedParams( $this, $params, $flags );
1728 
1729  return $params;
1730  }
1731 
1739  public function getFinalParamDescription() {
1740  $prefix = $this->getModulePrefix();
1741  $name = $this->getModuleName();
1742  $path = $this->getModulePath();
1743 
1744  $params = $this->getFinalParams( self::GET_VALUES_FOR_HELP );
1745  $msgs = [];
1746  foreach ( $params as $param => $settings ) {
1747  if ( !is_array( $settings ) ) {
1748  $settings = [];
1749  }
1750 
1751  if ( isset( $settings[self::PARAM_HELP_MSG] ) ) {
1752  $msg = $settings[self::PARAM_HELP_MSG];
1753  } else {
1754  $msg = $this->msg( "apihelp-{$path}-param-{$param}" );
1755  }
1756  $msg = self::makeMessage( $msg, $this->getContext(),
1757  [ $prefix, $param, $name, $path ] );
1758  if ( !$msg ) {
1759  self::dieDebug( __METHOD__,
1760  'Value in ApiBase::PARAM_HELP_MSG is not valid' );
1761  }
1762  $msgs[$param] = [ $msg ];
1763 
1764  if ( isset( $settings[self::PARAM_TYPE] ) &&
1765  $settings[self::PARAM_TYPE] === 'submodule'
1766  ) {
1767  if ( isset( $settings[self::PARAM_SUBMODULE_MAP] ) ) {
1768  $map = $settings[self::PARAM_SUBMODULE_MAP];
1769  } else {
1770  $prefix = $this->isMain() ? '' : ( $this->getModulePath() . '+' );
1771  $map = [];
1772  foreach ( $this->getModuleManager()->getNames( $param ) as $submoduleName ) {
1773  $map[$submoduleName] = $prefix . $submoduleName;
1774  }
1775  }
1776 
1777  $submodules = [];
1778  $submoduleFlags = []; // for sorting: higher flags are sorted later
1779  $submoduleNames = []; // for sorting: lexicographical, ascending
1780  foreach ( $map as $v => $m ) {
1781  $isDeprecated = false;
1782  $isInternal = false;
1783  $summary = null;
1784  try {
1785  $submod = $this->getModuleFromPath( $m );
1786  if ( $submod ) {
1787  $summary = $submod->getFinalSummary();
1788  $isDeprecated = $submod->isDeprecated();
1789  $isInternal = $submod->isInternal();
1790  }
1791  } catch ( ApiUsageException $ex ) {
1792  // Ignore
1793  }
1794  if ( $summary ) {
1795  $key = $summary->getKey();
1796  $params = $summary->getParams();
1797  } else {
1798  $key = 'api-help-undocumented-module';
1799  $params = [ $m ];
1800  }
1801  $m = new ApiHelpParamValueMessage(
1802  "[[Special:ApiHelp/$m|$v]]",
1803  $key,
1804  $params,
1805  $isDeprecated,
1806  $isInternal
1807  );
1808  $submodules[] = $m->setContext( $this->getContext() );
1809  $submoduleFlags[] = ( $isDeprecated ? 1 : 0 ) | ( $isInternal ? 2 : 0 );
1810  $submoduleNames[] = $v;
1811  }
1812  // sort $submodules by $submoduleFlags and $submoduleNames
1813  array_multisort( $submoduleFlags, $submoduleNames, $submodules );
1814  $msgs[$param] = array_merge( $msgs[$param], $submodules );
1815  } elseif ( isset( $settings[self::PARAM_HELP_MSG_PER_VALUE] ) ) {
1816  if ( !is_array( $settings[self::PARAM_HELP_MSG_PER_VALUE] ) ) {
1817  self::dieDebug( __METHOD__,
1818  'ApiBase::PARAM_HELP_MSG_PER_VALUE is not valid' );
1819  }
1820  if ( !is_array( $settings[self::PARAM_TYPE] ) ) {
1821  self::dieDebug( __METHOD__,
1822  'ApiBase::PARAM_HELP_MSG_PER_VALUE may only be used when ' .
1823  'ApiBase::PARAM_TYPE is an array' );
1824  }
1825 
1826  $valueMsgs = $settings[self::PARAM_HELP_MSG_PER_VALUE];
1827  $deprecatedValues = $settings[self::PARAM_DEPRECATED_VALUES] ?? [];
1828 
1829  foreach ( $settings[self::PARAM_TYPE] as $value ) {
1830  if ( isset( $valueMsgs[$value] ) ) {
1831  $msg = $valueMsgs[$value];
1832  } else {
1833  $msg = "apihelp-{$path}-paramvalue-{$param}-{$value}";
1834  }
1835  $m = self::makeMessage( $msg, $this->getContext(),
1836  [ $prefix, $param, $name, $path, $value ] );
1837  if ( $m ) {
1838  $m = new ApiHelpParamValueMessage(
1839  $value,
1840  // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal
1841  [ $m->getKey(), 'api-help-param-no-description' ],
1842  $m->getParams(),
1843  isset( $deprecatedValues[$value] )
1844  );
1845  $msgs[$param][] = $m->setContext( $this->getContext() );
1846  } else {
1847  self::dieDebug( __METHOD__,
1848  "Value in ApiBase::PARAM_HELP_MSG_PER_VALUE for $value is not valid" );
1849  }
1850  }
1851  }
1852 
1853  if ( isset( $settings[self::PARAM_HELP_MSG_APPEND] ) ) {
1854  if ( !is_array( $settings[self::PARAM_HELP_MSG_APPEND] ) ) {
1855  self::dieDebug( __METHOD__,
1856  'Value for ApiBase::PARAM_HELP_MSG_APPEND is not an array' );
1857  }
1858  foreach ( $settings[self::PARAM_HELP_MSG_APPEND] as $m ) {
1859  $m = self::makeMessage( $m, $this->getContext(),
1860  [ $prefix, $param, $name, $path ] );
1861  if ( $m ) {
1862  $msgs[$param][] = $m;
1863  } else {
1864  self::dieDebug( __METHOD__,
1865  'Value in ApiBase::PARAM_HELP_MSG_APPEND is not valid' );
1866  }
1867  }
1868  }
1869  }
1870 
1871  $this->getHookRunner()->onAPIGetParamDescriptionMessages( $this, $msgs );
1872 
1873  return $msgs;
1874  }
1875 
1885  protected function getHelpFlags() {
1886  $flags = [];
1887 
1888  if ( $this->isDeprecated() ) {
1889  $flags[] = 'deprecated';
1890  }
1891  if ( $this->isInternal() ) {
1892  $flags[] = 'internal';
1893  }
1894  if ( $this->isReadMode() ) {
1895  $flags[] = 'readrights';
1896  }
1897  if ( $this->isWriteMode() ) {
1898  $flags[] = 'writerights';
1899  }
1900  if ( $this->mustBePosted() ) {
1901  $flags[] = 'mustbeposted';
1902  }
1903 
1904  return $flags;
1905  }
1906 
1918  protected function getModuleSourceInfo() {
1919  global $IP;
1920 
1921  if ( $this->mModuleSource !== false ) {
1922  return $this->mModuleSource;
1923  }
1924 
1925  // First, try to find where the module comes from...
1926  $rClass = new ReflectionClass( $this );
1927  $path = $rClass->getFileName();
1928  if ( !$path ) {
1929  // No path known?
1930  $this->mModuleSource = null;
1931  return null;
1932  }
1933  $path = realpath( $path ) ?: $path;
1934 
1935  // Build map of extension directories to extension info
1936  if ( self::$extensionInfo === null ) {
1937  $extDir = $this->getConfig()->get( 'ExtensionDirectory' );
1938  self::$extensionInfo = [
1939  realpath( __DIR__ ) ?: __DIR__ => [
1940  'path' => $IP,
1941  'name' => 'MediaWiki',
1942  'license-name' => 'GPL-2.0-or-later',
1943  ],
1944  realpath( "$IP/extensions" ) ?: "$IP/extensions" => null,
1945  realpath( $extDir ) ?: $extDir => null,
1946  ];
1947  $keep = [
1948  'path' => null,
1949  'name' => null,
1950  'namemsg' => null,
1951  'license-name' => null,
1952  ];
1954  foreach ( $credits as $group ) {
1955  foreach ( $group as $ext ) {
1956  if ( !isset( $ext['path'] ) || !isset( $ext['name'] ) ) {
1957  // This shouldn't happen, but does anyway.
1958  continue;
1959  }
1960 
1961  $extpath = $ext['path'];
1962  if ( !is_dir( $extpath ) ) {
1963  $extpath = dirname( $extpath );
1964  }
1965  self::$extensionInfo[realpath( $extpath ) ?: $extpath] =
1966  array_intersect_key( $ext, $keep );
1967  }
1968  }
1969  }
1970 
1971  // Now traverse parent directories until we find a match or run out of
1972  // parents.
1973  do {
1974  if ( array_key_exists( $path, self::$extensionInfo ) ) {
1975  // Found it!
1976  $this->mModuleSource = self::$extensionInfo[$path];
1977  return $this->mModuleSource;
1978  }
1979 
1980  $oldpath = $path;
1981  $path = dirname( $path );
1982  } while ( $path !== $oldpath );
1983 
1984  // No idea what extension this might be.
1985  $this->mModuleSource = null;
1986  return null;
1987  }
1988 
2001  public function modifyHelp( array &$help, array $options, array &$tocData ) {
2002  }
2003 
2004  // endregion -- end of help message generation
2005 
2006  /***************************************************************************/
2007  // region Deprecated methods
2018  protected function explodeMultiValue( $value, $limit ) {
2019  wfDeprecated( __METHOD__, '1.35' );
2020  return ParamValidator::explodeMultiValue( $value, $limit );
2021  }
2022 
2041  protected function parseMultiValue( $valueName, $value, $allowMultiple, $allowedValues,
2042  $allSpecifier = null, $limit1 = null, $limit2 = null
2043  ) {
2044  wfDeprecated( __METHOD__, '1.35' );
2045 
2046  if ( ( $value === '' || $value === "\x1f" ) && $allowMultiple ) {
2047  return [];
2048  }
2049  $limit1 = $limit1 ?: self::LIMIT_SML1;
2050  $limit2 = $limit2 ?: self::LIMIT_SML2;
2051 
2052  // This is a bit awkward, but we want to avoid calling canApiHighLimits()
2053  // if we don't need to because its fairly expensive
2054  $valuesList = $this->explodeMultiValue( $value, $limit2 + 1 );
2055  $sizeLimit = count( $valuesList ) > $limit1 && $this->mMainModule->canApiHighLimits()
2056  ? $limit2
2057  : $limit1;
2058 
2059  if ( $allowMultiple && is_array( $allowedValues ) && $allSpecifier &&
2060  count( $valuesList ) === 1 && $valuesList[0] === $allSpecifier
2061  ) {
2062  return $allowedValues;
2063  }
2064 
2065  if ( count( $valuesList ) > $sizeLimit ) {
2066  $this->dieWithError(
2067  [ 'apierror-toomanyvalues', $valueName, $sizeLimit ],
2068  "too-many-$valueName"
2069  );
2070  }
2071 
2072  if ( !$allowMultiple && count( $valuesList ) != 1 ) {
2073  // T35482 - Allow entries with | in them for non-multiple values
2074  if ( in_array( $value, $allowedValues, true ) ) {
2075  return $value;
2076  }
2077 
2078  $values = array_map( static function ( $v ) {
2079  return '<kbd>' . wfEscapeWikiText( $v ) . '</kbd>';
2080  }, $allowedValues );
2081  $this->dieWithError( [
2082  'apierror-multival-only-one-of',
2083  $valueName,
2084  Message::listParam( $values ),
2085  count( $values ),
2086  ], "multival_$valueName" );
2087  }
2088 
2089  if ( is_array( $allowedValues ) ) {
2090  // Check for unknown values
2091  $unknown = array_map( 'wfEscapeWikiText', array_diff( $valuesList, $allowedValues ) );
2092  if ( count( $unknown ) ) {
2093  if ( $allowMultiple ) {
2094  $this->addWarning( [
2095  'apiwarn-unrecognizedvalues',
2096  $valueName,
2097  Message::listParam( $unknown, 'comma' ),
2098  count( $unknown ),
2099  ] );
2100  } else {
2101  $this->dieWithError(
2102  [ 'apierror-unrecognizedvalue', $valueName, wfEscapeWikiText( $valuesList[0] ) ],
2103  "unknown_$valueName"
2104  );
2105  }
2106  }
2107  // Now throw them out
2108  $valuesList = array_intersect( $valuesList, $allowedValues );
2109  }
2110 
2111  return $allowMultiple ? $valuesList : $valuesList[0];
2112  }
2113 
2125  protected function validateLimit( $name, &$value, $min, $max, $botMax = null,
2126  $enforceLimits = false
2127  ) {
2128  wfDeprecated( __METHOD__, '1.35' );
2129  $value = $this->getMain()->getParamValidator()->validateValue(
2130  $this, $name, $value, [
2131  ParamValidator::PARAM_TYPE => 'limit',
2132  IntegerDef::PARAM_MIN => $min,
2133  IntegerDef::PARAM_MAX => $max,
2134  IntegerDef::PARAM_MAX2 => $botMax,
2135  IntegerDef::PARAM_IGNORE_RANGE => !$enforceLimits,
2136  ]
2137  );
2138  }
2139 
2147  protected function validateTimestamp( $value, $encParamName ) {
2148  wfDeprecated( __METHOD__, '1.35' );
2149 
2150  // Sigh.
2151  $name = $encParamName;
2152  $p = (string)$this->getModulePrefix();
2153  $l = strlen( $p );
2154  if ( $l && substr( $name, 0, $l ) === $p ) {
2155  $name = substr( $name, $l );
2156  }
2157 
2158  return $this->getMain()->getParamValidator()->validateValue(
2159  $this, $name, $value, [
2160  ParamValidator::PARAM_TYPE => 'timestamp',
2161  ]
2162  );
2163  }
2164 
2165  // endregion -- end of deprecated methods
2166 
2167 }
2168 
2169 /*
2170  * This file uses VisualStudio style region/endregion fold markers which are
2171  * recognised by PHPStorm. If modelines are enabled, the following editor
2172  * configuration will also enable folding in vim, if it is in the last 5 lines
2173  * of the file. We also use "@name" which creates sections in Doxygen.
2174  *
2175  * vim: foldmarker=//\ region,//\ endregion foldmethod=marker
2176  */
ApiBase\checkTitleUserPermissions
checkTitleUserPermissions( $pageIdentity, $actions, array $options=[])
Helper function for permission-denied errors.
Definition: ApiBase.php:1512
Page\PageIdentity
Interface for objects (potentially) representing an editable wiki page.
Definition: PageIdentity.php:65
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:38
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:71
ApiBase\PARAM_SUBMODULE_MAP
const PARAM_SUBMODULE_MAP
Definition: ApiBase.php:79
ApiBase\$mModuleSource
array null false $mModuleSource
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:203
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:363
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:46
ApiBase\$mMainModule
ApiMain $mMainModule
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:194
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:475
ApiBase\addWarning
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
Definition: ApiBase.php:1303
ApiBase\getSummaryMessage
getSummaryMessage()
Return the summary message.
Definition: ApiBase.php:1635
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:1708
ApiBase\PARAM_REQUIRED
const PARAM_REQUIRED
Definition: ApiBase.php:78
StatusValue\getErrorsByType
getErrorsByType( $type)
Returns a list of status messages of the given type.
Definition: StatusValue.php:290
ApiBase\$hookContainer
HookContainer $hookContainer
Definition: ApiBase.php:60
MediaWiki\Permissions\GroupPermissionsLookup
Definition: GroupPermissionsLookup.php:30
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:172
ApiBase\parameterNotEmpty
parameterNotEmpty( $x)
Callback function used in requireOnlyOneParameter to check whether required parameters are set.
Definition: ApiBase.php:974
ApiBase\validateToken
validateToken( $token, array $params)
Validate the supplied token.
Definition: ApiBase.php:1095
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:1384
ApiBase\PARAM_HELP_MSG
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:105
ApiBase\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiBase.php:279
StatusValue\replaceMessage
replaceMessage( $source, $dest)
If the specified source message exists, replace it with the specified destination message,...
Definition: StatusValue.php:336
ApiBase\PARAM_ALL
const PARAM_ALL
Definition: ApiBase.php:81
ApiBase\validateTimestamp
validateTimestamp( $value, $encParamName)
Validate and normalize parameters of type 'timestamp'.
Definition: ApiBase.php:2147
ApiBase\$extensionInfo
static array $extensionInfo
Maps extension paths to info arrays.
Definition: ApiBase.php:179
ApiBase\getTitleOrPageId
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
Definition: ApiBase.php:989
ApiBase\PARAM_TYPE
const PARAM_TYPE
Definition: ApiBase.php:72
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:561
ApiBase\__construct
__construct(ApiMain $mainModule, $moduleName, $modulePrefix='')
Stable to call.
Definition: ApiBase.php:211
ApiBase\getParameterFromSettings
getParameterFromSettings( $name, $settings, $parseLimit)
Using the settings determine the value for the given parameter.
Definition: ApiBase.php:1055
wfUrlencode
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
Definition: GlobalFunctions.php:313
ApiBase\mustBePosted
mustBePosted()
Indicates whether this module must be called with a POST request Stable to override.
Definition: ApiBase.php:351
ApiBase\logFeatureUsage
logFeatureUsage( $feature)
Write logging information for API features to a debug log, for usage analysis.
Definition: ApiBase.php:1589
ApiBase\checkUserRightsAny
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
Definition: ApiBase.php:1486
ApiBase\shouldCheckMaxlag
shouldCheckMaxlag()
Indicates if this module needs maxlag to be checked Stable to override.
Definition: ApiBase.php:317
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:1549
ApiBase\setContinuationManager
setContinuationManager(ApiContinuationManager $manager=null)
Definition: ApiBase.php:614
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:1649
ApiBase\PARAM_ISMULTI_LIMIT1
const PARAM_ISMULTI_LIMIT1
Definition: ApiBase.php:85
User\newFromName
static newFromName( $name, $validate='valid')
Definition: User.php:584
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1231
ApiBase\addBlockInfoToStatus
addBlockInfoToStatus(StatusValue $status, User $user=null)
Add block info to block messages in a Status.
Definition: ApiBase.php:1224
ApiBase\getHookContainer
getHookContainer()
Get a HookContainer, for running extension hooks or for hook metadata.
Definition: ApiBase.php:651
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:1411
ApiBase\getDB
getDB()
Gets a default replica DB connection object Stable to override.
Definition: ApiBase.php:590
ApiBase\addMessagesFromStatus
addMessagesFromStatus(StatusValue $status, $types=[ 'warning', 'error'], array $filter=[])
Add warnings and/or errors from a Status.
Definition: ApiBase.php:1363
ApiBase\makeMessage
static makeMessage( $msg, IContextSource $context, array $params=null)
Create a Message from a string or array.
Definition: ApiBase.php:1171
ContextSource\getRequest
getRequest()
Definition: ContextSource.php:80
ApiBase\dynamicParameterDocumentation
dynamicParameterDocumentation()
Indicate if the module supports dynamically-determined parameters that cannot be included in self::ge...
Definition: ApiBase.php:687
ApiBase\modifyHelp
modifyHelp(array &$help, array $options, array &$tocData)
Called from ApiHelp before the pieces are joined together and returned.
Definition: ApiBase.php:2001
ApiBase\PARAM_ALLOW_DUPLICATES
const PARAM_ALLOW_DUPLICATES
Definition: ApiBase.php:76
ContextSource\getUser
getUser()
Stable to override.
Definition: ContextSource.php:135
MediaWiki\Api\ApiHookRunner
This class provides an implementation of the hook interfaces used by the core Action API,...
Definition: ApiHookRunner.php:54
StatusValue\setOK
setOK( $ok)
Change operation status.
Definition: StatusValue.php:158
ApiBase\PARAM_DEPRECATED_VALUES
const PARAM_DEPRECATED_VALUES
Definition: ApiBase.php:84
ApiBase\lacksSameOriginSecurity
lacksSameOriginSecurity()
Returns true if the current request breaks the same-origin policy.
Definition: ApiBase.php:489
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:112
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:996
ApiBase\getWebUITokenSalt
getWebUITokenSalt(array $params)
Fetch the salt used in the Web UI corresponding to this module.
Definition: ApiBase.php:409
Message\listParam
static listParam(array $list, $type='text')
Definition: Message.php:1115
ApiBase\isMain
isMain()
Returns true if this module is the main module ($this === $this->mMainModule), false otherwise.
Definition: ApiBase.php:465
ApiBase\isReadMode
isReadMode()
Indicates whether this module requires read rights Stable to override.
Definition: ApiBase.php:326
ApiBase
This abstract class implements many basic API functions, and is the base of all API classes.
Definition: ApiBase.php:55
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:523
ApiBase\getFinalParamDescription
getFinalParamDescription()
Get final parameter descriptions, after hooks have had a chance to tweak it as needed.
Definition: ApiBase.php:1739
ApiBase\PARAM_SENSITIVE
const PARAM_SENSITIVE
Definition: ApiBase.php:83
ApiBase\PARAM_ISMULTI_LIMIT2
const PARAM_ISMULTI_LIMIT2
Definition: ApiBase.php:86
ExtensionRegistry\getInstance
static getInstance()
Definition: ExtensionRegistry.php:136
ApiBase\getFinalSummary
getFinalSummary()
Get final module summary.
Definition: ApiBase.php:1663
ApiBase\PARAM_DEPRECATED
const PARAM_DEPRECATED
Definition: ApiBase.php:77
ApiBase\explodeMultiValue
explodeMultiValue( $value, $limit)
Split a multi-valued parameter string, like explode()
Definition: ApiBase.php:2018
MediaWiki\Block\DatabaseBlock
A DatabaseBlock (unlike a SystemBlock) is stored in the database, may give rise to autoblocks and may...
Definition: DatabaseBlock.php:50
ApiBase\PARAM_MIN
const PARAM_MIN
Definition: ApiBase.php:75
StatusValue\isGood
isGood()
Returns whether the operation completed and didn't have any error or warnings.
Definition: StatusValue.php:122
wfDeprecatedMsg
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
Definition: GlobalFunctions.php:1066
MWException
MediaWiki exception.
Definition: MWException.php:29
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Definition: GlobalFunctions.php:1034
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:263
ApiBase\getFinalDescription
getFinalDescription()
Get final module description, after hooks have had a chance to tweak it as needed.
Definition: ApiBase.php:1679
wfTransactionalTimeLimit
wfTransactionalTimeLimit()
Raise the request time limit to $wgTransactionalTimeLimit.
Definition: GlobalFunctions.php:2642
ApiBase\getModulePath
getModulePath()
Get the path to this module.
Definition: ApiBase.php:505
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2467
ApiBase\LIMIT_BIG1
const LIMIT_BIG1
Fast query, standard limit.
Definition: ApiBase.php:163
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:32
ApiQueryTokens\getTokenTypeSalts
static getTokenTypeSalts()
Get the salts for known token types.
Definition: ApiQueryTokens.php:66
ApiBase\$hookRunner
ApiHookRunner $hookRunner
Definition: ApiBase.php:63
ApiBase\PARAM_MAX
const PARAM_MAX
Definition: ApiBase.php:73
ApiBase\getGroupPermissionsLookup
getGroupPermissionsLookup()
Obtain a GroupPermissionsLookup instance that subclasses may use to access group permissions.
Definition: ApiBase.php:641
ApiBase\extractRequestParams
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:720
ApiBase\handleParamNormalization
handleParamNormalization( $paramName, $value, $rawValue)
Handle when a parameter was Unicode-normalized.
Definition: ApiBase.php:1082
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
ApiBase\isDeprecated
isDeprecated()
Indicates whether this module is deprecated.
Definition: ApiBase.php:361
ApiBase\requireAtLeastOneParameter
requireAtLeastOneParameter( $params,... $required)
Die if none of a certain set of parameters is set and not false.
Definition: ApiBase.php:917
ApiBase\$mReplicaDB
$mReplicaDB
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:197
MediaWiki\Block\AbstractBlock\getType
getType()
Get the type of target for this particular block.
Definition: AbstractBlock.php:350
MediaWiki\Block\AbstractBlock\isSitewide
isSitewide( $x=null)
Indicates that the block is a sitewide block.
Definition: AbstractBlock.php:220
ApiMessage\create
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
Definition: ApiMessage.php:43
ApiBase\PARAM_EXTRA_NAMESPACES
const PARAM_EXTRA_NAMESPACES
Definition: ApiBase.php:82
ApiBase\ALL_DEFAULT_STRING
const ALL_DEFAULT_STRING
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:160
ContextSource\setContext
setContext(IContextSource $context)
Definition: ContextSource.php:62
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:289
ApiBlockInfoTrait
trait ApiBlockInfoTrait
Definition: ApiBlockInfoTrait.php:27
ApiBase\needsToken
needsToken()
Returns the token type this module requires in order to execute.
Definition: ApiBase.php:395
ApiBase\getModulePrefix
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
Definition: ApiBase.php:448
ApiBase\$mModuleName
string $mModuleName
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:196
ApiBase\getContinuationManager
getContinuationManager()
Definition: ApiBase.php:601
ContextSource\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:195
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:2125
ApiBase\addError
addError( $msg, $code=null, $data=null)
Add an error for this module without aborting.
Definition: ApiBase.php:1350
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition: PermissionManager.php:51
ApiBase\getWatchlistUser
getWatchlistUser( $params)
Gets the user for whom to get the watchlist.
Definition: ApiBase.php:1136
$s
foreach( $mmfl['setupFiles'] as $fileName) if( $queue) if(empty( $mmfl['quiet'])) $s
Definition: mergeMessageFileList.php:188
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:857
ApiBase\requireMaxOneParameter
requireMaxOneParameter( $params,... $required)
Die if more than one of a certain set of parameters is set and not false.
Definition: ApiBase.php:892
ApiBase\dieContinueUsageIf
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
Definition: ApiBase.php:1567
SpecialVersion\getCredits
static getCredits(ExtensionRegistry $reg, Config $conf)
Definition: SpecialVersion.php:68
ApiBase\addDeprecation
addDeprecation( $msg, $feature, $data=[])
Add a deprecation warning for this module.
Definition: ApiBase.php:1317
ContextSource\getAuthority
getAuthority()
Definition: ContextSource.php:142
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:169
ApiBase\encodeParamName
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
Definition: ApiBase.php:698
ApiBase\dieReadOnly
dieReadOnly()
Helper function for readonly errors.
Definition: ApiBase.php:1470
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:176
WikiPage\newFromID
static newFromID( $id, $from='fromdb')
Constructor from a page id.
Definition: WikiPage.php:198
ApiBase\getPermissionManager
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
Definition: ApiBase.php:630
ApiBase\useTransactionalTimeLimit
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
Definition: ApiBase.php:1242
ApiBase\getConditionalRequestData
getConditionalRequestData( $condition)
Returns data for HTTP conditional request mechanisms.
Definition: ApiBase.php:426
ApiBase\isWriteMode
isWriteMode()
Indicates whether this module requires write mode.
Definition: ApiBase.php:342
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1505
ApiBase\PARAM_HELP_MSG_INFO
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
Definition: ApiBase.php:122
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:57
MediaWiki\Permissions\PermissionStatus
A StatusValue for permission errors.
Definition: PermissionStatus.php:34
ApiBase\PARAM_RANGE_ENFORCE
const PARAM_RANGE_ENFORCE
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:95
ApiBase\PARAM_VALUE_LINKS
const PARAM_VALUE_LINKS
Deprecated and unused.
Definition: ApiBase.php:129
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:156
ApiBase\filterIDs
filterIDs( $fields, array $ids)
Filter out-of-range values from a list of positive integer IDs.
Definition: ApiBase.php:1256
ApiBase\LIMIT_BIG2
const LIMIT_BIG2
Fast query, apihighlimits limit.
Definition: ApiBase.php:165
wfReadOnlyReason
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
Definition: GlobalFunctions.php:1148
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:249
WikiPage\factory
static factory(PageIdentity $pageIdentity)
Create a WikiPage object of the appropriate class for the given PageIdentity.
Definition: WikiPage.php:183
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:372
ApiBase\getModuleSourceInfo
getModuleSourceInfo()
Returns information about the source of this module, if known.
Definition: ApiBase.php:1918
$path
$path
Definition: NoLocalSettings.php:25
ApiBase\PARAM_DFLT
const PARAM_DFLT
Definition: ApiBase.php:70
ApiBase\getParameter
getParameter( $paramName, $parseLimit=true)
Get a value for the given parameter.
Definition: ApiBase.php:840
ApiBase\dieWithException
dieWithException(Throwable $exception, array $options=[])
Abort execution with an error derived from a throwable.
Definition: ApiBase.php:1396
ApiBase\dieStatus
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
Definition: ApiBase.php:1442
ApiBase\getModuleName
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:440
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
Definition: ApiBase.php:71
Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:161
ApiBase\$blockMsgMap
static array $blockMsgMap
Map of web UI block messages to corresponding API messages and codes.
Definition: ApiBase.php:185
ApiBase\PARAM_MAX2
const PARAM_MAX2
Definition: ApiBase.php:74
StatusValue\hasMessage
hasMessage( $message)
Returns true if the specified message is present as a warning or error.
Definition: StatusValue.php:308
ApiBase\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiBase.php:306
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:2041
$help
$help
Definition: mcc.php:32
ApiBase\getMain
getMain()
Get the main module.
Definition: ApiBase.php:456
$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
Definition: ApiBase.php:88
MediaWiki\Block\AbstractBlock
Definition: AbstractBlock.php:37
ApiBase\getTitleFromTitleOrPageId
getTitleFromTitleOrPageId( $params)
Get a Title object from a title or pageid param, if possible.
Definition: ApiBase.php:1026
Title\castFromLinkTarget
static castFromLinkTarget( $linkTarget)
Same as newFromLinkTarget, but if passed null, returns null.
Definition: Title.php:315
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
ApiBase\$mModulePrefix
string $mModulePrefix
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:196
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:138
ApiBase\PARAM_SUBMODULE_PARAM_PREFIX
const PARAM_SUBMODULE_PARAM_PREFIX
Definition: ApiBase.php:80
ApiBase\$mParamCache
array $mParamCache
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:201
ApiBase\PARAM_MAX_BYTES
const PARAM_MAX_BYTES
Definition: ApiBase.php:87
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:666
$IP
$IP
Definition: WebStart.php:49
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:66
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:507
ApiBase\dieDebug
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition: ApiBase.php:1579
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:1196
ApiBase\getErrorFormatter
getErrorFormatter()
Stable to override.
Definition: ApiBase.php:575
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:944
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:167
ApiBase\getHelpFlags
getHelpFlags()
Generates the list of flags for the help screen and for action=paraminfo.
Definition: ApiBase.php:1885
ApiBase\$filterIDsCache
static stdClass[][] $filterIDsCache
Cache for self::filterIDs()
Definition: ApiBase.php:182