MediaWiki  1.32.0
ApiQueryInfo.php
Go to the documentation of this file.
1 <?php
24 
30 class ApiQueryInfo extends ApiQueryBase {
31 
32  private $fld_protection = false, $fld_talkid = false,
33  $fld_subjectid = false, $fld_url = false,
34  $fld_readable = false, $fld_watched = false,
38 
39  private $params;
40 
42  private $titles;
44  private $missing;
46  private $everything;
47 
50 
53  private $showZeroWatchers = false;
54 
55  private $tokenFunctions;
56 
57  private $countTestedActions = 0;
58 
59  public function __construct( ApiQuery $query, $moduleName ) {
60  parent::__construct( $query, $moduleName, 'in' );
61  }
62 
67  public function requestExtraData( $pageSet ) {
68  $pageSet->requestField( 'page_restrictions' );
69  // If the pageset is resolving redirects we won't get page_is_redirect.
70  // But we can't know for sure until the pageset is executed (revids may
71  // turn it off), so request it unconditionally.
72  $pageSet->requestField( 'page_is_redirect' );
73  $pageSet->requestField( 'page_is_new' );
74  $config = $this->getConfig();
75  $pageSet->requestField( 'page_touched' );
76  $pageSet->requestField( 'page_latest' );
77  $pageSet->requestField( 'page_len' );
78  if ( $config->get( 'ContentHandlerUseDB' ) ) {
79  $pageSet->requestField( 'page_content_model' );
80  }
81  if ( $config->get( 'PageLanguageUseDB' ) ) {
82  $pageSet->requestField( 'page_lang' );
83  }
84  }
85 
93  protected function getTokenFunctions() {
94  // Don't call the hooks twice
95  if ( isset( $this->tokenFunctions ) ) {
96  return $this->tokenFunctions;
97  }
98 
99  // If we're in a mode that breaks the same-origin policy, no tokens can
100  // be obtained
101  if ( $this->lacksSameOriginSecurity() ) {
102  return [];
103  }
104 
105  $this->tokenFunctions = [
106  'edit' => [ self::class, 'getEditToken' ],
107  'delete' => [ self::class, 'getDeleteToken' ],
108  'protect' => [ self::class, 'getProtectToken' ],
109  'move' => [ self::class, 'getMoveToken' ],
110  'block' => [ self::class, 'getBlockToken' ],
111  'unblock' => [ self::class, 'getUnblockToken' ],
112  'email' => [ self::class, 'getEmailToken' ],
113  'import' => [ self::class, 'getImportToken' ],
114  'watch' => [ self::class, 'getWatchToken' ],
115  ];
116  Hooks::run( 'APIQueryInfoTokens', [ &$this->tokenFunctions ] );
117 
118  return $this->tokenFunctions;
119  }
120 
121  static protected $cachedTokens = [];
122 
126  public static function resetTokenCache() {
127  self::$cachedTokens = [];
128  }
129 
133  public static function getEditToken( $pageid, $title ) {
134  // We could check for $title->userCan('edit') here,
135  // but that's too expensive for this purpose
136  // and would break caching
137  global $wgUser;
138  if ( !$wgUser->isAllowed( 'edit' ) ) {
139  return false;
140  }
141 
142  // The token is always the same, let's exploit that
143  if ( !isset( self::$cachedTokens['edit'] ) ) {
144  self::$cachedTokens['edit'] = $wgUser->getEditToken();
145  }
146 
147  return self::$cachedTokens['edit'];
148  }
149 
153  public static function getDeleteToken( $pageid, $title ) {
154  global $wgUser;
155  if ( !$wgUser->isAllowed( 'delete' ) ) {
156  return false;
157  }
158 
159  // The token is always the same, let's exploit that
160  if ( !isset( self::$cachedTokens['delete'] ) ) {
161  self::$cachedTokens['delete'] = $wgUser->getEditToken();
162  }
163 
164  return self::$cachedTokens['delete'];
165  }
166 
170  public static function getProtectToken( $pageid, $title ) {
171  global $wgUser;
172  if ( !$wgUser->isAllowed( 'protect' ) ) {
173  return false;
174  }
175 
176  // The token is always the same, let's exploit that
177  if ( !isset( self::$cachedTokens['protect'] ) ) {
178  self::$cachedTokens['protect'] = $wgUser->getEditToken();
179  }
180 
181  return self::$cachedTokens['protect'];
182  }
183 
187  public static function getMoveToken( $pageid, $title ) {
188  global $wgUser;
189  if ( !$wgUser->isAllowed( 'move' ) ) {
190  return false;
191  }
192 
193  // The token is always the same, let's exploit that
194  if ( !isset( self::$cachedTokens['move'] ) ) {
195  self::$cachedTokens['move'] = $wgUser->getEditToken();
196  }
197 
198  return self::$cachedTokens['move'];
199  }
200 
204  public static function getBlockToken( $pageid, $title ) {
205  global $wgUser;
206  if ( !$wgUser->isAllowed( 'block' ) ) {
207  return false;
208  }
209 
210  // The token is always the same, let's exploit that
211  if ( !isset( self::$cachedTokens['block'] ) ) {
212  self::$cachedTokens['block'] = $wgUser->getEditToken();
213  }
214 
215  return self::$cachedTokens['block'];
216  }
217 
221  public static function getUnblockToken( $pageid, $title ) {
222  // Currently, this is exactly the same as the block token
223  return self::getBlockToken( $pageid, $title );
224  }
225 
229  public static function getEmailToken( $pageid, $title ) {
230  global $wgUser;
231  if ( !$wgUser->canSendEmail() || $wgUser->isBlockedFromEmailuser() ) {
232  return false;
233  }
234 
235  // The token is always the same, let's exploit that
236  if ( !isset( self::$cachedTokens['email'] ) ) {
237  self::$cachedTokens['email'] = $wgUser->getEditToken();
238  }
239 
240  return self::$cachedTokens['email'];
241  }
242 
246  public static function getImportToken( $pageid, $title ) {
247  global $wgUser;
248  if ( !$wgUser->isAllowedAny( 'import', 'importupload' ) ) {
249  return false;
250  }
251 
252  // The token is always the same, let's exploit that
253  if ( !isset( self::$cachedTokens['import'] ) ) {
254  self::$cachedTokens['import'] = $wgUser->getEditToken();
255  }
256 
257  return self::$cachedTokens['import'];
258  }
259 
263  public static function getWatchToken( $pageid, $title ) {
264  global $wgUser;
265  if ( !$wgUser->isLoggedIn() ) {
266  return false;
267  }
268 
269  // The token is always the same, let's exploit that
270  if ( !isset( self::$cachedTokens['watch'] ) ) {
271  self::$cachedTokens['watch'] = $wgUser->getEditToken( 'watch' );
272  }
273 
274  return self::$cachedTokens['watch'];
275  }
276 
280  public static function getOptionsToken( $pageid, $title ) {
281  global $wgUser;
282  if ( !$wgUser->isLoggedIn() ) {
283  return false;
284  }
285 
286  // The token is always the same, let's exploit that
287  if ( !isset( self::$cachedTokens['options'] ) ) {
288  self::$cachedTokens['options'] = $wgUser->getEditToken();
289  }
290 
291  return self::$cachedTokens['options'];
292  }
293 
294  public function execute() {
295  $this->params = $this->extractRequestParams();
296  if ( !is_null( $this->params['prop'] ) ) {
297  $prop = array_flip( $this->params['prop'] );
298  $this->fld_protection = isset( $prop['protection'] );
299  $this->fld_watched = isset( $prop['watched'] );
300  $this->fld_watchers = isset( $prop['watchers'] );
301  $this->fld_visitingwatchers = isset( $prop['visitingwatchers'] );
302  $this->fld_notificationtimestamp = isset( $prop['notificationtimestamp'] );
303  $this->fld_talkid = isset( $prop['talkid'] );
304  $this->fld_subjectid = isset( $prop['subjectid'] );
305  $this->fld_url = isset( $prop['url'] );
306  $this->fld_readable = isset( $prop['readable'] );
307  $this->fld_preload = isset( $prop['preload'] );
308  $this->fld_displaytitle = isset( $prop['displaytitle'] );
309  $this->fld_varianttitles = isset( $prop['varianttitles'] );
310  }
311 
312  $pageSet = $this->getPageSet();
313  $this->titles = $pageSet->getGoodTitles();
314  $this->missing = $pageSet->getMissingTitles();
315  $this->everything = $this->titles + $this->missing;
316  $result = $this->getResult();
317 
318  uasort( $this->everything, [ Title::class, 'compare' ] );
319  if ( !is_null( $this->params['continue'] ) ) {
320  // Throw away any titles we're gonna skip so they don't
321  // clutter queries
322  $cont = explode( '|', $this->params['continue'] );
323  $this->dieContinueUsageIf( count( $cont ) != 2 );
324  $conttitle = Title::makeTitleSafe( $cont[0], $cont[1] );
325  foreach ( $this->everything as $pageid => $title ) {
326  if ( Title::compare( $title, $conttitle ) >= 0 ) {
327  break;
328  }
329  unset( $this->titles[$pageid] );
330  unset( $this->missing[$pageid] );
331  unset( $this->everything[$pageid] );
332  }
333  }
334 
335  $this->pageRestrictions = $pageSet->getCustomField( 'page_restrictions' );
336  // when resolving redirects, no page will have this field
337  $this->pageIsRedir = !$pageSet->isResolvingRedirects()
338  ? $pageSet->getCustomField( 'page_is_redirect' )
339  : [];
340  $this->pageIsNew = $pageSet->getCustomField( 'page_is_new' );
341 
342  $this->pageTouched = $pageSet->getCustomField( 'page_touched' );
343  $this->pageLatest = $pageSet->getCustomField( 'page_latest' );
344  $this->pageLength = $pageSet->getCustomField( 'page_len' );
345 
346  // Get protection info if requested
347  if ( $this->fld_protection ) {
348  $this->getProtectionInfo();
349  }
350 
351  if ( $this->fld_watched || $this->fld_notificationtimestamp ) {
352  $this->getWatchedInfo();
353  }
354 
355  if ( $this->fld_watchers ) {
356  $this->getWatcherInfo();
357  }
358 
359  if ( $this->fld_visitingwatchers ) {
360  $this->getVisitingWatcherInfo();
361  }
362 
363  // Run the talkid/subjectid query if requested
364  if ( $this->fld_talkid || $this->fld_subjectid ) {
365  $this->getTSIDs();
366  }
367 
368  if ( $this->fld_displaytitle ) {
369  $this->getDisplayTitle();
370  }
371 
372  if ( $this->fld_varianttitles ) {
373  $this->getVariantTitles();
374  }
375 
377  foreach ( $this->everything as $pageid => $title ) {
378  $pageInfo = $this->extractPageInfo( $pageid, $title );
379  $fit = $pageInfo !== null && $result->addValue( [
380  'query',
381  'pages'
382  ], $pageid, $pageInfo );
383  if ( !$fit ) {
384  $this->setContinueEnumParameter( 'continue',
385  $title->getNamespace() . '|' .
386  $title->getText() );
387  break;
388  }
389  }
390  }
391 
398  private function extractPageInfo( $pageid, $title ) {
399  $pageInfo = [];
400  // $title->exists() needs pageid, which is not set for all title objects
401  $titleExists = $pageid > 0;
402  $ns = $title->getNamespace();
403  $dbkey = $title->getDBkey();
404 
405  $pageInfo['contentmodel'] = $title->getContentModel();
406 
407  $pageLanguage = $title->getPageLanguage();
408  $pageInfo['pagelanguage'] = $pageLanguage->getCode();
409  $pageInfo['pagelanguagehtmlcode'] = $pageLanguage->getHtmlCode();
410  $pageInfo['pagelanguagedir'] = $pageLanguage->getDir();
411 
412  if ( $titleExists ) {
413  $pageInfo['touched'] = wfTimestamp( TS_ISO_8601, $this->pageTouched[$pageid] );
414  $pageInfo['lastrevid'] = intval( $this->pageLatest[$pageid] );
415  $pageInfo['length'] = intval( $this->pageLength[$pageid] );
416 
417  if ( isset( $this->pageIsRedir[$pageid] ) && $this->pageIsRedir[$pageid] ) {
418  $pageInfo['redirect'] = true;
419  }
420  if ( $this->pageIsNew[$pageid] ) {
421  $pageInfo['new'] = true;
422  }
423  }
424 
425  if ( !is_null( $this->params['token'] ) ) {
427  $pageInfo['starttimestamp'] = wfTimestamp( TS_ISO_8601, time() );
428  foreach ( $this->params['token'] as $t ) {
429  $val = call_user_func( $tokenFunctions[$t], $pageid, $title );
430  if ( $val === false ) {
431  $this->addWarning( [ 'apiwarn-tokennotallowed', $t ] );
432  } else {
433  $pageInfo[$t . 'token'] = $val;
434  }
435  }
436  }
437 
438  if ( $this->fld_protection ) {
439  $pageInfo['protection'] = [];
440  if ( isset( $this->protections[$ns][$dbkey] ) ) {
441  $pageInfo['protection'] =
442  $this->protections[$ns][$dbkey];
443  }
444  ApiResult::setIndexedTagName( $pageInfo['protection'], 'pr' );
445 
446  $pageInfo['restrictiontypes'] = [];
447  if ( isset( $this->restrictionTypes[$ns][$dbkey] ) ) {
448  $pageInfo['restrictiontypes'] =
449  $this->restrictionTypes[$ns][$dbkey];
450  }
451  ApiResult::setIndexedTagName( $pageInfo['restrictiontypes'], 'rt' );
452  }
453 
454  if ( $this->fld_watched && $this->watched !== null ) {
455  $pageInfo['watched'] = $this->watched[$ns][$dbkey];
456  }
457 
458  if ( $this->fld_watchers ) {
459  if ( $this->watchers !== null && $this->watchers[$ns][$dbkey] !== 0 ) {
460  $pageInfo['watchers'] = $this->watchers[$ns][$dbkey];
461  } elseif ( $this->showZeroWatchers ) {
462  $pageInfo['watchers'] = 0;
463  }
464  }
465 
466  if ( $this->fld_visitingwatchers ) {
467  if ( $this->visitingwatchers !== null && $this->visitingwatchers[$ns][$dbkey] !== 0 ) {
468  $pageInfo['visitingwatchers'] = $this->visitingwatchers[$ns][$dbkey];
469  } elseif ( $this->showZeroWatchers ) {
470  $pageInfo['visitingwatchers'] = 0;
471  }
472  }
473 
474  if ( $this->fld_notificationtimestamp ) {
475  $pageInfo['notificationtimestamp'] = '';
476  if ( $this->notificationtimestamps[$ns][$dbkey] ) {
477  $pageInfo['notificationtimestamp'] =
478  wfTimestamp( TS_ISO_8601, $this->notificationtimestamps[$ns][$dbkey] );
479  }
480  }
481 
482  if ( $this->fld_talkid && isset( $this->talkids[$ns][$dbkey] ) ) {
483  $pageInfo['talkid'] = $this->talkids[$ns][$dbkey];
484  }
485 
486  if ( $this->fld_subjectid && isset( $this->subjectids[$ns][$dbkey] ) ) {
487  $pageInfo['subjectid'] = $this->subjectids[$ns][$dbkey];
488  }
489 
490  if ( $this->fld_url ) {
491  $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
492  $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ), PROTO_CURRENT );
493  $pageInfo['canonicalurl'] = wfExpandUrl( $title->getFullURL(), PROTO_CANONICAL );
494  }
495  if ( $this->fld_readable ) {
496  $pageInfo['readable'] = $title->userCan( 'read', $this->getUser() );
497  }
498 
499  if ( $this->fld_preload ) {
500  if ( $titleExists ) {
501  $pageInfo['preload'] = '';
502  } else {
503  $text = null;
504  Hooks::run( 'EditFormPreloadText', [ &$text, &$title ] );
505 
506  $pageInfo['preload'] = $text;
507  }
508  }
509 
510  if ( $this->fld_displaytitle ) {
511  if ( isset( $this->displaytitles[$pageid] ) ) {
512  $pageInfo['displaytitle'] = $this->displaytitles[$pageid];
513  } else {
514  $pageInfo['displaytitle'] = $title->getPrefixedText();
515  }
516  }
517 
518  if ( $this->fld_varianttitles ) {
519  if ( isset( $this->variantTitles[$pageid] ) ) {
520  $pageInfo['varianttitles'] = $this->variantTitles[$pageid];
521  }
522  }
523 
524  if ( $this->params['testactions'] ) {
525  $limit = $this->getMain()->canApiHighLimits() ? self::LIMIT_SML2 : self::LIMIT_SML1;
526  if ( $this->countTestedActions >= $limit ) {
527  return null; // force a continuation
528  }
529 
530  $detailLevel = $this->params['testactionsdetail'];
531  $rigor = $detailLevel === 'quick' ? 'quick' : 'secure';
532  $errorFormatter = $this->getErrorFormatter();
533  if ( $errorFormatter->getFormat() === 'bc' ) {
534  // Eew, no. Use a more modern format here.
535  $errorFormatter = $errorFormatter->newWithFormat( 'plaintext' );
536  }
537 
538  $user = $this->getUser();
539  $pageInfo['actions'] = [];
540  foreach ( $this->params['testactions'] as $action ) {
541  $this->countTestedActions++;
542 
543  if ( $detailLevel === 'boolean' ) {
544  $pageInfo['actions'][$action] = $title->userCan( $action, $user );
545  } else {
546  $pageInfo['actions'][$action] = $errorFormatter->arrayFromStatus( $this->errorArrayToStatus(
547  $title->getUserPermissionsErrors( $action, $user, $rigor ),
548  $user
549  ) );
550  }
551  }
552  }
553 
554  return $pageInfo;
555  }
556 
560  private function getProtectionInfo() {
561  $this->protections = [];
562  $db = $this->getDB();
563 
564  // Get normal protections for existing titles
565  if ( count( $this->titles ) ) {
566  $this->resetQueryParams();
567  $this->addTables( 'page_restrictions' );
568  $this->addFields( [ 'pr_page', 'pr_type', 'pr_level',
569  'pr_expiry', 'pr_cascade' ] );
570  $this->addWhereFld( 'pr_page', array_keys( $this->titles ) );
571 
572  $res = $this->select( __METHOD__ );
573  foreach ( $res as $row ) {
575  $title = $this->titles[$row->pr_page];
576  $a = [
577  'type' => $row->pr_type,
578  'level' => $row->pr_level,
579  'expiry' => ApiResult::formatExpiry( $row->pr_expiry )
580  ];
581  if ( $row->pr_cascade ) {
582  $a['cascade'] = true;
583  }
584  $this->protections[$title->getNamespace()][$title->getDBkey()][] = $a;
585  }
586  // Also check old restrictions
587  foreach ( $this->titles as $pageId => $title ) {
588  if ( $this->pageRestrictions[$pageId] ) {
589  $namespace = $title->getNamespace();
590  $dbKey = $title->getDBkey();
591  $restrictions = explode( ':', trim( $this->pageRestrictions[$pageId] ) );
592  foreach ( $restrictions as $restrict ) {
593  $temp = explode( '=', trim( $restrict ) );
594  if ( count( $temp ) == 1 ) {
595  // old old format should be treated as edit/move restriction
596  $restriction = trim( $temp[0] );
597 
598  if ( $restriction == '' ) {
599  continue;
600  }
601  $this->protections[$namespace][$dbKey][] = [
602  'type' => 'edit',
603  'level' => $restriction,
604  'expiry' => 'infinity',
605  ];
606  $this->protections[$namespace][$dbKey][] = [
607  'type' => 'move',
608  'level' => $restriction,
609  'expiry' => 'infinity',
610  ];
611  } else {
612  $restriction = trim( $temp[1] );
613  if ( $restriction == '' ) {
614  continue;
615  }
616  $this->protections[$namespace][$dbKey][] = [
617  'type' => $temp[0],
618  'level' => $restriction,
619  'expiry' => 'infinity',
620  ];
621  }
622  }
623  }
624  }
625  }
626 
627  // Get protections for missing titles
628  if ( count( $this->missing ) ) {
629  $this->resetQueryParams();
630  $lb = new LinkBatch( $this->missing );
631  $this->addTables( 'protected_titles' );
632  $this->addFields( [ 'pt_title', 'pt_namespace', 'pt_create_perm', 'pt_expiry' ] );
633  $this->addWhere( $lb->constructSet( 'pt', $db ) );
634  $res = $this->select( __METHOD__ );
635  foreach ( $res as $row ) {
636  $this->protections[$row->pt_namespace][$row->pt_title][] = [
637  'type' => 'create',
638  'level' => $row->pt_create_perm,
639  'expiry' => ApiResult::formatExpiry( $row->pt_expiry )
640  ];
641  }
642  }
643 
644  // Separate good and missing titles into files and other pages
645  // and populate $this->restrictionTypes
646  $images = $others = [];
647  foreach ( $this->everything as $title ) {
648  if ( $title->getNamespace() == NS_FILE ) {
649  $images[] = $title->getDBkey();
650  } else {
651  $others[] = $title;
652  }
653  // Applicable protection types
654  $this->restrictionTypes[$title->getNamespace()][$title->getDBkey()] =
655  array_values( $title->getRestrictionTypes() );
656  }
657 
658  if ( count( $others ) ) {
659  // Non-images: check templatelinks
660  $lb = new LinkBatch( $others );
661  $this->resetQueryParams();
662  $this->addTables( [ 'page_restrictions', 'page', 'templatelinks' ] );
663  $this->addFields( [ 'pr_type', 'pr_level', 'pr_expiry',
664  'page_title', 'page_namespace',
665  'tl_title', 'tl_namespace' ] );
666  $this->addWhere( $lb->constructSet( 'tl', $db ) );
667  $this->addWhere( 'pr_page = page_id' );
668  $this->addWhere( 'pr_page = tl_from' );
669  $this->addWhereFld( 'pr_cascade', 1 );
670 
671  $res = $this->select( __METHOD__ );
672  foreach ( $res as $row ) {
673  $source = Title::makeTitle( $row->page_namespace, $row->page_title );
674  $this->protections[$row->tl_namespace][$row->tl_title][] = [
675  'type' => $row->pr_type,
676  'level' => $row->pr_level,
677  'expiry' => ApiResult::formatExpiry( $row->pr_expiry ),
678  'source' => $source->getPrefixedText()
679  ];
680  }
681  }
682 
683  if ( count( $images ) ) {
684  // Images: check imagelinks
685  $this->resetQueryParams();
686  $this->addTables( [ 'page_restrictions', 'page', 'imagelinks' ] );
687  $this->addFields( [ 'pr_type', 'pr_level', 'pr_expiry',
688  'page_title', 'page_namespace', 'il_to' ] );
689  $this->addWhere( 'pr_page = page_id' );
690  $this->addWhere( 'pr_page = il_from' );
691  $this->addWhereFld( 'pr_cascade', 1 );
692  $this->addWhereFld( 'il_to', $images );
693 
694  $res = $this->select( __METHOD__ );
695  foreach ( $res as $row ) {
696  $source = Title::makeTitle( $row->page_namespace, $row->page_title );
697  $this->protections[NS_FILE][$row->il_to][] = [
698  'type' => $row->pr_type,
699  'level' => $row->pr_level,
700  'expiry' => ApiResult::formatExpiry( $row->pr_expiry ),
701  'source' => $source->getPrefixedText()
702  ];
703  }
704  }
705  }
706 
711  private function getTSIDs() {
712  $getTitles = $this->talkids = $this->subjectids = [];
713 
715  foreach ( $this->everything as $t ) {
716  if ( MWNamespace::isTalk( $t->getNamespace() ) ) {
717  if ( $this->fld_subjectid ) {
718  $getTitles[] = $t->getSubjectPage();
719  }
720  } elseif ( $this->fld_talkid ) {
721  $getTitles[] = $t->getTalkPage();
722  }
723  }
724  if ( !count( $getTitles ) ) {
725  return;
726  }
727 
728  $db = $this->getDB();
729 
730  // Construct a custom WHERE clause that matches
731  // all titles in $getTitles
732  $lb = new LinkBatch( $getTitles );
733  $this->resetQueryParams();
734  $this->addTables( 'page' );
735  $this->addFields( [ 'page_title', 'page_namespace', 'page_id' ] );
736  $this->addWhere( $lb->constructSet( 'page', $db ) );
737  $res = $this->select( __METHOD__ );
738  foreach ( $res as $row ) {
739  if ( MWNamespace::isTalk( $row->page_namespace ) ) {
740  $this->talkids[MWNamespace::getSubject( $row->page_namespace )][$row->page_title] =
741  intval( $row->page_id );
742  } else {
743  $this->subjectids[MWNamespace::getTalk( $row->page_namespace )][$row->page_title] =
744  intval( $row->page_id );
745  }
746  }
747  }
748 
749  private function getDisplayTitle() {
750  $this->displaytitles = [];
751 
752  $pageIds = array_keys( $this->titles );
753 
754  if ( !count( $pageIds ) ) {
755  return;
756  }
757 
758  $this->resetQueryParams();
759  $this->addTables( 'page_props' );
760  $this->addFields( [ 'pp_page', 'pp_value' ] );
761  $this->addWhereFld( 'pp_page', $pageIds );
762  $this->addWhereFld( 'pp_propname', 'displaytitle' );
763  $res = $this->select( __METHOD__ );
764 
765  foreach ( $res as $row ) {
766  $this->displaytitles[$row->pp_page] = $row->pp_value;
767  }
768  }
769 
770  private function getVariantTitles() {
771  if ( !count( $this->titles ) ) {
772  return;
773  }
774  $this->variantTitles = [];
775  foreach ( $this->titles as $pageId => $t ) {
776  $this->variantTitles[$pageId] = isset( $this->displaytitles[$pageId] )
777  ? $this->getAllVariants( $this->displaytitles[$pageId] )
778  : $this->getAllVariants( $t->getText(), $t->getNamespace() );
779  }
780  }
781 
782  private function getAllVariants( $text, $ns = NS_MAIN ) {
783  $result = [];
784  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
785  foreach ( $contLang->getVariants() as $variant ) {
786  $convertTitle = $contLang->autoConvert( $text, $variant );
787  if ( $ns !== NS_MAIN ) {
788  $convertNs = $contLang->convertNamespace( $ns, $variant );
789  $convertTitle = $convertNs . ':' . $convertTitle;
790  }
791  $result[$variant] = $convertTitle;
792  }
793  return $result;
794  }
795 
800  private function getWatchedInfo() {
801  $user = $this->getUser();
802 
803  if ( $user->isAnon() || count( $this->everything ) == 0
804  || !$user->isAllowed( 'viewmywatchlist' )
805  ) {
806  return;
807  }
808 
809  $this->watched = [];
810  $this->notificationtimestamps = [];
811 
812  $store = MediaWikiServices::getInstance()->getWatchedItemStore();
813  $timestamps = $store->getNotificationTimestampsBatch( $user, $this->everything );
814 
815  if ( $this->fld_watched ) {
816  foreach ( $timestamps as $namespaceId => $dbKeys ) {
817  $this->watched[$namespaceId] = array_map(
818  function ( $x ) {
819  return $x !== false;
820  },
821  $dbKeys
822  );
823  }
824  }
825  if ( $this->fld_notificationtimestamp ) {
826  $this->notificationtimestamps = $timestamps;
827  }
828  }
829 
833  private function getWatcherInfo() {
834  if ( count( $this->everything ) == 0 ) {
835  return;
836  }
837 
838  $user = $this->getUser();
839  $canUnwatchedpages = $user->isAllowed( 'unwatchedpages' );
840  $unwatchedPageThreshold = $this->getConfig()->get( 'UnwatchedPageThreshold' );
841  if ( !$canUnwatchedpages && !is_int( $unwatchedPageThreshold ) ) {
842  return;
843  }
844 
845  $this->showZeroWatchers = $canUnwatchedpages;
846 
847  $countOptions = [];
848  if ( !$canUnwatchedpages ) {
849  $countOptions['minimumWatchers'] = $unwatchedPageThreshold;
850  }
851 
852  $this->watchers = MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchersMultiple(
853  $this->everything,
854  $countOptions
855  );
856  }
857 
864  private function getVisitingWatcherInfo() {
865  $config = $this->getConfig();
866  $user = $this->getUser();
867  $db = $this->getDB();
868 
869  $canUnwatchedpages = $user->isAllowed( 'unwatchedpages' );
870  $unwatchedPageThreshold = $this->getConfig()->get( 'UnwatchedPageThreshold' );
871  if ( !$canUnwatchedpages && !is_int( $unwatchedPageThreshold ) ) {
872  return;
873  }
874 
875  $this->showZeroWatchers = $canUnwatchedpages;
876 
877  $titlesWithThresholds = [];
878  if ( $this->titles ) {
879  $lb = new LinkBatch( $this->titles );
880 
881  // Fetch last edit timestamps for pages
882  $this->resetQueryParams();
883  $this->addTables( [ 'page', 'revision' ] );
884  $this->addFields( [ 'page_namespace', 'page_title', 'rev_timestamp' ] );
885  $this->addWhere( [
886  'page_latest = rev_id',
887  $lb->constructSet( 'page', $db ),
888  ] );
889  $this->addOption( 'GROUP BY', [ 'page_namespace', 'page_title' ] );
890  $timestampRes = $this->select( __METHOD__ );
891 
892  $age = $config->get( 'WatchersMaxAge' );
893  $timestamps = [];
894  foreach ( $timestampRes as $row ) {
895  $revTimestamp = wfTimestamp( TS_UNIX, (int)$row->rev_timestamp );
896  $timestamps[$row->page_namespace][$row->page_title] = $revTimestamp - $age;
897  }
898  $titlesWithThresholds = array_map(
899  function ( LinkTarget $target ) use ( $timestamps ) {
900  return [
901  $target, $timestamps[$target->getNamespace()][$target->getDBkey()]
902  ];
903  },
905  );
906  }
907 
908  if ( $this->missing ) {
909  $titlesWithThresholds = array_merge(
910  $titlesWithThresholds,
911  array_map(
912  function ( LinkTarget $target ) {
913  return [ $target, null ];
914  },
916  )
917  );
918  }
919  $store = MediaWikiServices::getInstance()->getWatchedItemStore();
920  $this->visitingwatchers = $store->countVisitingWatchersMultiple(
921  $titlesWithThresholds,
922  !$canUnwatchedpages ? $unwatchedPageThreshold : null
923  );
924  }
925 
926  public function getCacheMode( $params ) {
927  // Other props depend on something about the current user
928  $publicProps = [
929  'protection',
930  'talkid',
931  'subjectid',
932  'url',
933  'preload',
934  'displaytitle',
935  'varianttitles',
936  ];
937  if ( array_diff( (array)$params['prop'], $publicProps ) ) {
938  return 'private';
939  }
940 
941  // testactions also depends on the current user
942  if ( $params['testactions'] ) {
943  return 'private';
944  }
945 
946  if ( !is_null( $params['token'] ) ) {
947  return 'private';
948  }
949 
950  return 'public';
951  }
952 
953  public function getAllowedParams() {
954  return [
955  'prop' => [
956  ApiBase::PARAM_ISMULTI => true,
958  'protection',
959  'talkid',
960  'watched', # private
961  'watchers', # private
962  'visitingwatchers', # private
963  'notificationtimestamp', # private
964  'subjectid',
965  'url',
966  'readable', # private
967  'preload',
968  'displaytitle',
969  'varianttitles',
970  // If you add more properties here, please consider whether they
971  // need to be added to getCacheMode()
972  ],
975  'readable' => true, // Since 1.32
976  ],
977  ],
978  'testactions' => [
979  ApiBase::PARAM_TYPE => 'string',
980  ApiBase::PARAM_ISMULTI => true,
981  ],
982  'testactionsdetail' => [
983  ApiBase::PARAM_TYPE => [ 'boolean', 'full', 'quick' ],
984  ApiBase::PARAM_DFLT => 'boolean',
986  ],
987  'token' => [
989  ApiBase::PARAM_ISMULTI => true,
990  ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() )
991  ],
992  'continue' => [
993  ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
994  ],
995  ];
996  }
997 
998  protected function getExamplesMessages() {
999  return [
1000  'action=query&prop=info&titles=Main%20Page'
1001  => 'apihelp-query+info-example-simple',
1002  'action=query&prop=info&inprop=protection&titles=Main%20Page'
1003  => 'apihelp-query+info-example-protection',
1004  ];
1005  }
1006 
1007  public function getHelpUrls() {
1008  return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Info';
1009  }
1010 }
ApiQueryInfo\$talkids
$talkids
Definition: ApiQueryInfo.php:51
ApiQueryInfo\extractPageInfo
extractPageInfo( $pageid, $title)
Get a result array with information about a title.
Definition: ApiQueryInfo.php:398
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:63
ApiQueryInfo\$everything
Title[] $everything
Definition: ApiQueryInfo.php:46
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:244
ApiQueryBase\addFields
addFields( $value)
Add a set of fields to select to the internal array.
Definition: ApiQueryBase.php:192
ApiQuery
This is the main query class.
Definition: ApiQuery.php:36
PROTO_CANONICAL
const PROTO_CANONICAL
Definition: Defines.php:223
ApiBase\addWarning
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
Definition: ApiBase.php:1906
ApiQueryInfo\$fld_url
$fld_url
Definition: ApiQueryInfo.php:33
ApiQueryInfo\$subjectids
$subjectids
Definition: ApiQueryInfo.php:51
ApiQueryInfo\$displaytitles
$displaytitles
Definition: ApiQueryInfo.php:51
MWNamespace\isTalk
static isTalk( $index)
Is the given namespace a talk namespace?
Definition: MWNamespace.php:118
ApiQueryBase\resetQueryParams
resetQueryParams()
Blank the internal arrays with query parameters.
Definition: ApiQueryBase.php:144
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
ApiQueryInfo\getProtectionInfo
getProtectionInfo()
Get information about protections and put it in $protections.
Definition: ApiQueryInfo.php:560
ApiQueryInfo\getUnblockToken
static getUnblockToken( $pageid, $title)
Definition: ApiQueryInfo.php:221
ApiQueryInfo\$pageTouched
$pageTouched
Definition: ApiQueryInfo.php:48
captcha-old.count
count
Definition: captcha-old.py:249
ApiQueryInfo\$showZeroWatchers
$showZeroWatchers
Definition: ApiQueryInfo.php:53
ApiBase\PARAM_HELP_MSG
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:124
ApiQueryInfo\resetTokenCache
static resetTokenCache()
Definition: ApiQueryInfo.php:126
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED since 1.16! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:2034
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1954
ApiQueryInfo\$tokenFunctions
$tokenFunctions
Definition: ApiQueryInfo.php:55
ApiBase\PARAM_TYPE
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
Definition: ApiBase.php:87
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:659
ApiQueryInfo\getVisitingWatcherInfo
getVisitingWatcherInfo()
Get the count of watchers who have visited recent edits and put it in $this->visitingwatchers.
Definition: ApiQueryInfo.php:864
NS_FILE
const NS_FILE
Definition: Defines.php:70
$res
$res
Definition: database.txt:21
ApiQueryBase\addOption
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
Definition: ApiQueryBase.php:325
ContextSource\getUser
getUser()
Definition: ContextSource.php:120
ApiQueryInfo
A query module to show basic page information.
Definition: ApiQueryInfo.php:30
ApiBase\PARAM_DEPRECATED_VALUES
const PARAM_DEPRECATED_VALUES
(array) When PARAM_TYPE is an array, this indicates which of the values are deprecated.
Definition: ApiBase.php:202
ApiBase\lacksSameOriginSecurity
lacksSameOriginSecurity()
Returns true if the current request breaks the same-origin policy.
Definition: ApiBase.php:587
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
ApiQueryInfo\$countTestedActions
$countTestedActions
Definition: ApiQueryInfo.php:57
ApiQueryInfo\getAllVariants
getAllVariants( $text, $ns=NS_MAIN)
Definition: ApiQueryInfo.php:782
NS_MAIN
const NS_MAIN
Definition: Defines.php:64
ApiQueryInfo\$fld_varianttitles
$fld_varianttitles
Definition: ApiQueryInfo.php:37
ApiBase\PARAM_DEPRECATED
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
Definition: ApiBase.php:105
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1627
MediaWiki\Linker\LinkTarget\getNamespace
getNamespace()
Get the namespace index.
ApiQueryInfo\$visitingwatchers
$visitingwatchers
Definition: ApiQueryInfo.php:51
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
ApiQueryInfo\getEmailToken
static getEmailToken( $pageid, $title)
Definition: ApiQueryInfo.php:229
ApiQueryInfo\getProtectToken
static getProtectToken( $pageid, $title)
Definition: ApiQueryInfo.php:170
ApiQueryBase
This is a base class for all Query modules.
Definition: ApiQueryBase.php:33
ApiQueryInfo\getWatchToken
static getWatchToken( $pageid, $title)
Definition: ApiQueryInfo.php:263
ApiQueryInfo\$pageRestrictions
$pageRestrictions
Definition: ApiQueryInfo.php:48
ApiQueryBase\getDB
getDB()
Get the Query database connection (read-only)
Definition: ApiQueryBase.php:105
PROTO_CURRENT
const PROTO_CURRENT
Definition: Defines.php:222
ApiQueryBase\addTables
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
Definition: ApiQueryBase.php:158
ApiQueryBase\select
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
Definition: ApiQueryBase.php:350
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
ApiQueryInfo\$titles
Title[] $titles
Definition: ApiQueryInfo.php:42
ApiBase\extractRequestParams
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:770
ApiQueryInfo\$fld_talkid
$fld_talkid
Definition: ApiQueryInfo.php:32
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:545
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
ApiQueryInfo\$fld_displaytitle
$fld_displaytitle
Definition: ApiQueryInfo.php:37
ApiQueryInfo\$notificationtimestamps
$notificationtimestamps
Definition: ApiQueryInfo.php:51
ApiQueryInfo\getDeleteToken
static getDeleteToken( $pageid, $title)
Definition: ApiQueryInfo.php:153
ApiQueryInfo\getTSIDs
getTSIDs()
Get talk page IDs (if requested) and subject page IDs (if requested) and put them in $talkids and $su...
Definition: ApiQueryInfo.php:711
ApiQueryInfo\getWatchedInfo
getWatchedInfo()
Get information about watched status and put it in $this->watched and $this->notificationtimestamps.
Definition: ApiQueryInfo.php:800
ApiQueryInfo\$watched
$watched
Definition: ApiQueryInfo.php:51
ApiQueryInfo\$params
$params
Definition: ApiQueryInfo.php:39
ApiQueryInfo\getHelpUrls
getHelpUrls()
Return links to more detailed help pages about the module.
Definition: ApiQueryInfo.php:1007
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:573
ApiResult\setIndexedTagName
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:616
ApiQueryInfo\getImportToken
static getImportToken( $pageid, $title)
Definition: ApiQueryInfo.php:246
ApiQueryInfo\$pageIsNew
$pageIsNew
Definition: ApiQueryInfo.php:48
ApiQueryInfo\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiQueryInfo.php:998
ApiBase\dieContinueUsageIf
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
Definition: ApiBase.php:2155
ApiQueryInfo\getTokenFunctions
getTokenFunctions()
Get an array mapping token names to their handler functions.
Definition: ApiQueryInfo.php:93
ApiBase\LIMIT_SML2
const LIMIT_SML2
Slow query, apihighlimits limit.
Definition: ApiBase.php:258
ApiQueryInfo\$fld_preload
$fld_preload
Definition: ApiQueryInfo.php:37
MediaWiki\Linker\LinkTarget\getDBkey
getDBkey()
Get the main part with underscores.
ApiQueryBase\addWhereFld
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
Definition: ApiQueryBase.php:260
ApiQueryBase\getPageSet
getPageSet()
Get the PageSet object to work on.
Definition: ApiQueryBase.php:130
ApiQueryInfo\$fld_watchers
$fld_watchers
Definition: ApiQueryInfo.php:35
ApiQueryInfo\getCacheMode
getCacheMode( $params)
Get the cache mode for the data generated by this module.
Definition: ApiQueryInfo.php:926
ApiQueryInfo\$fld_subjectid
$fld_subjectid
Definition: ApiQueryInfo.php:33
Title
Represents a title within MediaWiki.
Definition: Title.php:39
ApiQueryInfo\$fld_watched
$fld_watched
Definition: ApiQueryInfo.php:34
ApiQueryInfo\getDisplayTitle
getDisplayTitle()
Definition: ApiQueryInfo.php:749
ApiQueryInfo\$fld_protection
$fld_protection
Definition: ApiQueryInfo.php:32
ApiQueryInfo\$watchers
$watchers
Definition: ApiQueryInfo.php:51
ApiQueryInfo\getEditToken
static getEditToken( $pageid, $title)
Definition: ApiQueryInfo.php:133
ApiQueryInfo\$pageLatest
$pageLatest
Definition: ApiQueryInfo.php:48
ApiBase\PARAM_DFLT
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:48
ApiQueryInfo\$restrictionTypes
$restrictionTypes
Definition: ApiQueryInfo.php:51
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
ApiQueryInfo\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiQueryInfo.php:953
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition: ApiBase.php:51
ApiQueryInfo\$protections
$protections
Definition: ApiQueryInfo.php:51
$source
$source
Definition: mwdoc-filter.php:46
ApiQueryInfo\getMoveToken
static getMoveToken( $pageid, $title)
Definition: ApiQueryInfo.php:187
ApiResult\formatExpiry
static formatExpiry( $expiry, $infinity='infinity')
Format an expiry timestamp for API output.
Definition: ApiResult.php:1205
ApiQueryInfo\getOptionsToken
static getOptionsToken( $pageid, $title)
Definition: ApiQueryInfo.php:280
ApiBase\getMain
getMain()
Get the main module.
Definition: ApiBase.php:555
ApiQueryInfo\$fld_notificationtimestamp
$fld_notificationtimestamp
Definition: ApiQueryInfo.php:36
ApiQueryBase\addWhere
addWhere( $value)
Add a set of WHERE clauses to the internal array.
Definition: ApiQueryBase.php:227
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
Title\compare
static compare(LinkTarget $a, LinkTarget $b)
Callback for usort() to do title sorts by (namespace, title)
Definition: Title.php:795
$t
$t
Definition: testCompression.php:69
ApiQueryBase\setContinueEnumParameter
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
Definition: ApiQueryBase.php:536
ApiQueryInfo\$pageIsRedir
$pageIsRedir
Definition: ApiQueryInfo.php:48
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
ApiQueryInfo\$cachedTokens
static $cachedTokens
Definition: ApiQueryInfo.php:121
MWNamespace\getTalk
static getTalk( $index)
Get the talk namespace index for a given namespace.
Definition: MWNamespace.php:129
ApiQueryInfo\getBlockToken
static getBlockToken( $pageid, $title)
Definition: ApiQueryInfo.php:204
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:157
ApiQueryInfo\getVariantTitles
getVariantTitles()
Definition: ApiQueryInfo.php:770
MWNamespace\getSubject
static getSubject( $index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA,...
Definition: MWNamespace.php:143
ApiQueryInfo\$fld_readable
$fld_readable
Definition: ApiQueryInfo.php:34
ApiQueryInfo\requestExtraData
requestExtraData( $pageSet)
Definition: ApiQueryInfo.php:67
ApiQueryInfo\$fld_visitingwatchers
$fld_visitingwatchers
Definition: ApiQueryInfo.php:35
ApiQueryInfo\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiQueryInfo.php:294
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
ApiQueryInfo\getWatcherInfo
getWatcherInfo()
Get the count of watchers and put it in $this->watchers.
Definition: ApiQueryInfo.php:833
ApiBase\errorArrayToStatus
errorArrayToStatus(array $errors, User $user=null)
Turn an array of message keys or key+param arrays into a Status.
Definition: ApiBase.php:1843
ApiQueryInfo\$pageLength
$pageLength
Definition: ApiQueryInfo.php:48
ApiBase\getErrorFormatter
getErrorFormatter()
Get the error formatter.
Definition: ApiBase.php:673
ApiQueryInfo\$missing
Title[] $missing
Definition: ApiQueryInfo.php:44
ApiQueryInfo\$variantTitles
$variantTitles
Definition: ApiQueryInfo.php:51
ApiBase\LIMIT_SML1
const LIMIT_SML1
Slow query, standard limit.
Definition: ApiBase.php:256
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:512
ApiQueryInfo\__construct
__construct(ApiQuery $query, $moduleName)
Definition: ApiQueryInfo.php:59