52 private bool $fld_protection =
false;
53 private bool $fld_talkid =
false;
54 private bool $fld_subjectid =
false;
55 private bool $fld_url =
false;
56 private bool $fld_readable =
false;
57 private bool $fld_watched =
false;
58 private bool $fld_watchlistlabels =
false;
59 private bool $fld_watchers =
false;
60 private bool $fld_visitingwatchers =
false;
61 private bool $fld_notificationtimestamp =
false;
62 private bool $fld_preload =
false;
63 private bool $fld_preloadcontent =
false;
64 private bool $fld_editintro =
false;
65 private bool $fld_displaytitle =
false;
66 private bool $fld_varianttitles =
false;
72 private $fld_linkclasses =
false;
77 private $fld_associatedpage =
false;
103 private $pageTouched;
116 private $protections;
118 private $restrictionTypes;
122 private $watchlistLabels;
126 private $visitingwatchers;
128 private $notificationtimestamps;
134 private $displaytitles;
136 private $variantTitles;
142 private $watchlistExpiries;
148 private $linkClasses;
151 private $showZeroWatchers =
false;
154 private $countTestedActions = 0;
173 private readonly
UrlUtils $urlUtils,
176 parent::__construct( $queryModule, $moduleName,
'in' );
188 $pageSet->requestField(
'page_is_redirect' );
189 $pageSet->requestField(
'page_is_new' );
191 $pageSet->requestField(
'page_touched' );
192 $pageSet->requestField(
'page_latest' );
193 $pageSet->requestField(
'page_len' );
194 $pageSet->requestField(
'page_content_model' );
196 $pageSet->requestField(
'page_lang' );
202 if ( $this->params[
'prop'] !==
null ) {
203 $prop = array_fill_keys( $this->params[
'prop'],
true );
204 $this->fld_protection = isset( $prop[
'protection'] );
205 $this->fld_watched = isset( $prop[
'watched'] );
206 $this->fld_watchlistlabels = isset( $prop[
'watchlistlabels'] )
208 $this->fld_watchers = isset( $prop[
'watchers'] );
209 $this->fld_visitingwatchers = isset( $prop[
'visitingwatchers'] );
210 $this->fld_notificationtimestamp = isset( $prop[
'notificationtimestamp'] );
211 $this->fld_talkid = isset( $prop[
'talkid'] );
212 $this->fld_subjectid = isset( $prop[
'subjectid'] );
213 $this->fld_url = isset( $prop[
'url'] );
214 $this->fld_readable = isset( $prop[
'readable'] );
215 $this->fld_preload = isset( $prop[
'preload'] );
216 $this->fld_preloadcontent = isset( $prop[
'preloadcontent'] );
217 $this->fld_editintro = isset( $prop[
'editintro'] );
218 $this->fld_displaytitle = isset( $prop[
'displaytitle'] );
219 $this->fld_varianttitles = isset( $prop[
'varianttitles'] );
220 $this->fld_linkclasses = isset( $prop[
'linkclasses'] );
221 $this->fld_associatedpage = isset( $prop[
'associatedpage'] );
225 $this->titles = $pageSet->getGoodPages();
226 $this->missing = $pageSet->getMissingPages();
227 $this->everything = $this->titles + $this->missing;
231 ( $this->fld_preloadcontent || $this->fld_editintro ) &&
232 ( count( $this->everything ) > 1 || count( $this->
getPageSet()->getRevisionIDs() ) > 1 )
237 [
'apierror-info-singlepagerevision', $this->
getModulePrefix() ],
'invalidparammix'
241 uasort( $this->everything, Title::compare( ... ) );
242 if ( $this->params[
'continue'] !==
null ) {
246 $conttitle = $this->titleFactory->makeTitleSafe( $cont[0], $cont[1] );
248 foreach ( $this->everything as $pageid => $page ) {
249 if ( Title::compare( $page, $conttitle ) >= 0 ) {
252 unset( $this->titles[$pageid] );
253 unset( $this->missing[$pageid] );
254 unset( $this->everything[$pageid] );
259 $this->pageIsRedir = !$pageSet->isResolvingRedirects()
260 ? $pageSet->getCustomField(
'page_is_redirect' )
262 $this->pageIsNew = $pageSet->getCustomField(
'page_is_new' );
264 $this->pageTouched = $pageSet->getCustomField(
'page_touched' );
265 $this->pageLatest = $pageSet->getCustomField(
'page_latest' );
266 $this->pageLength = $pageSet->getCustomField(
'page_len' );
269 if ( $this->fld_protection ) {
270 $this->getProtectionInfo();
273 if ( $this->fld_watched || $this->fld_watchlistlabels || $this->fld_notificationtimestamp ) {
274 $this->getWatchedInfo();
277 if ( $this->fld_watchers ) {
278 $this->getWatcherInfo();
281 if ( $this->fld_visitingwatchers ) {
282 $this->getVisitingWatcherInfo();
286 if ( $this->fld_talkid || $this->fld_subjectid ) {
290 if ( $this->fld_displaytitle ) {
291 $this->getDisplayTitle();
294 if ( $this->fld_varianttitles ) {
295 $this->getVariantTitles();
298 if ( $this->fld_linkclasses ) {
299 $this->getLinkClasses( $this->params[
'linkcontext'], $this->params[
'defaultlinkcaption'] );
303 foreach ( $this->everything as $pageid => $page ) {
304 $pageInfo = $this->extractPageInfo( $pageid, $page );
305 $fit = $pageInfo !==
null && $result->addValue( [
308 ], $pageid, $pageInfo );
311 $page->getNamespace() .
'|' .
312 $this->titleFormatter->getText( $page ) );
324 private function extractPageInfo( $pageid, $page ) {
325 $title = $this->titleFactory->newFromPageIdentity( $page );
328 $pageExists = $pageid > 0;
329 $ns = $page->getNamespace();
330 $dbkey = $page->getDBkey();
332 $pageInfo[
'contentmodel'] = $title->getContentModel();
334 $pageLanguage = $title->getPageLanguage();
335 $pageInfo[
'pagelanguage'] = $pageLanguage->getCode();
336 $pageInfo[
'pagelanguagehtmlcode'] = $pageLanguage->getHtmlCode();
337 $pageInfo[
'pagelanguagedir'] = $pageLanguage->getDir();
340 $pageInfo[
'touched'] =
wfTimestamp( TS::ISO_8601, $this->pageTouched[$pageid] );
341 $pageInfo[
'lastrevid'] = (int)$this->pageLatest[$pageid];
342 $pageInfo[
'length'] = (int)$this->pageLength[$pageid];
344 if ( isset( $this->pageIsRedir[$pageid] ) && $this->pageIsRedir[$pageid] ) {
345 $pageInfo[
'redirect'] =
true;
347 if ( $this->pageIsNew[$pageid] ) {
348 $pageInfo[
'new'] =
true;
352 if ( $this->fld_protection ) {
353 $pageInfo[
'protection'] = [];
354 if ( isset( $this->protections[$ns][$dbkey] ) ) {
355 $pageInfo[
'protection'] =
356 $this->protections[$ns][$dbkey];
360 $pageInfo[
'restrictiontypes'] = [];
361 if ( isset( $this->restrictionTypes[$ns][$dbkey] ) ) {
362 $pageInfo[
'restrictiontypes'] =
363 $this->restrictionTypes[$ns][$dbkey];
368 if ( $this->fld_watched ) {
369 $pageInfo[
'watched'] =
false;
371 if ( isset( $this->watched[$ns][$dbkey] ) ) {
372 $pageInfo[
'watched'] = $this->watched[$ns][$dbkey];
375 if ( isset( $this->watchlistExpiries[$ns][$dbkey] ) ) {
376 $pageInfo[
'watchlistexpiry'] = $this->watchlistExpiries[$ns][$dbkey];
380 if ( $this->fld_watchlistlabels ) {
381 $pageInfo[
'watchlistlabels'] = [];
382 if ( isset( $this->watchlistLabels[$ns][$dbkey] ) ) {
383 $pageInfo[
'watchlistlabels'] = $this->watchlistLabels[$ns][$dbkey];
388 if ( $this->fld_watchers ) {
389 if ( $this->watchers !==
null && $this->watchers[$ns][$dbkey] !== 0 ) {
390 $pageInfo[
'watchers'] = $this->watchers[$ns][$dbkey];
391 } elseif ( $this->showZeroWatchers ) {
392 $pageInfo[
'watchers'] = 0;
396 if ( $this->fld_visitingwatchers ) {
397 if ( $this->visitingwatchers !==
null && $this->visitingwatchers[$ns][$dbkey] !== 0 ) {
398 $pageInfo[
'visitingwatchers'] = $this->visitingwatchers[$ns][$dbkey];
399 } elseif ( $this->showZeroWatchers ) {
400 $pageInfo[
'visitingwatchers'] = 0;
404 if ( $this->fld_notificationtimestamp ) {
405 $pageInfo[
'notificationtimestamp'] =
'';
406 if ( isset( $this->notificationtimestamps[$ns][$dbkey] ) ) {
407 $pageInfo[
'notificationtimestamp'] =
408 wfTimestamp( TS::ISO_8601, $this->notificationtimestamps[$ns][$dbkey] );
412 if ( $this->fld_talkid && isset( $this->talkids[$ns][$dbkey] ) ) {
413 $pageInfo[
'talkid'] = $this->talkids[$ns][$dbkey];
416 if ( $this->fld_subjectid && isset( $this->subjectids[$ns][$dbkey] ) ) {
417 $pageInfo[
'subjectid'] = $this->subjectids[$ns][$dbkey];
420 if ( $this->fld_associatedpage && $ns >=
NS_MAIN ) {
421 $pageInfo[
'associatedpage'] = $this->titleFormatter->getPrefixedText(
422 $this->namespaceInfo->getAssociatedPage( TitleValue::newFromPage( $page ) )
426 if ( $this->fld_url ) {
427 $pageInfo[
'fullurl'] = (string)$this->urlUtils->expand(
430 $pageInfo[
'editurl'] = (string)$this->urlUtils->expand(
433 $pageInfo[
'canonicalurl'] = (string)$this->urlUtils->expand(
437 if ( $this->fld_readable ) {
438 $pageInfo[
'readable'] = $this->
getAuthority()->definitelyCan(
'read', $page );
441 if ( $this->fld_preload ) {
443 if ( !$pageExists ) {
444 $this->
getHookRunner()->onEditFormPreloadText( $text, $title );
446 $pageInfo[
'preload'] = $text;
449 if ( $this->fld_preloadcontent ) {
450 $newSection = $this->params[
'preloadnewsection'];
453 if ( !$pageExists || $newSection ) {
454 $content = $this->preloadedContentBuilder->getPreloadedContent(
455 $title->toPageIdentity(),
456 $this->getAuthority(),
457 $this->params[
'preloadcustom'],
458 $this->params[
'preloadparams'] ?? [],
459 $newSection ?
'new' : null
461 $defaultContent = $newSection ? null :
462 $this->preloadedContentBuilder->getDefaultContent( $title->toPageIdentity() );
463 $contentIsDefault = $defaultContent ? $content->equals( $defaultContent ) : $content->isEmpty();
466 $pageInfo[
'preloadcontent'][
'contentmodel'] = $content->getModel();
467 $pageInfo[
'preloadcontent'][
'contentformat'] = $content->getDefaultFormat();
472 $pageInfo[
'preloadisdefault'] = $contentIsDefault;
476 if ( $this->fld_editintro ) {
478 $localizerWithPage =
new class( $this, $page ) implements MessageLocalizer {
479 private MessageLocalizer $base;
480 private PageReference $page;
482 public function __construct( MessageLocalizer $base, PageReference $page ) {
490 public function msg( $key, ...$params ) {
491 return $this->base->msg( $key, ...$params )->page( $this->page );
496 'lessframes' => IntroMessageBuilder::LESS_FRAMES,
497 'moreframes' => IntroMessageBuilder::MORE_FRAMES,
500 $revId = array_key_first( $this->
getPageSet()->getLiveRevisionIDs() );
501 $revRecord = $revId ? $this->revisionLookup->getRevisionById( $revId ) :
null;
503 $messages = $this->introMessageBuilder->getIntroMessages(
504 $styleParamMap[ $this->params[
'editintrostyle'] ],
505 $this->params[
'editintroskip'] ?? [],
507 $title->toPageIdentity(),
509 $this->getAuthority(),
510 $this->params[
'editintrocustom'],
518 $pageInfo[
'editintro'] = $messages;
521 if ( $this->fld_displaytitle ) {
522 $pageInfo[
'displaytitle'] = $this->displaytitles[$pageid] ??
523 htmlspecialchars( $this->titleFormatter->getPrefixedText( $page ), ENT_NOQUOTES );
526 if ( $this->fld_varianttitles && isset( $this->variantTitles[$pageid] ) ) {
527 $pageInfo[
'varianttitles'] = $this->variantTitles[$pageid];
530 if ( $this->fld_linkclasses && isset( $this->linkClasses[$pageid] ) ) {
531 $pageInfo[
'linkclasses'] = $this->linkClasses[$pageid];
534 if ( $this->params[
'testactions'] ) {
536 if ( $this->countTestedActions >= $limit ) {
540 $detailLevel = $this->params[
'testactionsdetail'];
542 if ( $errorFormatter->getFormat() ===
'bc' ) {
544 $errorFormatter = $errorFormatter->newWithFormat(
'plaintext' );
547 $pageInfo[
'actions'] = [];
548 if ( $this->params[
'testactionsautocreate'] ) {
549 $pageInfo[
'wouldautocreate'] = [];
552 foreach ( $this->params[
'testactions'] as $action ) {
553 $this->countTestedActions++;
555 $shouldAutoCreate = $this->tempUserCreator->shouldAutoCreate( $this->
getUser(), $action );
557 if ( $shouldAutoCreate ) {
558 $authority = $this->userFactory->newTempPlaceholder();
563 if ( $detailLevel ===
'boolean' ) {
564 $pageInfo[
'actions'][$action] = $authority->definitelyCan( $action, $page );
566 $status =
new PermissionStatus();
567 if ( $detailLevel ===
'quick' ) {
568 $authority->probablyCan( $action, $page, $status );
570 $authority->definitelyCan( $action, $page, $status );
573 $pageInfo[
'actions'][$action] = $errorFormatter->arrayFromStatus( $status );
576 if ( $this->params[
'testactionsautocreate'] ) {
577 $pageInfo[
'wouldautocreate'][$action] = $shouldAutoCreate;
588 private function getProtectionInfo() {
589 $this->protections = [];
592 if ( count( $this->titles ) ) {
595 $this->
addFields( [
'pr_page',
'pr_type',
'pr_level',
596 'pr_expiry',
'pr_cascade' ] );
597 $this->
addWhereFld(
'pr_page', array_keys( $this->titles ) );
599 $res = $this->
select( __METHOD__ );
600 foreach ( $res as $row ) {
602 $page = $this->titles[$row->pr_page];
604 'type' => $row->pr_type,
605 'level' => $row->pr_level,
608 if ( $row->pr_cascade ) {
609 $a[
'cascade'] =
true;
611 $this->protections[$page->getNamespace()][$page->getDBkey()][] = $a;
616 if ( count( $this->missing ) ) {
618 $lb = $this->linkBatchFactory->newLinkBatch( $this->missing );
620 $this->
addFields( [
'pt_title',
'pt_namespace',
'pt_create_perm',
'pt_expiry' ] );
621 $this->
addWhere( $lb->constructSet(
'pt', $this->getDB() ) );
622 $res = $this->
select( __METHOD__ );
623 foreach ( $res as $row ) {
624 $this->protections[$row->pt_namespace][$row->pt_title][] = [
626 'level' => $row->pt_create_perm,
634 $images = $others = [];
635 foreach ( $this->everything as $page ) {
636 if ( $page->getNamespace() ===
NS_FILE ) {
637 $images[] = $page->getDBkey();
642 $this->restrictionTypes[$page->getNamespace()][$page->getDBkey()] =
643 array_values( $this->restrictionStore->listApplicableRestrictionTypes( $page ) );
646 if ( count( $others ) ) {
648 $this->
addTables( [
'page_restrictions',
'page' ] );
649 $this->
addFields( [
'pr_type',
'pr_level',
'pr_expiry',
650 'page_title',
'page_namespace',
'page_id' ] );
651 $this->
addWhere(
'pr_page = page_id' );
654 $res = $this->
select( __METHOD__ );
656 $protectedPages = [];
657 foreach ( $res as $row ) {
658 $protectedPages[$row->page_id] = [
659 'type' => $row->pr_type,
660 'level' => $row->pr_level,
662 'source' => $this->titleFormatter->formatTitle( $row->page_namespace, $row->page_title ),
666 if ( $protectedPages ) {
669 $lb = $this->linkBatchFactory->newLinkBatch( $others );
671 $queryInfo = $this->linksMigration->getQueryInfo(
'templatelinks' );
672 $res = $this->
getDB()->newSelectQueryBuilder()
673 ->select( [
'tl_from',
'lt_namespace',
'lt_title' ] )
674 ->tables( $queryInfo[
'tables'] )
675 ->joinConds( $queryInfo[
'joins'] )
676 ->where( [
'tl_from' => array_keys( $protectedPages ) ] )
677 ->andWhere( $lb->constructSet(
'tl', $this->getDB() ) )
678 ->useIndex( [
'templatelinks' =>
'PRIMARY' ] )
679 ->caller( __METHOD__ )
682 foreach ( $res as $row ) {
683 $protection = $protectedPages[$row->tl_from];
684 $this->protections[$row->lt_namespace][$row->lt_title][] = $protection;
691 if ( count( $images ) ) {
693 $this->
addTables( [
'page_restrictions',
'page' ] );
694 $this->
addFields( [
'pr_type',
'pr_level',
'pr_expiry',
695 'page_title',
'page_namespace',
'page_id' ] );
696 $this->
addWhere(
'pr_page = page_id' );
699 $res = $this->
select( __METHOD__ );
701 $protectedPages = [];
702 foreach ( $res as $row ) {
703 $protectedPages[$row->page_id] = [
704 'type' => $row->pr_type,
705 'level' => $row->pr_level,
707 'source' => $this->titleFormatter->formatTitle( $row->page_namespace, $row->page_title ),
711 if ( $protectedPages ) {
714 $queryInfo = $this->linksMigration->getQueryInfo(
'imagelinks' );
716 $res = $this->
getDB()->newSelectQueryBuilder()
717 ->fields( [
'il_from',
'lt_title' ] )
718 ->tables( $queryInfo[
'tables'] )
719 ->where( [
'il_from' => array_keys( $protectedPages ) ] )
720 ->joinConds( $queryInfo[
'joins'] )
721 ->andWhere( [
'lt_title' => $images,
'lt_namespace' =>
NS_FILE ] )
724 ->useIndex( [
'imagelinks' =>
'PRIMARY' ] )
725 ->caller( __METHOD__ )
728 foreach ( $res as $row ) {
729 $protection = $protectedPages[$row->il_from];
730 $this->protections[
NS_FILE][$row->lt_title][] = $protection;
742 private function getTSIDs() {
743 $getTitles = $this->talkids = $this->subjectids = [];
744 $nsInfo = $this->namespaceInfo;
747 foreach ( $this->everything as $page ) {
748 if ( $nsInfo->isTalk( $page->getNamespace() ) ) {
749 if ( $this->fld_subjectid ) {
750 $getTitles[] = $nsInfo->getSubjectPage( TitleValue::newFromPage( $page ) );
752 } elseif ( $this->fld_talkid ) {
753 $getTitles[] = $nsInfo->getTalkPage( TitleValue::newFromPage( $page ) );
756 if ( $getTitles === [] ) {
760 $db = $this->
getDB();
764 $lb = $this->linkBatchFactory->newLinkBatch( $getTitles );
767 $this->
addFields( [
'page_title',
'page_namespace',
'page_id' ] );
768 $this->
addWhere( $lb->constructSet(
'page', $db ) );
769 $res = $this->
select( __METHOD__ );
770 foreach ( $res as $row ) {
771 if ( $nsInfo->isTalk( $row->page_namespace ) ) {
772 $this->talkids[$nsInfo->getSubject( $row->page_namespace )][$row->page_title] =
773 (int)( $row->page_id );
775 $this->subjectids[$nsInfo->getTalk( $row->page_namespace )][$row->page_title] =
776 (int)( $row->page_id );
781 private function getDisplayTitle() {
782 $this->displaytitles = [];
784 $pageIds = array_keys( $this->titles );
786 if ( $pageIds === [] ) {
792 $this->
addFields( [
'pp_page',
'pp_value' ] );
794 $this->
addWhereFld(
'pp_propname',
'displaytitle' );
795 $res = $this->
select( __METHOD__ );
797 foreach ( $res as $row ) {
798 $this->displaytitles[$row->pp_page] = $row->pp_value;
812 private function getLinkClasses( ?LinkTarget $context_title =
null,
bool $default_link_caption =
false ) {
813 if ( $this->titles === [] ) {
824 foreach ( $this->titles as $pageId => $page ) {
825 $pdbk = $this->titleFormatter->getPrefixedDBkey( $page );
826 $pagemap[$pageId] = $pdbk;
827 $classes[$pdbk] = $this->linkRenderer->getLinkClasses( $page, $default_link_caption );
830 $context_title = $this->titleFactory->newFromLinkTarget(
831 $context_title ?? $this->titleFactory->newMainPage()
834 $pagemap, $classes, $context_title
841 $this->linkClasses = [];
842 foreach ( $this->titles as $pageId => $page ) {
843 $pdbk = $this->titleFormatter->getPrefixedDBkey( $page );
844 $this->linkClasses[$pageId] = preg_split(
845 '/\s+/', $classes[$pdbk] ??
'', -1, PREG_SPLIT_NO_EMPTY
850 private function getVariantTitles() {
851 if ( $this->titles === [] ) {
854 $this->variantTitles = [];
855 foreach ( $this->titles as $pageId => $page ) {
856 $this->variantTitles[$pageId] = isset( $this->displaytitles[$pageId] )
857 ? $this->getAllVariants( $this->displaytitles[$pageId] )
858 : $this->getAllVariants( $this->titleFormatter->getText( $page ), $page->getNamespace() );
862 private function getAllVariants(
string $text,
int $ns =
NS_MAIN ): array {
864 foreach ( $this->languageConverter->getVariants() as $variant ) {
865 $convertTitle = $this->languageConverter->autoConvert( $text, $variant );
867 $convertNs = $this->languageConverter->convertNamespace( $ns, $variant );
868 $convertTitle = $convertNs .
':' . $convertTitle;
870 $result[$variant] = $convertTitle;
879 private function getWatchedInfo() {
882 if ( !$user->isRegistered() || count( $this->everything ) == 0
883 || !$this->
getAuthority()->isAllowed(
'viewmywatchlist' )
889 $this->watchlistExpiries = [];
890 $this->watchlistLabels = [];
891 $this->notificationtimestamps = [];
893 $items = $this->watchedItemStore->loadWatchedItemsBatch( $user, $this->everything );
895 foreach ( $items as $item ) {
896 $nsId = $item->getTarget()->getNamespace();
897 $dbKey = $item->getTarget()->getDBkey();
899 if ( $this->fld_watched ) {
900 $this->watched[$nsId][$dbKey] =
true;
902 $expiry = $item->getExpiry( TS::ISO_8601 );
904 $this->watchlistExpiries[$nsId][$dbKey] = $expiry;
908 if ( $this->fld_watchlistlabels ) {
909 $labels = $item->getLabels();
912 foreach ( $labels as $label ) {
914 'id' => $label->getId(),
915 'name' => $label->getName(),
918 $this->watchlistLabels[$nsId][$dbKey] = $labelData;
922 if ( $this->fld_notificationtimestamp ) {
923 $this->notificationtimestamps[$nsId][$dbKey] = $item->getNotificationTimestamp();
931 private function getWatcherInfo() {
932 if ( count( $this->everything ) == 0 ) {
936 $canUnwatchedpages = $this->
getAuthority()->isAllowed(
'unwatchedpages' );
937 $unwatchedPageThreshold =
939 if ( !$canUnwatchedpages && !is_int( $unwatchedPageThreshold ) ) {
943 $this->showZeroWatchers = $canUnwatchedpages;
946 if ( !$canUnwatchedpages ) {
947 $countOptions[
'minimumWatchers'] = $unwatchedPageThreshold;
950 $this->watchers = $this->watchedItemStore->countWatchersMultiple(
962 private function getVisitingWatcherInfo() {
964 $db = $this->
getDB();
966 $canUnwatchedpages = $this->
getAuthority()->isAllowed(
'unwatchedpages' );
968 if ( !$canUnwatchedpages && !is_int( $unwatchedPageThreshold ) ) {
972 $this->showZeroWatchers = $canUnwatchedpages;
974 $titlesWithThresholds = [];
975 if ( $this->titles ) {
976 $lb = $this->linkBatchFactory->newLinkBatch( $this->titles );
979 $this->resetQueryParams();
980 $this->
addTables( [
'page',
'revision' ] );
981 $this->
addFields( [
'page_namespace',
'page_title',
'rev_timestamp' ] );
983 'page_latest = rev_id',
984 $lb->constructSet(
'page', $db ),
986 $this->addOption(
'GROUP BY', [
'page_namespace',
'page_title' ] );
987 $timestampRes = $this->select( __METHOD__ );
991 foreach ( $timestampRes as $row ) {
992 $revTimestamp =
wfTimestamp( TS::UNIX, (
int)$row->rev_timestamp );
993 $timestamps[$row->page_namespace][$row->page_title] = (int)$revTimestamp - $age;
995 $titlesWithThresholds = array_map(
996 static function ( PageReference $target ) use ( $timestamps ) {
998 $target, $timestamps[$target->getNamespace()][$target->getDBkey()]
1005 if ( $this->missing ) {
1006 $titlesWithThresholds = array_merge(
1007 $titlesWithThresholds,
1009 static function ( PageReference $target ) {
1010 return [ $target, null ];
1016 $this->visitingwatchers = $this->watchedItemStore->countVisitingWatchersMultiple(
1017 $titlesWithThresholds,
1018 !$canUnwatchedpages ? $unwatchedPageThreshold : null
1035 if ( array_diff( (array)$params[
'prop'], $publicProps ) ) {
1040 if ( $params[
'testactions'] ) {
1051 ParamValidator::PARAM_ISMULTI =>
true,
1052 ParamValidator::PARAM_TYPE => [
1055 'watched', #
private
1056 'watchlistlabels', #
private
1057 'watchers', #
private
1058 'visitingwatchers', #
private
1059 'notificationtimestamp', #
private
1063 'readable', #
private
1065 'preloadcontent', #
private: checks current user
's permissions
1066 'editintro
', # private: checks current user's permissions
1069 'linkclasses', #
private: stub length (and possibly hook colors)
1074 EnumDef::PARAM_DEPRECATED_VALUES => [
1080 ParamValidator::PARAM_TYPE =>
'title',
1081 ParamValidator::PARAM_DEFAULT => $this->titleFactory->newMainPage()->getPrefixedText(),
1082 TitleDef::PARAM_RETURN_OBJECT =>
true,
1084 'defaultlinkcaption' => [
1085 ParamValidator::PARAM_TYPE =>
'boolean',
1086 ParamValidator::PARAM_DEFAULT =>
false,
1089 ParamValidator::PARAM_TYPE =>
'string',
1090 ParamValidator::PARAM_ISMULTI =>
true,
1092 'testactionsdetail' => [
1093 ParamValidator::PARAM_TYPE => [
'boolean',
'full',
'quick' ],
1094 ParamValidator::PARAM_DEFAULT =>
'boolean',
1097 'testactionsautocreate' =>
false,
1098 'preloadcustom' => [
1101 ParamValidator::PARAM_TYPE =>
'string',
1104 'preloadparams' => [
1105 ParamValidator::PARAM_ISMULTI =>
true,
1108 'preloadnewsection' => [
1109 ParamValidator::PARAM_TYPE =>
'boolean',
1110 ParamValidator::PARAM_DEFAULT =>
false,
1113 'editintrostyle' => [
1114 ParamValidator::PARAM_TYPE => [
'lessframes',
'moreframes' ],
1115 ParamValidator::PARAM_DEFAULT =>
'moreframes',
1118 'editintroskip' => [
1119 ParamValidator::PARAM_TYPE =>
'string',
1120 ParamValidator::PARAM_ISMULTI =>
true,
1123 'editintrocustom' => [
1126 ParamValidator::PARAM_TYPE =>
'string',
1137 $title = Title::newMainPage()->getPrefixedText();
1138 $mp = rawurlencode( $title );
1141 "action=query&prop=info&titles={$mp}"
1142 =>
'apihelp-query+info-example-simple',
1143 "action=query&prop=info&inprop=protection&titles={$mp}"
1144 =>
'apihelp-query+info-example-protection',
1150 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Info';