63 private $mInvalidTitles = [];
71 private $mPendingRedirectIDs = [];
83 private $mRequestedPageFields = [];
96 private static function addValues( array &$result, $values, $flags = [], $name =
null ) {
97 foreach ( $values as $val ) {
98 if ( $val instanceof
Title ) {
100 ApiQueryBase::addTitleInfo( $v, $val );
101 } elseif ( $name !==
null ) {
102 $v = [ $name => $val ];
106 foreach ( $flags as $flag ) {
122 $this->mDbSource = $dbSource;
123 $this->mAllowGenerator = ( $flags & self::DISABLE_GENERATORS ) == 0;
124 $this->mDefaultNamespace = $defaultNamespace;
127 $this->mResolveRedirects = $this->mParams[
'redirects'];
128 $this->mConvertTitles = $this->mParams[
'converttitles'];
152 $generatorName = $this->mAllowGenerator ? $this->mParams[
'generator'] :
null;
153 if ( isset( $generatorName ) ) {
154 $dbSource = $this->mDbSource;
155 if ( !$dbSource instanceof
ApiQuery ) {
157 $dbSource = $this->
getMain()->getModuleManager()->getModule(
'query' );
159 $generator = $dbSource->getModuleManager()->getModule( $generatorName,
null,
true );
161 $this->
dieWithError( [
'apierror-badgenerator-unknown', $generatorName ],
'badgenerator' );
164 $this->
dieWithError( [
'apierror-badgenerator-notgenerator', $generatorName ],
'badgenerator' );
168 $tmpPageSet =
new ApiPageSet( $dbSource, self::DISABLE_GENERATORS );
175 $tmpPageSet->executeInternal( $isDryRun );
185 foreach (
$generator->extractRequestParams() as $paramName => $param ) {
186 $main->markParamsUsed(
$generator->encodeParamName( $paramName ) );
196 if ( isset( $this->mParams[
'titles'] ) ) {
197 $dataSource =
'titles';
199 if ( isset( $this->mParams[
'pageids'] ) ) {
200 if ( isset( $dataSource ) ) {
203 'apierror-invalidparammix-cannotusewith',
210 $dataSource =
'pageids';
212 if ( isset( $this->mParams[
'revids'] ) ) {
213 if ( isset( $dataSource ) ) {
216 'apierror-invalidparammix-cannotusewith',
223 $dataSource =
'revids';
228 switch ( $dataSource ) {
236 if ( $this->mResolveRedirects ) {
237 $this->
addWarning(
'apiwarn-redirectsandrevids' );
239 $this->mResolveRedirects =
false;
255 return $this->mResolveRedirects;
267 if ( $this->mAllowGenerator && isset( $this->mParams[
'generator'] ) ) {
270 if ( isset( $this->mParams[
'titles'] ) ) {
273 if ( isset( $this->mParams[
'pageids'] ) ) {
276 if ( isset( $this->mParams[
'revids'] ) ) {
289 $this->mRequestedPageFields[$fieldName] =
null;
299 return $this->mRequestedPageFields[$fieldName];
312 'page_namespace' =>
null,
313 'page_title' =>
null,
317 if ( $this->mResolveRedirects ) {
318 $pageFlds[
'page_is_redirect'] =
null;
321 $pageFlds[
'page_content_model'] =
null;
323 if ( $this->
getConfig()->
get(
'PageLanguageUseDB' ) ) {
324 $pageFlds[
'page_lang'] =
null;
327 foreach ( LinkCache::getSelectFields() as $field ) {
328 $pageFlds[$field] =
null;
331 $pageFlds = array_merge( $pageFlds, $this->mRequestedPageFields );
333 return array_keys( $pageFlds );
343 return $this->mAllPages;
351 return $this->mTitles;
359 return count( $this->mTitles );
367 return $this->mGoodPages;
375 return $this->mGoodTitles;
383 return count( $this->mGoodTitles );
392 return $this->mMissingPages;
401 return $this->mMissingTitles;
409 return $this->mGoodAndMissingPages;
417 return $this->mGoodTitles + $this->mMissingTitles;
426 return $this->mInvalidTitles;
434 return $this->mMissingPageIDs;
443 return $this->mRedirectTitles;
457 'from' => strval( $titleStrFrom ),
458 'to' => $titleTo->getPrefixedText(),
460 if ( $titleTo->hasFragment() ) {
461 $r[
'tofragment'] = $titleTo->getFragment();
463 if ( $titleTo->isExternal() ) {
464 $r[
'tointerwiki'] = $titleTo->getInterwiki();
466 if ( isset( $this->mResolvedRedirectTitles[$titleStrFrom] ) ) {
467 $titleFrom = $this->mResolvedRedirectTitles[$titleStrFrom];
470 if ( isset( $this->mGeneratorData[$ns][$dbkey] ) ) {
471 $r = array_merge( $this->mGeneratorData[$ns][$dbkey], $r );
477 if ( !empty( $values ) && $result ) {
478 ApiResult::setIndexedTagName( $values,
'r' );
490 return $this->mNormalizedTitles;
502 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
504 $encode = $contLang->normalize( $rawTitleStr ) !== $rawTitleStr;
506 'fromencoded' => $encode,
507 'from' => $encode ? rawurlencode( $rawTitleStr ) : $rawTitleStr,
511 if ( !empty( $values ) && $result ) {
512 ApiResult::setIndexedTagName( $values,
'n' );
524 return $this->mConvertedTitles;
538 'from' => $rawTitleStr,
542 if ( !empty( $values ) && $result ) {
543 ApiResult::setIndexedTagName( $values,
'c' );
555 return $this->mInterwikiTitles;
570 'title' => $rawTitleStr,
571 'iw' => $interwikiStr,
574 $title = Title::newFromText( $rawTitleStr );
579 if ( !empty( $values ) && $result ) {
580 ApiResult::setIndexedTagName( $values,
'i' );
601 'special',
'missingIds',
'missingRevIds',
'missingTitles',
'interwikiTitles' ]
604 if ( in_array(
'invalidTitles', $invalidChecks ) ) {
607 if ( in_array(
'special', $invalidChecks ) ) {
611 if (
$title->isKnown() ) {
617 self::addValues( $result, $unknown, [
'special',
'missing' ] );
618 self::addValues( $result, $known, [
'special' ] );
620 if ( in_array(
'missingIds', $invalidChecks ) ) {
623 if ( in_array(
'missingRevIds', $invalidChecks ) ) {
626 if ( in_array(
'missingTitles', $invalidChecks ) ) {
630 if (
$title->isKnown() ) {
636 self::addValues( $result, $unknown, [
'missing' ] );
637 self::addValues( $result, $known, [
'missing',
'known' ] );
639 if ( in_array(
'interwikiTitles', $invalidChecks ) ) {
651 return $this->mGoodRevIDs;
659 return $this->mLiveRevIDs;
667 return $this->mDeletedRevIDs;
675 return $this->mMissingRevIDs;
692 if ( !empty( $values ) && $result ) {
693 ApiResult::setIndexedTagName( $values,
'rev' );
704 return $this->mSpecialTitles;
758 $title = Title::newFromRow( $row );
760 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
761 $linkCache->addGoodLinkObjFromRow(
$title, $row );
763 $pageId = (int)$row->page_id;
764 $this->mAllPages[$row->page_namespace][$row->page_title] = $pageId;
765 $this->mTitles[] =
$title;
767 if ( $this->mResolveRedirects && $row->page_is_redirect ==
'1' ) {
768 $this->mPendingRedirectIDs[$pageId] =
$title;
770 $this->mGoodPages[$row->page_namespace][$row->page_title] = $pageId;
771 $this->mGoodAndMissingPages[$row->page_namespace][$row->page_title] = $pageId;
772 $this->mGoodTitles[$pageId] =
$title;
775 foreach ( $this->mRequestedPageFields as $fieldName => &$fieldValues ) {
776 $fieldValues[$pageId] = $row->$fieldName;
799 if ( $linkBatch->isEmpty() ) {
805 $db = $this->
getDB();
806 $set = $linkBatch->constructSet(
'page', $db );
829 $pageids = array_map(
'intval', $pageids );
830 $remaining = array_flip( $pageids );
833 $pageids = $this->
filterIDs( [ [
'page',
'page_id' ] ], $pageids );
837 if ( !empty( $pageids ) ) {
839 'page_id' => $pageids
841 $db = $this->
getDB();
865 if ( $remaining !==
null && $processTitles ===
null ) {
866 ApiBase::dieDebug( __METHOD__,
'Missing $processTitles parameter when $remaining is provided' );
869 $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
873 foreach (
$res as $row ) {
874 $pageId = (int)$row->page_id;
877 if ( isset( $remaining ) ) {
878 if ( $processTitles ) {
879 unset( $remaining[$row->page_namespace][$row->page_title] );
881 unset( $remaining[$pageId] );
889 if ( $nsInfo->hasGenderDistinction( $row->page_namespace ) ) {
890 $usernames[] = $row->page_title;
895 if ( isset( $remaining ) ) {
897 if ( $processTitles ) {
899 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
900 foreach ( $remaining as $ns => $dbkeys ) {
901 foreach ( array_keys( $dbkeys ) as $dbkey ) {
902 $title = Title::makeTitle( $ns, $dbkey );
903 $linkCache->addBadLinkObj(
$title );
904 $this->mAllPages[$ns][$dbkey] = $this->mFakePageId;
905 $this->mMissingPages[$ns][$dbkey] = $this->mFakePageId;
906 $this->mGoodAndMissingPages[$ns][$dbkey] = $this->mFakePageId;
907 $this->mMissingTitles[$this->mFakePageId] =
$title;
908 $this->mFakePageId--;
909 $this->mTitles[] =
$title;
912 if ( $nsInfo->hasGenderDistinction( $ns ) ) {
913 $usernames[] = $dbkey;
919 if ( !$this->mMissingPageIDs ) {
920 $this->mMissingPageIDs = array_keys( $remaining );
922 $this->mMissingPageIDs = array_merge( $this->mMissingPageIDs, array_keys( $remaining ) );
928 $genderCache = MediaWikiServices::getInstance()->getGenderCache();
929 $genderCache->doQuery( $usernames, __METHOD__ );
942 $revids = array_map(
'intval', $revids );
943 $db = $this->
getDB();
945 $remaining = array_flip( $revids );
947 $revids = $this->
filterIDs( [ [
'revision',
'rev_id' ], [
'archive',
'ar_rev_id' ] ], $revids );
948 $goodRemaining = array_flip( $revids );
951 $tables = [
'revision',
'page' ];
952 $fields = [
'rev_id',
'rev_page' ];
953 $where = [
'rev_id' => $revids,
'rev_page = page_id' ];
956 $res = $db->select( $tables, $fields, $where, __METHOD__ );
957 foreach (
$res as $row ) {
958 $revid = (int)$row->rev_id;
959 $pageid = (int)$row->rev_page;
960 $this->mGoodRevIDs[$revid] = $pageid;
961 $this->mLiveRevIDs[$revid] = $pageid;
962 $pageids[$pageid] =
'';
963 unset( $remaining[$revid] );
964 unset( $goodRemaining[$revid] );
974 if ( $goodRemaining &&
976 $tables = [
'archive' ];
977 $fields = [
'ar_rev_id',
'ar_namespace',
'ar_title' ];
978 $where = [
'ar_rev_id' => array_keys( $goodRemaining ) ];
980 $res = $db->select( $tables, $fields, $where, __METHOD__ );
982 foreach (
$res as $row ) {
983 $revid = (int)$row->ar_rev_id;
984 $titles[$revid] = Title::makeTitle( $row->ar_namespace, $row->ar_title );
985 unset( $remaining[$revid] );
990 foreach ( $titles as $revid =>
$title ) {
991 $ns =
$title->getNamespace();
992 $dbkey =
$title->getDBkey();
995 if ( !isset( $this->mAllPages[$ns][$dbkey] ) &&
996 isset( $this->mConvertedTitles[
$title->getPrefixedText()] )
998 $title = Title::newFromText( $this->mConvertedTitles[
$title->getPrefixedText()] );
999 $ns =
$title->getNamespace();
1000 $dbkey =
$title->getDBkey();
1003 if ( isset( $this->mAllPages[$ns][$dbkey] ) ) {
1004 $this->mGoodRevIDs[$revid] = $this->mAllPages[$ns][$dbkey];
1005 $this->mDeletedRevIDs[$revid] = $this->mAllPages[$ns][$dbkey];
1007 $remaining[$revid] =
true;
1012 $this->mMissingRevIDs = array_keys( $remaining );
1021 if ( $this->mResolveRedirects ) {
1022 $db = $this->
getDB();
1027 while ( $this->mPendingRedirectIDs || $this->mPendingRedirectSpecialPages ) {
1032 if ( $linkBatch->isEmpty() ) {
1036 $set = $linkBatch->constructSet(
'page', $db );
1037 if ( $set ===
false ) {
1042 $res = $db->select(
'page', $pageFlds, $set, __METHOD__ );
1058 $titlesToResolve = [];
1059 $db = $this->
getDB();
1061 if ( $this->mPendingRedirectIDs ) {
1070 ], [
'rd_from' => array_keys( $this->mPendingRedirectIDs ) ],
1073 foreach (
$res as $row ) {
1074 $rdfrom = (int)$row->rd_from;
1075 $from = $this->mPendingRedirectIDs[$rdfrom]->getPrefixedText();
1076 $to = Title::makeTitle(
1082 $this->mResolvedRedirectTitles[$from] = $this->mPendingRedirectIDs[$rdfrom];
1083 unset( $this->mPendingRedirectIDs[$rdfrom] );
1084 if ( $to->isExternal() ) {
1085 $this->mInterwikiTitles[$to->getPrefixedText()] = $to->getInterwiki();
1086 } elseif ( !isset( $this->mAllPages[$to->getNamespace()][$to->getDBkey()] )
1087 && !( $this->mConvertTitles && isset( $this->mConvertedTitles[$to->getPrefixedText()] ) )
1089 $titlesToResolve[] = $to;
1091 $this->mRedirectTitles[$from] = $to;
1094 if ( $this->mPendingRedirectIDs ) {
1097 foreach ( $this->mPendingRedirectIDs as $id =>
$title ) {
1098 $page = WikiPage::factory(
$title );
1099 $rt = $page->insertRedirect();
1104 if ( $rt->isExternal() ) {
1105 $this->mInterwikiTitles[$rt->getPrefixedText()] = $rt->getInterwiki();
1106 } elseif ( !isset( $this->mAllPages[$rt->getNamespace()][$rt->getDBkey()] ) ) {
1107 $titlesToResolve[] = $rt;
1109 $from =
$title->getPrefixedText();
1110 $this->mResolvedRedirectTitles[$from] =
$title;
1111 $this->mRedirectTitles[$from] = $rt;
1112 unset( $this->mPendingRedirectIDs[$id] );
1117 if ( $this->mPendingRedirectSpecialPages ) {
1118 foreach ( $this->mPendingRedirectSpecialPages as $key => list( $from, $to ) ) {
1120 $fromKey = $from->getPrefixedText();
1121 $this->mResolvedRedirectTitles[$fromKey] = $from;
1122 $this->mRedirectTitles[$fromKey] = $to;
1123 if ( $to->isExternal() ) {
1124 $this->mInterwikiTitles[$to->getPrefixedText()] = $to->getInterwiki();
1125 } elseif ( !isset( $this->mAllPages[$to->getNamespace()][$to->getDBkey()] ) ) {
1126 $titlesToResolve[] = $to;
1129 $this->mPendingRedirectSpecialPages = [];
1133 $this->mCacheMode =
'private';
1153 return $this->mCacheMode;
1167 $services = MediaWikiServices::getInstance();
1168 $contLang = $services->getContentLanguage();
1171 foreach ( $titles as $index =>
$title ) {
1172 if ( is_string(
$title ) ) {
1175 $titleObj = Title::newFromTextThrow(
$title, $this->mDefaultNamespace );
1178 if ( !isset( $this->mAllPages[0][
$title] ) ) {
1179 $this->mAllPages[0][
$title] = $this->mFakePageId;
1180 $this->mInvalidTitles[$this->mFakePageId] = [
1182 'invalidreason' => $this->
getErrorFormatter()->formatException( $ex, [
'bc' =>
true ] ),
1184 $this->mFakePageId--;
1192 $titleObjects[$index] = $titleObj;
1196 $genderCache = $services->getGenderCache();
1197 $genderCache->doTitlesArray( $titleObjects, __METHOD__ );
1199 foreach ( $titleObjects as $index => $titleObj ) {
1200 $title = is_string( $titles[$index] ) ? $titles[$index] :
false;
1201 $unconvertedTitle = $titleObj->getPrefixedText();
1202 $titleWasConverted =
false;
1203 if ( $titleObj->isExternal() ) {
1205 $this->mInterwikiTitles[$unconvertedTitle] = $titleObj->getInterwiki();
1209 $this->mConvertTitles && $contLang->hasVariants() && !$titleObj->exists()
1213 $titleText =
$title !==
false ?
$title : $titleObj->getPrefixedText();
1214 $contLang->findVariantLink( $titleText, $titleObj );
1215 $titleWasConverted = $unconvertedTitle !== $titleObj->getPrefixedText();
1218 if ( $titleObj->getNamespace() < 0 ) {
1220 $titleObj = $titleObj->fixSpecialName();
1221 $ns = $titleObj->getNamespace();
1222 $dbkey = $titleObj->getDBkey();
1223 if ( !isset( $this->mAllSpecials[$ns][$dbkey] ) ) {
1224 $this->mAllSpecials[$ns][$dbkey] = $this->mFakePageId;
1226 if ( $ns ===
NS_SPECIAL && $this->mResolveRedirects ) {
1227 $spFactory = $services->getSpecialPageFactory();
1228 $special = $spFactory->getPage( $dbkey );
1237 list( , $subpage ) = $spFactory->resolveAlias( $dbkey );
1238 $target = $special->getRedirect( $subpage );
1242 $this->mPendingRedirectSpecialPages[$dbkey] = [ $titleObj, $target ];
1244 $this->mSpecialTitles[$this->mFakePageId] = $titleObj;
1245 $this->mFakePageId--;
1250 $linkBatch->addObj( $titleObj );
1259 if ( $titleWasConverted ) {
1260 $this->mConvertedTitles[$unconvertedTitle] = $titleObj->getPrefixedText();
1262 if (
$title !==
false &&
$title !== $unconvertedTitle ) {
1263 $this->mNormalizedTitles[
$title] = $unconvertedTitle;
1265 } elseif (
$title !==
false &&
$title !== $titleObj->getPrefixedText() ) {
1266 $this->mNormalizedTitles[
$title] = $titleObj->getPrefixedText();
1289 $ns =
$title->getNamespace();
1290 $dbkey =
$title->getDBkey();
1291 $this->mGeneratorData[$ns][$dbkey] = $data;
1314 $this->mRedirectMergePolicy = $callable;
1331 while ( isset( $this->mRedirectTitles[$dest->getPrefixedText()] ) ) {
1332 $dest = $this->mRedirectTitles[$dest->getPrefixedText()];
1333 if ( isset( $seen[$dest->getPrefixedText()] ) ) {
1336 $seen[$dest->getPrefixedText()] =
true;
1363 $data = $result->getResultData(
$path );
1364 if ( $data ===
null ) {
1369 foreach (
$path as $key ) {
1370 if ( !isset( $data[$key] ) ) {
1375 $data = &$data[$key];
1378 foreach ( $this->mGeneratorData as $ns => $dbkeys ) {
1381 foreach ( $this->mSpecialTitles as $id =>
$title ) {
1382 $pages[
$title->getDBkey()] = $id;
1385 if ( !isset( $this->mAllPages[$ns] ) ) {
1389 $pages = $this->mAllPages[$ns];
1391 foreach ( $dbkeys as $dbkey => $genData ) {
1392 if ( !isset( $pages[$dbkey] ) ) {
1396 $pageId = $pages[$dbkey];
1397 if ( !isset( $data[$pageId] ) ) {
1403 $path2 = array_merge(
$path, [ $pageId ] );
1404 foreach ( $genData as $key => $value ) {
1405 if ( !$result->addValue( $path2, $key, $value ) ) {
1410 $data[$pageId] = array_merge( $data[$pageId], $genData );
1416 if ( $this->mRedirectMergePolicy ) {
1417 foreach ( $this->mResolvedRedirectTitles as $titleFrom ) {
1418 $dest = $this->resolveRedirectTitleDest( $titleFrom );
1419 $fromNs = $titleFrom->getNamespace();
1420 $fromDBkey = $titleFrom->getDBkey();
1421 $toPageId = $dest->getArticleID();
1422 if ( isset( $data[$toPageId] ) &&
1423 isset( $this->mGeneratorData[$fromNs][$fromDBkey] )
1427 $data[$toPageId] = call_user_func(
1428 $this->mRedirectMergePolicy,
1430 $this->mGeneratorData[$fromNs][$fromDBkey]
1433 !$result->
addValue(
$path, $toPageId, $data[$toPageId], ApiResult::OVERRIDE )
1449 return $this->mDbSource->getDB();
1476 ?
'api-pageset-param-redirects-generator'
1477 :
'api-pageset-param-redirects-nogenerator',
1479 'converttitles' => [
1482 'api-pageset-param-converttitles',
1488 if ( !$this->mAllowGenerator ) {
1489 unset( $result[
'generator'] );
1499 parent::handleParamNormalization( $paramName, $value, $rawValue );
1501 if ( $paramName ===
'titles' ) {
1504 $value = ParamValidator::explodeMultiValue( $value, self::LIMIT_SML2 + 1 );
1505 $l = count( $value );
1506 $rawValue = ParamValidator::explodeMultiValue( $rawValue, $l );
1507 for ( $i = 0; $i < $l; $i++ ) {
1508 if ( $value[$i] !== $rawValue[$i] ) {
1509 $this->mNormalizedTitles[$rawValue[$i]] = $value[$i];
1515 private static $generators =
null;
1522 if ( self::$generators ===
null ) {
1523 $query = $this->mDbSource;
1524 if ( !( $query instanceof
ApiQuery ) ) {
1527 $query = $this->getMain()->getModuleManager()->getModule(
'query' );
1530 $prefix = $query->getModulePath() .
'+';
1531 $mgr = $query->getModuleManager();
1532 foreach ( $mgr->getNamesWithClasses() as $name => $class ) {
1533 if ( is_subclass_of( $class, ApiQueryGeneratorBase::class ) ) {
1534 $gens[$name] = $prefix . $name;
1538 self::$generators = $gens;
1541 return self::$generators;
This abstract class implements many basic API functions, and is the base of all API classes.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
const PARAM_SUBMODULE_MAP
filterIDs( $fields, array $ids)
Filter out-of-range values from a list of positive integer IDs.
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
getMain()
Get the main module.
getErrorFormatter()
Get the error formatter Stable to override.
const PARAM_SUBMODULE_PARAM_PREFIX
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
getModuleName()
Get the name of the module being executed by this instance.
getHookRunner()
Get an ApiHookRunner for running core API hooks.
This class contains a list of pages that the client has requested.
getGoodAndMissingTitlesByNamespace()
Returns an array [ns][dbkey] => page_id for all good and missing titles.
populateFromRevisionIDs( $revIDs)
Populate this PageSet from a list of revision IDs.
getInterwikiTitlesAsResult( $result=null, $iwUrl=false)
Get a list of interwiki titles - maps a title to its interwiki prefix as result.
getCustomField( $fieldName)
Get the value of a custom field previously requested through requestField()
getNormalizedTitles()
Get a list of title normalizations - maps a title to its normalized version.
getGenerators()
Get an array of all available generators.
__construct(ApiBase $dbSource, $flags=0, $defaultNamespace=NS_MAIN)
getGoodTitlesByNamespace()
Returns an array [ns][dbkey] => page_id for all good titles.
getAllowedParams( $flags=0)
getRevisionIDs()
Get the list of valid revision IDs (requested with the revids= parameter)
getGoodAndMissingTitles()
Title objects for good and missing titles.
populateFromPageIDs( $pageIDs)
Populate this PageSet from a list of page IDs.
getRedirectTargets()
Get the targets of the pending redirects from the database.
getMissingTitlesByNamespace()
Returns an array [ns][dbkey] => fake_page_id for all missing titles.
array $mRequestedPageFields
getMissingTitles()
Title objects that were NOT found in the database.
getDB()
Get the database connection (read-only)
initFromRevIDs( $revids)
Does the same as initFromTitles(), but is based on revision IDs instead.
executeDryRun()
In case execute() is not called, call this method to mark all relevant parameters as used This preven...
getRedirectTitlesAsResult( $result=null)
Get a list of redirect resolutions - maps a title to its redirect target.
getPageTableFields()
Get the fields that have to be queried from the page table: the ones requested through requestField()...
getGoodTitleCount()
Returns the number of found unique pages (not revisions) in the set.
getRevisionCount()
Returns the number of revisions (requested with revids= parameter).
getAllTitlesByNamespace()
Returns an array [ns][dbkey] => page_id for all requested titles.
processDbRow( $row)
Extract all requested fields from the row received from the database.
processTitlesArray( $titles)
Given an array of title strings, convert them into Title objects.
static addValues(array &$result, $values, $flags=[], $name=null)
Add all items from $values into the result.
setRedirectMergePolicy( $callable)
Controls how generator data about a redirect source is merged into the generator data for the redirec...
handleParamNormalization( $paramName, $value, $rawValue)
Handle when a parameter was Unicode-normalized.
getNormalizedTitlesAsResult( $result=null)
Get a list of title normalizations - maps a title to its normalized version in the form of result arr...
getTitleCount()
Returns the number of unique pages (not revisions) in the set.
initFromTitles( $titles)
This method populates internal variables with page information based on the given array of title stri...
getInvalidTitlesAndReasons()
Titles that were deemed invalid by Title::newFromText() The array's index will be unique and negative...
array $mInvalidTitles
[fake_page_id] => [ 'title' => $title, 'invalidreason' => $reason ]
getSpecialTitles()
Get the list of titles with negative namespace.
Title[] $mPendingRedirectIDs
getTitles()
All Title objects provided.
executeInternal( $isDryRun)
Populate the PageSet from the request parameters.
resolvePendingRedirects()
Resolve any redirects in the result if redirect resolution was requested.
populateFromQueryResult( $db, $queryResult)
Populate this PageSet from a rowset returned from the database.
getMissingPageIDs()
Page IDs that were not found in the database.
requestField( $fieldName)
Request an additional field from the page table.
getInterwikiTitles()
Get a list of interwiki titles - maps a title to its interwiki prefix.
resolveRedirectTitleDest(Title $titleFrom)
Resolve the title a redirect points to.
populateFromTitles( $titles)
Populate this PageSet from a list of Titles.
getMissingRevisionIDs()
Revision IDs that were not found in the database.
initFromPageIds( $pageids, $filterIds=true)
Does the same as initFromTitles(), but is based on page IDs instead.
execute()
Populate the PageSet from the request parameters.
populateGeneratorData(&$result, array $path=[])
Populate the generator data for all titles in the result.
$mPendingRedirectSpecialPages
getConvertedTitlesAsResult( $result=null)
Get a list of title conversions - maps a title to its converted version as a result array.
getConvertedTitles()
Get a list of title conversions - maps a title to its converted version.
getDataSource()
Return the parameter name that is the source of data for this PageSet.
getInvalidTitlesAndRevisions( $invalidChecks=[ 'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles'])
Get an array of invalid/special/missing titles.
getLiveRevisionIDs()
Get the list of non-deleted revision IDs (requested with the revids= parameter)
getCacheMode( $params=null)
Get the cache mode for the data generated by this module.
getGoodTitles()
Title objects that were found in the database.
callable null $mRedirectMergePolicy
isResolvingRedirects()
Check whether this PageSet is resolving redirects.
getRedirectTitles()
Get a list of redirect resolutions - maps a title to its redirect target, as an array of output-ready...
setGeneratorData(Title $title, array $data)
Set data for a title.
const DISABLE_GENERATORS
Constructor flag: The new instance of ApiPageSet will ignore the 'generator=' parameter.
initFromQueryResult( $res, &$remaining=null, $processTitles=null)
Iterate through the result of the query on 'page' table, and for each row create and store title obje...
getMissingRevisionIDsAsResult( $result=null)
Revision IDs that were not found in the database as result array.
getDeletedRevisionIDs()
Get the list of revision IDs that were associated with deleted titles.
This is the main query class.
This class represents the result of the API operations.
addValue( $path, $name, $value, $flags=0)
Add value to the output data at the given path.
An IContextSource implementation which will inherit context from another source but allow individual ...
WebRequest clone which takes values from a provided array.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
static listParam(array $list, $type='text')
Superclass for any RedirectSpecialPage which redirects the user to a particular article (as opposed t...
Represents a title within MediaWiki.
getNamespace()
Get the namespace index, i.e.
getDBkey()
Get the main part with underscores.
getPrefixedText()
Get the prefixed title with spaces.