MediaWiki  1.30.0
ApiQueryWatchlistIntegrationTest.php
Go to the documentation of this file.
1 <?php
2 
5 
14 
15  public function __construct( $name = null, array $data = [], $dataName = '' ) {
16  parent::__construct( $name, $data, $dataName );
17  $this->tablesUsed = array_unique(
18  array_merge( $this->tablesUsed, [ 'watchlist', 'recentchanges', 'page' ] )
19  );
20  }
21 
22  protected function setUp() {
23  parent::setUp();
24  self::$users['ApiQueryWatchlistIntegrationTestUser'] = $this->getMutableTestUser();
25  self::$users['ApiQueryWatchlistIntegrationTestUser2'] = $this->getMutableTestUser();
26  $this->doLogin( 'ApiQueryWatchlistIntegrationTestUser' );
27  }
28 
29  private function getLoggedInTestUser() {
30  return self::$users['ApiQueryWatchlistIntegrationTestUser']->getUser();
31  }
32 
33  private function getNonLoggedInTestUser() {
34  return self::$users['ApiQueryWatchlistIntegrationTestUser2']->getUser();
35  }
36 
37  private function doPageEdit( User $user, LinkTarget $target, $content, $summary ) {
38  $title = Title::newFromLinkTarget( $target );
39  $page = WikiPage::factory( $title );
40  $page->doEditContent(
42  $summary,
43  0,
44  false,
45  $user
46  );
47  }
48 
49  private function doMinorPageEdit( User $user, LinkTarget $target, $content, $summary ) {
50  $title = Title::newFromLinkTarget( $target );
51  $page = WikiPage::factory( $title );
52  $page->doEditContent(
54  $summary,
55  EDIT_MINOR,
56  false,
57  $user
58  );
59  }
60 
61  private function doBotPageEdit( User $user, LinkTarget $target, $content, $summary ) {
62  $title = Title::newFromLinkTarget( $target );
63  $page = WikiPage::factory( $title );
64  $page->doEditContent(
66  $summary,
68  false,
69  $user
70  );
71  }
72 
73  private function doAnonPageEdit( LinkTarget $target, $content, $summary ) {
74  $title = Title::newFromLinkTarget( $target );
75  $page = WikiPage::factory( $title );
76  $page->doEditContent(
78  $summary,
79  0,
80  false,
81  User::newFromId( 0 )
82  );
83  }
84 
85  private function doPatrolledPageEdit(
86  User $user,
87  LinkTarget $target,
88  $content,
89  $summary,
90  User $patrollingUser
91  ) {
92  $title = Title::newFromLinkTarget( $target );
93  $page = WikiPage::factory( $title );
94  $status = $page->doEditContent(
96  $summary,
97  0,
98  false,
99  $user
100  );
102  $rev = $status->value['revision'];
103  $rc = $rev->getRecentChange();
104  $rc->doMarkPatrolled( $patrollingUser, false, [] );
105  }
106 
107  private function deletePage( LinkTarget $target, $reason ) {
108  $title = Title::newFromLinkTarget( $target );
109  $page = WikiPage::factory( $title );
110  $page->doDeleteArticleReal( $reason );
111  }
112 
123  private function doPageEdits( User $user, array $editData ) {
124  foreach ( $editData as $singleEditData ) {
125  if ( array_key_exists( 'minorEdit', $singleEditData ) && $singleEditData['minorEdit'] ) {
126  $this->doMinorPageEdit(
127  $user,
128  $singleEditData['target'],
129  $singleEditData['content'],
130  $singleEditData['summary']
131  );
132  continue;
133  }
134  if ( array_key_exists( 'botEdit', $singleEditData ) && $singleEditData['botEdit'] ) {
135  $this->doBotPageEdit(
136  $user,
137  $singleEditData['target'],
138  $singleEditData['content'],
139  $singleEditData['summary']
140  );
141  continue;
142  }
143  $this->doPageEdit(
144  $user,
145  $singleEditData['target'],
146  $singleEditData['content'],
147  $singleEditData['summary']
148  );
149  }
150  }
151 
152  private function getWatchedItemStore() {
153  return MediaWikiServices::getInstance()->getWatchedItemStore();
154  }
155 
160  private function watchPages( User $user, array $targets ) {
161  $store = $this->getWatchedItemStore();
162  $store->addWatchBatchForUser( $user, $targets );
163  }
164 
165  private function doListWatchlistRequest( array $params = [], $user = null ) {
166  return $this->doApiRequest(
167  array_merge(
168  [ 'action' => 'query', 'list' => 'watchlist' ],
169  $params
170  ), null, false, $user
171  );
172  }
173 
174  private function doGeneratorWatchlistRequest( array $params = [] ) {
175  return $this->doApiRequest(
176  array_merge(
177  [ 'action' => 'query', 'generator' => 'watchlist' ],
178  $params
179  )
180  );
181  }
182 
184  return $response[0]['query']['watchlist'];
185  }
186 
203  private function assertArraySubsetsEqual(
204  array $actualItems,
205  array $expectedItems,
206  array $keysUsedInValueComparison,
207  array $requiredKeys = []
208  ) {
209  $this->assertCount( count( $expectedItems ), $actualItems );
210 
211  // not checking values of all keys of the actual item, so removing unwanted keys from comparison
212  $actualItemsOnlyComparedValues = array_map(
213  function ( array $item ) use ( $keysUsedInValueComparison ) {
214  return array_intersect_key( $item, array_flip( $keysUsedInValueComparison ) );
215  },
216  $actualItems
217  );
218 
219  $this->assertEquals(
220  $expectedItems,
221  $actualItemsOnlyComparedValues
222  );
223 
224  // Check that each item in $actualItems contains all of keys specified in $requiredKeys
225  $actualItemsKeysOnly = array_map( 'array_keys', $actualItems );
226  foreach ( $actualItemsKeysOnly as $keysOfTheItem ) {
227  $this->assertEmpty( array_diff( $requiredKeys, $keysOfTheItem ) );
228  }
229  }
230 
231  private function getTitleFormatter() {
232  return new MediaWikiTitleCodec(
233  Language::factory( 'en' ),
234  MediaWikiServices::getInstance()->getGenderCache()
235  );
236  }
237 
238  private function getPrefixedText( LinkTarget $target ) {
239  $formatter = $this->getTitleFormatter();
240  return $formatter->getPrefixedText( $target );
241  }
242 
243  private function cleanTestUsersWatchlist() {
244  $user = $this->getLoggedInTestUser();
245  $store = $this->getWatchedItemStore();
246  $items = $store->getWatchedItemsForUser( $user );
247  foreach ( $items as $item ) {
248  $store->removeWatch( $user, $item->getLinkTarget() );
249  }
250  }
251 
253  // Clean up after previous tests that might have added something to the watchlist of
254  // the user with the same user ID as user used here as the test user
255  $this->cleanTestUsersWatchlist();
256 
257  $user = $this->getLoggedInTestUser();
258  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
259  $this->doPageEdit(
260  $user,
261  $target,
262  'Some Content',
263  'Create the page'
264  );
265  $this->watchPages( $user, [ $target ] );
266 
267  $result = $this->doListWatchlistRequest();
268 
269  $this->assertArrayHasKey( 'query', $result[0] );
270  $this->assertArrayHasKey( 'watchlist', $result[0]['query'] );
271 
274  [
275  [
276  'type' => 'new',
277  'ns' => $target->getNamespace(),
278  'title' => $this->getPrefixedText( $target ),
279  'bot' => false,
280  'new' => true,
281  'minor' => false,
282  ]
283  ],
284  [ 'type', 'ns', 'title', 'bot', 'new', 'minor' ],
285  [ 'pageid', 'revid', 'old_revid' ]
286  );
287  }
288 
289  public function testIdsPropParameter() {
290  $user = $this->getLoggedInTestUser();
291  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
292  $this->doPageEdit(
293  $user,
294  $target,
295  'Some Content',
296  'Create the page'
297  );
298  $this->watchPages( $user, [ $target ] );
299 
300  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'ids', ] );
301  $items = $this->getItemsFromApiResponse( $result );
302 
303  $this->assertCount( 1, $items );
304  $this->assertArrayHasKey( 'pageid', $items[0] );
305  $this->assertArrayHasKey( 'revid', $items[0] );
306  $this->assertArrayHasKey( 'old_revid', $items[0] );
307  $this->assertEquals( 'new', $items[0]['type'] );
308  }
309 
310  public function testTitlePropParameter() {
311  $user = $this->getLoggedInTestUser();
312  $subjectTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
313  $talkTarget = new TitleValue( 1, 'ApiQueryWatchlistIntegrationTestPage' );
314  $this->doPageEdits(
315  $user,
316  [
317  [
318  'target' => $subjectTarget,
319  'content' => 'Some Content',
320  'summary' => 'Create the page',
321  ],
322  [
323  'target' => $talkTarget,
324  'content' => 'Some Talk Page Content',
325  'summary' => 'Create Talk page',
326  ],
327  ]
328  );
329  $this->watchPages( $user, [ $subjectTarget, $talkTarget ] );
330 
331  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'title', ] );
332 
333  $this->assertEquals(
334  [
335  [
336  'type' => 'new',
337  'ns' => $talkTarget->getNamespace(),
338  'title' => $this->getPrefixedText( $talkTarget ),
339  ],
340  [
341  'type' => 'new',
342  'ns' => $subjectTarget->getNamespace(),
343  'title' => $this->getPrefixedText( $subjectTarget ),
344  ],
345  ],
347  );
348  }
349 
350  public function testFlagsPropParameter() {
351  $user = $this->getLoggedInTestUser();
352  $normalEditTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
353  $minorEditTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPageM' );
354  $botEditTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPageB' );
355  $this->doPageEdits(
356  $user,
357  [
358  [
359  'target' => $normalEditTarget,
360  'content' => 'Some Content',
361  'summary' => 'Create the page',
362  ],
363  [
364  'target' => $minorEditTarget,
365  'content' => 'Some Content',
366  'summary' => 'Create the page',
367  ],
368  [
369  'target' => $minorEditTarget,
370  'content' => 'Slightly Better Content',
371  'summary' => 'Change content',
372  'minorEdit' => true,
373  ],
374  [
375  'target' => $botEditTarget,
376  'content' => 'Some Content',
377  'summary' => 'Create the page with a bot',
378  'botEdit' => true,
379  ],
380  ]
381  );
382  $this->watchPages( $user, [ $normalEditTarget, $minorEditTarget, $botEditTarget ] );
383 
384  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'flags', ] );
385 
386  $this->assertEquals(
387  [
388  [
389  'type' => 'new',
390  'new' => true,
391  'minor' => false,
392  'bot' => true,
393  ],
394  [
395  'type' => 'edit',
396  'new' => false,
397  'minor' => true,
398  'bot' => false,
399  ],
400  [
401  'type' => 'new',
402  'new' => true,
403  'minor' => false,
404  'bot' => false,
405  ],
406  ],
408  );
409  }
410 
411  public function testUserPropParameter() {
412  $user = $this->getLoggedInTestUser();
413  $userEditTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
414  $anonEditTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPageA' );
415  $this->doPageEdit(
416  $user,
417  $userEditTarget,
418  'Some Content',
419  'Create the page'
420  );
421  $this->doAnonPageEdit(
422  $anonEditTarget,
423  'Some Content',
424  'Create the page'
425  );
426  $this->watchPages( $user, [ $userEditTarget, $anonEditTarget ] );
427 
428  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'user', ] );
429 
430  $this->assertEquals(
431  [
432  [
433  'type' => 'new',
434  'anon' => true,
435  'user' => User::newFromId( 0 )->getName(),
436  ],
437  [
438  'type' => 'new',
439  'user' => $user->getName(),
440  ],
441  ],
443  );
444  }
445 
446  public function testUserIdPropParameter() {
447  $user = $this->getLoggedInTestUser();
448  $userEditTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
449  $anonEditTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPageA' );
450  $this->doPageEdit(
451  $user,
452  $userEditTarget,
453  'Some Content',
454  'Create the page'
455  );
456  $this->doAnonPageEdit(
457  $anonEditTarget,
458  'Some Content',
459  'Create the page'
460  );
461  $this->watchPages( $user, [ $userEditTarget, $anonEditTarget ] );
462 
463  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'userid', ] );
464 
465  $this->assertEquals(
466  [
467  [
468  'type' => 'new',
469  'anon' => true,
470  'user' => 0,
471  'userid' => 0,
472  ],
473  [
474  'type' => 'new',
475  'user' => $user->getId(),
476  'userid' => $user->getId(),
477  ],
478  ],
480  );
481  }
482 
483  public function testCommentPropParameter() {
484  $user = $this->getLoggedInTestUser();
485  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
486  $this->doPageEdit(
487  $user,
488  $target,
489  'Some Content',
490  'Create the <b>page</b>'
491  );
492  $this->watchPages( $user, [ $target ] );
493 
494  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'comment', ] );
495 
496  $this->assertEquals(
497  [
498  [
499  'type' => 'new',
500  'comment' => 'Create the <b>page</b>',
501  ],
502  ],
504  );
505  }
506 
507  public function testParsedCommentPropParameter() {
508  $user = $this->getLoggedInTestUser();
509  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
510  $this->doPageEdit(
511  $user,
512  $target,
513  'Some Content',
514  'Create the <b>page</b>'
515  );
516  $this->watchPages( $user, [ $target ] );
517 
518  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'parsedcomment', ] );
519 
520  $this->assertEquals(
521  [
522  [
523  'type' => 'new',
524  'parsedcomment' => 'Create the &lt;b&gt;page&lt;/b&gt;',
525  ],
526  ],
528  );
529  }
530 
531  public function testTimestampPropParameter() {
532  $user = $this->getLoggedInTestUser();
533  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
534  $this->doPageEdit(
535  $user,
536  $target,
537  'Some Content',
538  'Create the page'
539  );
540  $this->watchPages( $user, [ $target ] );
541 
542  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'timestamp', ] );
543  $items = $this->getItemsFromApiResponse( $result );
544 
545  $this->assertCount( 1, $items );
546  $this->assertArrayHasKey( 'timestamp', $items[0] );
547  $this->assertInternalType( 'string', $items[0]['timestamp'] );
548  }
549 
550  public function testSizesPropParameter() {
551  $user = $this->getLoggedInTestUser();
552  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
553  $this->doPageEdit(
554  $user,
555  $target,
556  'Some Content',
557  'Create the page'
558  );
559  $this->watchPages( $user, [ $target ] );
560 
561  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'sizes', ] );
562 
563  $this->assertEquals(
564  [
565  [
566  'type' => 'new',
567  'oldlen' => 0,
568  'newlen' => 12,
569  ],
570  ],
572  );
573  }
574 
576  $otherUser = $this->getNonLoggedInTestUser();
577  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
578  $this->doPageEdit(
579  $otherUser,
580  $target,
581  'Some Content',
582  'Create the page'
583  );
584  $store = $this->getWatchedItemStore();
585  $store->addWatch( $this->getLoggedInTestUser(), $target );
586  $store->updateNotificationTimestamp(
587  $otherUser,
588  $target,
589  '20151212010101'
590  );
591 
592  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'notificationtimestamp', ] );
593 
594  $this->assertEquals(
595  [
596  [
597  'type' => 'new',
598  'notificationtimestamp' => '2015-12-12T01:01:01Z',
599  ],
600  ],
602  );
603  }
604 
606  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
607 
608  $this->doPatrolledPageEdit(
609  $user,
610  $target,
611  'Some Content',
612  'Create the page (this gets patrolled)',
613  $user
614  );
615 
616  $this->watchPages( $user, [ $target ] );
617  }
618 
619  public function testPatrolPropParameter() {
620  $testUser = static::getTestSysop();
621  $user = $testUser->getUser();
623 
624  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'patrol', ], $user );
625 
626  $this->assertEquals(
627  [
628  [
629  'type' => 'new',
630  'patrolled' => true,
631  'unpatrolled' => false,
632  ]
633  ],
635  );
636  }
637 
638  private function createPageAndDeleteIt( LinkTarget $target ) {
639  $this->doPageEdit(
640  $this->getLoggedInTestUser(),
641  $target,
642  'Some Content',
643  'Create the page that will be deleted'
644  );
645  $this->deletePage( $target, 'Important Reason' );
646  }
647 
648  public function testLoginfoPropParameter() {
649  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
650  $this->createPageAndDeleteIt( $target );
651 
652  $this->watchPages( $this->getLoggedInTestUser(), [ $target ] );
653 
654  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'loginfo', ] );
655 
658  [
659  [
660  'type' => 'log',
661  'logtype' => 'delete',
662  'logaction' => 'delete',
663  'logparams' => [],
664  ],
665  ],
666  [ 'type', 'logtype', 'logaction', 'logparams' ],
667  [ 'logid' ]
668  );
669  }
670 
671  public function testEmptyPropParameter() {
672  $user = $this->getLoggedInTestUser();
673  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
674  $this->doPageEdit(
675  $user,
676  $target,
677  'Some Content',
678  'Create the page'
679  );
680  $this->watchPages( $user, [ $target ] );
681 
682  $result = $this->doListWatchlistRequest( [ 'wlprop' => '', ] );
683 
684  $this->assertEquals(
685  [
686  [
687  'type' => 'new',
688  ]
689  ],
691  );
692  }
693 
694  public function testNamespaceParam() {
695  $user = $this->getLoggedInTestUser();
696  $subjectTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
697  $talkTarget = new TitleValue( 1, 'ApiQueryWatchlistIntegrationTestPage' );
698  $this->doPageEdits(
699  $user,
700  [
701  [
702  'target' => $subjectTarget,
703  'content' => 'Some Content',
704  'summary' => 'Create the page',
705  ],
706  [
707  'target' => $talkTarget,
708  'content' => 'Some Content',
709  'summary' => 'Create the talk page',
710  ],
711  ]
712  );
713  $this->watchPages( $user, [ $subjectTarget, $talkTarget ] );
714 
715  $result = $this->doListWatchlistRequest( [ 'wlnamespace' => '0', ] );
716 
719  [
720  [
721  'ns' => 0,
722  'title' => $this->getPrefixedText( $subjectTarget ),
723  ],
724  ],
725  [ 'ns', 'title' ]
726  );
727  }
728 
729  public function testUserParam() {
730  $user = $this->getLoggedInTestUser();
731  $otherUser = $this->getNonLoggedInTestUser();
732  $subjectTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
733  $talkTarget = new TitleValue( 1, 'ApiQueryWatchlistIntegrationTestPage' );
734  $this->doPageEdit(
735  $user,
736  $subjectTarget,
737  'Some Content',
738  'Create the page'
739  );
740  $this->doPageEdit(
741  $otherUser,
742  $talkTarget,
743  'What is this page about?',
744  'Create the talk page'
745  );
746  $this->watchPages( $user, [ $subjectTarget, $talkTarget ] );
747 
748  $result = $this->doListWatchlistRequest( [
749  'wlprop' => 'user|title',
750  'wluser' => $otherUser->getName(),
751  ] );
752 
753  $this->assertEquals(
754  [
755  [
756  'type' => 'new',
757  'ns' => $talkTarget->getNamespace(),
758  'title' => $this->getPrefixedText( $talkTarget ),
759  'user' => $otherUser->getName(),
760  ],
761  ],
763  );
764  }
765 
766  public function testExcludeUserParam() {
767  $user = $this->getLoggedInTestUser();
768  $otherUser = $this->getNonLoggedInTestUser();
769  $subjectTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
770  $talkTarget = new TitleValue( 1, 'ApiQueryWatchlistIntegrationTestPage' );
771  $this->doPageEdit(
772  $user,
773  $subjectTarget,
774  'Some Content',
775  'Create the page'
776  );
777  $this->doPageEdit(
778  $otherUser,
779  $talkTarget,
780  'What is this page about?',
781  'Create the talk page'
782  );
783  $this->watchPages( $user, [ $subjectTarget, $talkTarget ] );
784 
785  $result = $this->doListWatchlistRequest( [
786  'wlprop' => 'user|title',
787  'wlexcludeuser' => $otherUser->getName(),
788  ] );
789 
790  $this->assertEquals(
791  [
792  [
793  'type' => 'new',
794  'ns' => $subjectTarget->getNamespace(),
795  'title' => $this->getPrefixedText( $subjectTarget ),
796  'user' => $user->getName(),
797  ]
798  ],
800  );
801  }
802 
803  public function testShowMinorParams() {
804  $user = $this->getLoggedInTestUser();
805  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
806  $this->doPageEdits(
807  $user,
808  [
809  [
810  'target' => $target,
811  'content' => 'Some Content',
812  'summary' => 'Create the page',
813  ],
814  [
815  'target' => $target,
816  'content' => 'Slightly Better Content',
817  'summary' => 'Change content',
818  'minorEdit' => true,
819  ],
820  ]
821  );
822  $this->watchPages( $user, [ $target ] );
823 
824  $resultMinor = $this->doListWatchlistRequest( [
826  'wlprop' => 'flags'
827  ] );
828  $resultNotMinor = $this->doListWatchlistRequest( [
829  'wlshow' => WatchedItemQueryService::FILTER_NOT_MINOR, 'wlprop' => 'flags'
830  ] );
831 
833  $this->getItemsFromApiResponse( $resultMinor ),
834  [
835  [ 'minor' => true, ]
836  ],
837  [ 'minor' ]
838  );
839  $this->assertEmpty( $this->getItemsFromApiResponse( $resultNotMinor ) );
840  }
841 
842  public function testShowBotParams() {
843  $user = $this->getLoggedInTestUser();
844  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
845  $this->doBotPageEdit(
846  $user,
847  $target,
848  'Some Content',
849  'Create the page'
850  );
851  $this->watchPages( $user, [ $target ] );
852 
853  $resultBot = $this->doListWatchlistRequest( [
855  ] );
856  $resultNotBot = $this->doListWatchlistRequest( [
858  ] );
859 
861  $this->getItemsFromApiResponse( $resultBot ),
862  [
863  [ 'bot' => true ],
864  ],
865  [ 'bot' ]
866  );
867  $this->assertEmpty( $this->getItemsFromApiResponse( $resultNotBot ) );
868  }
869 
870  public function testShowAnonParams() {
871  $user = $this->getLoggedInTestUser();
872  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
873  $this->doAnonPageEdit(
874  $target,
875  'Some Content',
876  'Create the page'
877  );
878  $this->watchPages( $user, [ $target ] );
879 
880  $resultAnon = $this->doListWatchlistRequest( [
881  'wlprop' => 'user',
883  ] );
884  $resultNotAnon = $this->doListWatchlistRequest( [
885  'wlprop' => 'user',
887  ] );
888 
890  $this->getItemsFromApiResponse( $resultAnon ),
891  [
892  [ 'anon' => true ],
893  ],
894  [ 'anon' ]
895  );
896  $this->assertEmpty( $this->getItemsFromApiResponse( $resultNotAnon ) );
897  }
898 
899  public function testShowUnreadParams() {
900  $user = $this->getLoggedInTestUser();
901  $otherUser = $this->getNonLoggedInTestUser();
902  $subjectTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
903  $talkTarget = new TitleValue( 1, 'ApiQueryWatchlistIntegrationTestPage' );
904  $this->doPageEdit(
905  $user,
906  $subjectTarget,
907  'Some Content',
908  'Create the page'
909  );
910  $this->doPageEdit(
911  $otherUser,
912  $talkTarget,
913  'Some Content',
914  'Create the talk page'
915  );
916  $store = $this->getWatchedItemStore();
917  $store->addWatchBatchForUser( $user, [ $subjectTarget, $talkTarget ] );
918  $store->updateNotificationTimestamp(
919  $otherUser,
920  $talkTarget,
921  '20151212010101'
922  );
923 
924  $resultUnread = $this->doListWatchlistRequest( [
925  'wlprop' => 'notificationtimestamp|title',
927  ] );
928  $resultNotUnread = $this->doListWatchlistRequest( [
929  'wlprop' => 'notificationtimestamp|title',
931  ] );
932 
933  $this->assertEquals(
934  [
935  [
936  'type' => 'new',
937  'notificationtimestamp' => '2015-12-12T01:01:01Z',
938  'ns' => $talkTarget->getNamespace(),
939  'title' => $this->getPrefixedText( $talkTarget )
940  ]
941  ],
942  $this->getItemsFromApiResponse( $resultUnread )
943  );
944  $this->assertEquals(
945  [
946  [
947  'type' => 'new',
948  'notificationtimestamp' => '',
949  'ns' => $subjectTarget->getNamespace(),
950  'title' => $this->getPrefixedText( $subjectTarget )
951  ]
952  ],
953  $this->getItemsFromApiResponse( $resultNotUnread )
954  );
955  }
956 
957  public function testShowPatrolledParams() {
958  $user = static::getTestSysop()->getUser();
960 
961  $resultPatrolled = $this->doListWatchlistRequest( [
962  'wlprop' => 'patrol',
964  ], $user );
965  $resultNotPatrolled = $this->doListWatchlistRequest( [
966  'wlprop' => 'patrol',
968  ], $user );
969 
970  $this->assertEquals(
971  [
972  [
973  'type' => 'new',
974  'patrolled' => true,
975  'unpatrolled' => false,
976  ]
977  ],
978  $this->getItemsFromApiResponse( $resultPatrolled )
979  );
980  $this->assertEmpty( $this->getItemsFromApiResponse( $resultNotPatrolled ) );
981  }
982 
983  public function testNewAndEditTypeParameters() {
984  $user = $this->getLoggedInTestUser();
985  $subjectTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
986  $talkTarget = new TitleValue( 1, 'ApiQueryWatchlistIntegrationTestPage' );
987  $this->doPageEdits(
988  $user,
989  [
990  [
991  'target' => $subjectTarget,
992  'content' => 'Some Content',
993  'summary' => 'Create the page',
994  ],
995  [
996  'target' => $subjectTarget,
997  'content' => 'Some Other Content',
998  'summary' => 'Change the content',
999  ],
1000  [
1001  'target' => $talkTarget,
1002  'content' => 'Some Talk Page Content',
1003  'summary' => 'Create Talk page',
1004  ],
1005  ]
1006  );
1007  $this->watchPages( $user, [ $subjectTarget, $talkTarget ] );
1008 
1009  $resultNew = $this->doListWatchlistRequest( [ 'wlprop' => 'title', 'wltype' => 'new' ] );
1010  $resultEdit = $this->doListWatchlistRequest( [ 'wlprop' => 'title', 'wltype' => 'edit' ] );
1011 
1012  $this->assertEquals(
1013  [
1014  [
1015  'type' => 'new',
1016  'ns' => $talkTarget->getNamespace(),
1017  'title' => $this->getPrefixedText( $talkTarget ),
1018  ],
1019  ],
1020  $this->getItemsFromApiResponse( $resultNew )
1021  );
1022  $this->assertEquals(
1023  [
1024  [
1025  'type' => 'edit',
1026  'ns' => $subjectTarget->getNamespace(),
1027  'title' => $this->getPrefixedText( $subjectTarget ),
1028  ],
1029  ],
1030  $this->getItemsFromApiResponse( $resultEdit )
1031  );
1032  }
1033 
1034  public function testLogTypeParameters() {
1035  $user = $this->getLoggedInTestUser();
1036  $subjectTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
1037  $talkTarget = new TitleValue( 1, 'ApiQueryWatchlistIntegrationTestPage' );
1038  $this->createPageAndDeleteIt( $subjectTarget );
1039  $this->doPageEdit(
1040  $user,
1041  $talkTarget,
1042  'Some Talk Page Content',
1043  'Create Talk page'
1044  );
1045  $this->watchPages( $user, [ $subjectTarget, $talkTarget ] );
1046 
1047  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'title', 'wltype' => 'log' ] );
1048 
1049  $this->assertEquals(
1050  [
1051  [
1052  'type' => 'log',
1053  'ns' => $subjectTarget->getNamespace(),
1054  'title' => $this->getPrefixedText( $subjectTarget ),
1055  ],
1056  ],
1058  );
1059  }
1060 
1061  private function getExternalRC( LinkTarget $target ) {
1062  $title = Title::newFromLinkTarget( $target );
1063 
1064  $rc = new RecentChange;
1065  $rc->mTitle = $title;
1066  $rc->mAttribs = [
1067  'rc_timestamp' => wfTimestamp( TS_MW ),
1068  'rc_namespace' => $title->getNamespace(),
1069  'rc_title' => $title->getDBkey(),
1070  'rc_type' => RC_EXTERNAL,
1071  'rc_source' => 'foo',
1072  'rc_minor' => 0,
1073  'rc_cur_id' => $title->getArticleID(),
1074  'rc_user' => 0,
1075  'rc_user_text' => 'External User',
1076  'rc_comment' => '',
1077  'rc_comment_text' => '',
1078  'rc_comment_data' => null,
1079  'rc_this_oldid' => $title->getLatestRevID(),
1080  'rc_last_oldid' => $title->getLatestRevID(),
1081  'rc_bot' => 0,
1082  'rc_ip' => '',
1083  'rc_patrolled' => 0,
1084  'rc_new' => 0,
1085  'rc_old_len' => $title->getLength(),
1086  'rc_new_len' => $title->getLength(),
1087  'rc_deleted' => 0,
1088  'rc_logid' => 0,
1089  'rc_log_type' => null,
1090  'rc_log_action' => '',
1091  'rc_params' => '',
1092  ];
1093  $rc->mExtra = [
1094  'prefixedDBkey' => $title->getPrefixedDBkey(),
1095  'lastTimestamp' => 0,
1096  'oldSize' => $title->getLength(),
1097  'newSize' => $title->getLength(),
1098  'pageStatus' => 'changed'
1099  ];
1100 
1101  return $rc;
1102  }
1103 
1104  public function testExternalTypeParameters() {
1105  $user = $this->getLoggedInTestUser();
1106  $subjectTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
1107  $talkTarget = new TitleValue( 1, 'ApiQueryWatchlistIntegrationTestPage' );
1108  $this->doPageEdit(
1109  $user,
1110  $subjectTarget,
1111  'Some Content',
1112  'Create the page'
1113  );
1114  $this->doPageEdit(
1115  $user,
1116  $talkTarget,
1117  'Some Talk Page Content',
1118  'Create Talk page'
1119  );
1120 
1121  $rc = $this->getExternalRC( $subjectTarget );
1122  $rc->save();
1123 
1124  $this->watchPages( $user, [ $subjectTarget, $talkTarget ] );
1125 
1126  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'title', 'wltype' => 'external' ] );
1127 
1128  $this->assertEquals(
1129  [
1130  [
1131  'type' => 'external',
1132  'ns' => $subjectTarget->getNamespace(),
1133  'title' => $this->getPrefixedText( $subjectTarget ),
1134  ],
1135  ],
1137  );
1138  }
1139 
1140  public function testCategorizeTypeParameter() {
1141  $user = $this->getLoggedInTestUser();
1142  $subjectTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
1143  $categoryTarget = new TitleValue( NS_CATEGORY, 'ApiQueryWatchlistIntegrationTestCategory' );
1144  $this->doPageEdits(
1145  $user,
1146  [
1147  [
1148  'target' => $categoryTarget,
1149  'content' => 'Some Content',
1150  'summary' => 'Create the category',
1151  ],
1152  [
1153  'target' => $subjectTarget,
1154  'content' => 'Some Content [[Category:ApiQueryWatchlistIntegrationTestCategory]]t',
1155  'summary' => 'Create the page and add it to the category',
1156  ],
1157  ]
1158  );
1159  $title = Title::newFromLinkTarget( $subjectTarget );
1160  $revision = Revision::newFromTitle( $title );
1161 
1163  $revision->getTimestamp(),
1164  Title::newFromLinkTarget( $categoryTarget ),
1165  $user,
1166  $revision->getComment(),
1167  $title,
1168  0,
1169  $revision->getId(),
1170  null,
1171  false
1172  );
1173  $rc->save();
1174 
1175  $this->watchPages( $user, [ $subjectTarget, $categoryTarget ] );
1176 
1177  $result = $this->doListWatchlistRequest( [ 'wlprop' => 'title', 'wltype' => 'categorize' ] );
1178 
1179  $this->assertEquals(
1180  [
1181  [
1182  'type' => 'categorize',
1183  'ns' => $categoryTarget->getNamespace(),
1184  'title' => $this->getPrefixedText( $categoryTarget ),
1185  ],
1186  ],
1188  );
1189  }
1190 
1191  public function testLimitParam() {
1192  $user = $this->getLoggedInTestUser();
1193  $target1 = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
1194  $target2 = new TitleValue( 1, 'ApiQueryWatchlistIntegrationTestPage' );
1195  $target3 = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage2' );
1196  $this->doPageEdits(
1197  $user,
1198  [
1199  [
1200  'target' => $target1,
1201  'content' => 'Some Content',
1202  'summary' => 'Create the page',
1203  ],
1204  [
1205  'target' => $target2,
1206  'content' => 'Some Talk Page Content',
1207  'summary' => 'Create Talk page',
1208  ],
1209  [
1210  'target' => $target3,
1211  'content' => 'Some Other Content',
1212  'summary' => 'Create the page',
1213  ],
1214  ]
1215  );
1216  $this->watchPages( $user, [ $target1, $target2, $target3 ] );
1217 
1218  $resultWithoutLimit = $this->doListWatchlistRequest( [ 'wlprop' => 'title' ] );
1219  $resultWithLimit = $this->doListWatchlistRequest( [ 'wllimit' => 2, 'wlprop' => 'title' ] );
1220 
1221  $this->assertEquals(
1222  [
1223  [
1224  'type' => 'new',
1225  'ns' => $target3->getNamespace(),
1226  'title' => $this->getPrefixedText( $target3 )
1227  ],
1228  [
1229  'type' => 'new',
1230  'ns' => $target2->getNamespace(),
1231  'title' => $this->getPrefixedText( $target2 )
1232  ],
1233  [
1234  'type' => 'new',
1235  'ns' => $target1->getNamespace(),
1236  'title' => $this->getPrefixedText( $target1 )
1237  ],
1238  ],
1239  $this->getItemsFromApiResponse( $resultWithoutLimit )
1240  );
1241  $this->assertEquals(
1242  [
1243  [
1244  'type' => 'new',
1245  'ns' => $target3->getNamespace(),
1246  'title' => $this->getPrefixedText( $target3 )
1247  ],
1248  [
1249  'type' => 'new',
1250  'ns' => $target2->getNamespace(),
1251  'title' => $this->getPrefixedText( $target2 )
1252  ],
1253  ],
1254  $this->getItemsFromApiResponse( $resultWithLimit )
1255  );
1256  $this->assertArrayHasKey( 'continue', $resultWithLimit[0] );
1257  $this->assertArrayHasKey( 'wlcontinue', $resultWithLimit[0]['continue'] );
1258  }
1259 
1260  public function testAllRevParam() {
1261  $user = $this->getLoggedInTestUser();
1262  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
1263  $this->doPageEdits(
1264  $user,
1265  [
1266  [
1267  'target' => $target,
1268  'content' => 'Some Content',
1269  'summary' => 'Create the page',
1270  ],
1271  [
1272  'target' => $target,
1273  'content' => 'Some Other Content',
1274  'summary' => 'Change the content',
1275  ],
1276  ]
1277  );
1278  $this->watchPages( $user, [ $target ] );
1279 
1280  $resultAllRev = $this->doListWatchlistRequest( [ 'wlprop' => 'title', 'wlallrev' => '', ] );
1281  $resultNoAllRev = $this->doListWatchlistRequest( [ 'wlprop' => 'title' ] );
1282 
1283  $this->assertEquals(
1284  [
1285  [
1286  'type' => 'edit',
1287  'ns' => $target->getNamespace(),
1288  'title' => $this->getPrefixedText( $target ),
1289  ],
1290  ],
1291  $this->getItemsFromApiResponse( $resultNoAllRev )
1292  );
1293  $this->assertEquals(
1294  [
1295  [
1296  'type' => 'edit',
1297  'ns' => $target->getNamespace(),
1298  'title' => $this->getPrefixedText( $target ),
1299  ],
1300  [
1301  'type' => 'new',
1302  'ns' => $target->getNamespace(),
1303  'title' => $this->getPrefixedText( $target ),
1304  ],
1305  ],
1306  $this->getItemsFromApiResponse( $resultAllRev )
1307  );
1308  }
1309 
1310  public function testDirParams() {
1311  $user = $this->getLoggedInTestUser();
1312  $subjectTarget = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
1313  $talkTarget = new TitleValue( 1, 'ApiQueryWatchlistIntegrationTestPage' );
1314  $this->doPageEdits(
1315  $user,
1316  [
1317  [
1318  'target' => $subjectTarget,
1319  'content' => 'Some Content',
1320  'summary' => 'Create the page',
1321  ],
1322  [
1323  'target' => $talkTarget,
1324  'content' => 'Some Talk Page Content',
1325  'summary' => 'Create Talk page',
1326  ],
1327  ]
1328  );
1329  $this->watchPages( $user, [ $subjectTarget, $talkTarget ] );
1330 
1331  $resultDirOlder = $this->doListWatchlistRequest( [ 'wldir' => 'older', 'wlprop' => 'title' ] );
1332  $resultDirNewer = $this->doListWatchlistRequest( [ 'wldir' => 'newer', 'wlprop' => 'title' ] );
1333 
1334  $this->assertEquals(
1335  [
1336  [
1337  'type' => 'new',
1338  'ns' => $talkTarget->getNamespace(),
1339  'title' => $this->getPrefixedText( $talkTarget )
1340  ],
1341  [
1342  'type' => 'new',
1343  'ns' => $subjectTarget->getNamespace(),
1344  'title' => $this->getPrefixedText( $subjectTarget )
1345  ],
1346  ],
1347  $this->getItemsFromApiResponse( $resultDirOlder )
1348  );
1349  $this->assertEquals(
1350  [
1351  [
1352  'type' => 'new',
1353  'ns' => $subjectTarget->getNamespace(),
1354  'title' => $this->getPrefixedText( $subjectTarget )
1355  ],
1356  [
1357  'type' => 'new',
1358  'ns' => $talkTarget->getNamespace(),
1359  'title' => $this->getPrefixedText( $talkTarget )
1360  ],
1361  ],
1362  $this->getItemsFromApiResponse( $resultDirNewer )
1363  );
1364  }
1365 
1366  public function testStartEndParams() {
1367  $user = $this->getLoggedInTestUser();
1368  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
1369  $this->doPageEdit(
1370  $user,
1371  $target,
1372  'Some Content',
1373  'Create the page'
1374  );
1375  $this->watchPages( $user, [ $target ] );
1376 
1377  $resultStart = $this->doListWatchlistRequest( [
1378  'wlstart' => '20010115000000',
1379  'wldir' => 'newer',
1380  'wlprop' => 'title',
1381  ] );
1382  $resultEnd = $this->doListWatchlistRequest( [
1383  'wlend' => '20010115000000',
1384  'wldir' => 'newer',
1385  'wlprop' => 'title',
1386  ] );
1387 
1388  $this->assertEquals(
1389  [
1390  [
1391  'type' => 'new',
1392  'ns' => $target->getNamespace(),
1393  'title' => $this->getPrefixedText( $target ),
1394  ]
1395  ],
1396  $this->getItemsFromApiResponse( $resultStart )
1397  );
1398  $this->assertEmpty( $this->getItemsFromApiResponse( $resultEnd ) );
1399  }
1400 
1401  public function testContinueParam() {
1402  $user = $this->getLoggedInTestUser();
1403  $target1 = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
1404  $target2 = new TitleValue( 1, 'ApiQueryWatchlistIntegrationTestPage' );
1405  $target3 = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage2' );
1406  $this->doPageEdits(
1407  $user,
1408  [
1409  [
1410  'target' => $target1,
1411  'content' => 'Some Content',
1412  'summary' => 'Create the page',
1413  ],
1414  [
1415  'target' => $target2,
1416  'content' => 'Some Talk Page Content',
1417  'summary' => 'Create Talk page',
1418  ],
1419  [
1420  'target' => $target3,
1421  'content' => 'Some Other Content',
1422  'summary' => 'Create the page',
1423  ],
1424  ]
1425  );
1426  $this->watchPages( $user, [ $target1, $target2, $target3 ] );
1427 
1428  $firstResult = $this->doListWatchlistRequest( [ 'wllimit' => 2, 'wlprop' => 'title' ] );
1429  $this->assertArrayHasKey( 'continue', $firstResult[0] );
1430  $this->assertArrayHasKey( 'wlcontinue', $firstResult[0]['continue'] );
1431 
1432  $continuationParam = $firstResult[0]['continue']['wlcontinue'];
1433 
1434  $continuedResult = $this->doListWatchlistRequest(
1435  [ 'wlcontinue' => $continuationParam, 'wlprop' => 'title' ]
1436  );
1437 
1438  $this->assertEquals(
1439  [
1440  [
1441  'type' => 'new',
1442  'ns' => $target3->getNamespace(),
1443  'title' => $this->getPrefixedText( $target3 ),
1444  ],
1445  [
1446  'type' => 'new',
1447  'ns' => $target2->getNamespace(),
1448  'title' => $this->getPrefixedText( $target2 ),
1449  ],
1450  ],
1451  $this->getItemsFromApiResponse( $firstResult )
1452  );
1453  $this->assertEquals(
1454  [
1455  [
1456  'type' => 'new',
1457  'ns' => $target1->getNamespace(),
1458  'title' => $this->getPrefixedText( $target1 )
1459  ]
1460  ],
1461  $this->getItemsFromApiResponse( $continuedResult )
1462  );
1463  }
1464 
1465  public function testOwnerAndTokenParams() {
1466  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
1467  $this->doPageEdit(
1468  $this->getLoggedInTestUser(),
1469  $target,
1470  'Some Content',
1471  'Create the page'
1472  );
1473 
1474  $otherUser = $this->getNonLoggedInTestUser();
1475  $otherUser->setOption( 'watchlisttoken', '1234567890' );
1476  $otherUser->saveSettings();
1477 
1478  $this->watchPages( $otherUser, [ $target ] );
1479 
1480  $reloadedUser = User::newFromName( $otherUser->getName() );
1481  $this->assertEquals( '1234567890', $reloadedUser->getOption( 'watchlisttoken' ) );
1482 
1483  $result = $this->doListWatchlistRequest( [
1484  'wlowner' => $otherUser->getName(),
1485  'wltoken' => '1234567890',
1486  'wlprop' => 'title',
1487  ] );
1488 
1489  $this->assertEquals(
1490  [
1491  [
1492  'type' => 'new',
1493  'ns' => $target->getNamespace(),
1494  'title' => $this->getPrefixedText( $target )
1495  ]
1496  ],
1497  $this->getItemsFromApiResponse( $result )
1498  );
1499  }
1500 
1502  $otherUser = $this->getNonLoggedInTestUser();
1503  $otherUser->setOption( 'watchlisttoken', '1234567890' );
1504  $otherUser->saveSettings();
1505 
1506  $this->setExpectedException( ApiUsageException::class, 'Incorrect watchlist token provided' );
1507 
1508  $this->doListWatchlistRequest( [
1509  'wlowner' => $otherUser->getName(),
1510  'wltoken' => 'wrong-token',
1511  ] );
1512  }
1513 
1515  $this->setExpectedException( ApiUsageException::class, 'Incorrect watchlist token provided' );
1516 
1517  $this->doListWatchlistRequest( [
1518  'wlowner' => $this->getNonLoggedInTestUser()->getName(),
1519  'wltoken' => 'some-token',
1520  ] );
1521  }
1522 
1524  $user = $this->getLoggedInTestUser();
1525  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
1526  $this->doPageEdit(
1527  $user,
1528  $target,
1529  'Some Content',
1530  'Create the page'
1531  );
1532  $this->watchPages( $user, [ $target ] );
1533 
1534  $result = $this->doGeneratorWatchlistRequest( [ 'prop' => 'info' ] );
1535 
1536  $this->assertArrayHasKey( 'query', $result[0] );
1537  $this->assertArrayHasKey( 'pages', $result[0]['query'] );
1538 
1539  // $result[0]['query']['pages'] uses page ids as keys. Page ids don't matter here, so drop them
1540  $pages = array_values( $result[0]['query']['pages'] );
1541 
1542  $this->assertArraySubsetsEqual(
1543  $pages,
1544  [
1545  [
1546  'ns' => $target->getNamespace(),
1547  'title' => $this->getPrefixedText( $target ),
1548  'new' => true,
1549  ]
1550  ],
1551  [ 'ns', 'title', 'new' ]
1552  );
1553  }
1554 
1556  $user = $this->getLoggedInTestUser();
1557  $target = new TitleValue( 0, 'ApiQueryWatchlistIntegrationTestPage' );
1558  $this->doPageEdits(
1559  $user,
1560  [
1561  [
1562  'target' => $target,
1563  'content' => 'Some Content',
1564  'summary' => 'Create the page',
1565  ],
1566  [
1567  'target' => $target,
1568  'content' => 'Some Other Content',
1569  'summary' => 'Change the content',
1570  ],
1571  ]
1572  );
1573  $this->watchPages( $user, [ $target ] );
1574 
1575  $result = $this->doGeneratorWatchlistRequest( [ 'prop' => 'revisions', 'gwlallrev' => '' ] );
1576 
1577  $this->assertArrayHasKey( 'query', $result[0] );
1578  $this->assertArrayHasKey( 'pages', $result[0]['query'] );
1579 
1580  // $result[0]['query']['pages'] uses page ids as keys. Page ids don't matter here, so drop them
1581  $pages = array_values( $result[0]['query']['pages'] );
1582 
1583  $this->assertCount( 1, $pages );
1584  $this->assertEquals( 0, $pages[0]['ns'] );
1585  $this->assertEquals( $this->getPrefixedText( $target ), $pages[0]['title'] );
1586  $this->assertArraySubsetsEqual(
1587  $pages[0]['revisions'],
1588  [
1589  [
1590  'comment' => 'Create the page',
1591  'user' => $user->getName(),
1592  'minor' => false,
1593  ],
1594  [
1595  'comment' => 'Change the content',
1596  'user' => $user->getName(),
1597  'minor' => false,
1598  ],
1599  ],
1600  [ 'comment', 'user', 'minor' ]
1601  );
1602  }
1603 
1604 }
ApiQueryWatchlistIntegrationTest\testTimestampPropParameter
testTimestampPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:531
ApiQueryWatchlistIntegrationTest\setUp
setUp()
Definition: ApiQueryWatchlistIntegrationTest.php:22
$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
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:573
RC_EXTERNAL
const RC_EXTERNAL
Definition: Defines.php:146
MediaWikiTitleCodec
A codec for MediaWiki page titles.
Definition: MediaWikiTitleCodec.php:39
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
ApiQueryWatchlistIntegrationTest\deletePage
deletePage(LinkTarget $target, $reason)
Definition: ApiQueryWatchlistIntegrationTest.php:107
ApiQueryWatchlistIntegrationTest\watchPages
watchPages(User $user, array $targets)
Definition: ApiQueryWatchlistIntegrationTest.php:160
RecentChange\newForCategorization
static newForCategorization( $timestamp, Title $categoryTitle, User $user=null, $comment, Title $pageTitle, $oldRevId, $newRevId, $lastTimestamp, $bot, $ip='', $deleted=0, $added=null)
Constructs a RecentChange object for the given categorization This does not call save() on the object...
Definition: RecentChange.php:857
EDIT_FORCE_BOT
const EDIT_FORCE_BOT
Definition: Defines.php:157
WatchedItemQueryService\FILTER_PATROLLED
const FILTER_PATROLLED
Definition: WatchedItemQueryService.php:40
captcha-old.count
count
Definition: captcha-old.py:249
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:67
$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 '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! 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! 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:1963
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:2040
$status
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
Definition: hooks.txt:1245
ApiQueryWatchlistIntegrationTest\testLimitParam
testLimitParam()
Definition: ApiQueryWatchlistIntegrationTest.php:1191
ApiQueryWatchlistIntegrationTest\doListWatchlistRequest
doListWatchlistRequest(array $params=[], $user=null)
Definition: ApiQueryWatchlistIntegrationTest.php:165
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
ApiQueryWatchlistIntegrationTest
API Database medium.
Definition: ApiQueryWatchlistIntegrationTest.php:13
ApiQueryWatchlistIntegrationTest\testIdsPropParameter
testIdsPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:289
$params
$params
Definition: styleTest.css.php:40
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:550
ApiQueryWatchlistIntegrationTest\testShowBotParams
testShowBotParams()
Definition: ApiQueryWatchlistIntegrationTest.php:842
ApiQueryWatchlistIntegrationTest\doGeneratorWatchlistRequest
doGeneratorWatchlistRequest(array $params=[])
Definition: ApiQueryWatchlistIntegrationTest.php:174
ApiQueryWatchlistIntegrationTest\testStartEndParams
testStartEndParams()
Definition: ApiQueryWatchlistIntegrationTest.php:1366
ApiQueryWatchlistIntegrationTest\setupPatrolledSpecificFixtures
setupPatrolledSpecificFixtures(User $user)
Definition: ApiQueryWatchlistIntegrationTest.php:605
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
ApiQueryWatchlistIntegrationTest\createPageAndDeleteIt
createPageAndDeleteIt(LinkTarget $target)
Definition: ApiQueryWatchlistIntegrationTest.php:638
ApiQueryWatchlistIntegrationTest\getLoggedInTestUser
getLoggedInTestUser()
Definition: ApiQueryWatchlistIntegrationTest.php:29
ApiQueryWatchlistIntegrationTest\testDirParams
testDirParams()
Definition: ApiQueryWatchlistIntegrationTest.php:1310
ApiQueryWatchlistIntegrationTest\testExternalTypeParameters
testExternalTypeParameters()
Definition: ApiQueryWatchlistIntegrationTest.php:1104
ApiQueryWatchlistIntegrationTest\assertArraySubsetsEqual
assertArraySubsetsEqual(array $actualItems, array $expectedItems, array $keysUsedInValueComparison, array $requiredKeys=[])
Convenience method to assert that actual items array fetched from API is equal to the expected array,...
Definition: ApiQueryWatchlistIntegrationTest.php:203
ApiQueryWatchlistIntegrationTest\testContinueParam
testContinueParam()
Definition: ApiQueryWatchlistIntegrationTest.php:1401
ApiQueryWatchlistIntegrationTest\testParsedCommentPropParameter
testParsedCommentPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:507
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
ApiQueryWatchlistIntegrationTest\testShowUnreadParams
testShowUnreadParams()
Definition: ApiQueryWatchlistIntegrationTest.php:899
Revision\newFromTitle
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
Definition: Revision.php:134
ApiQueryWatchlistIntegrationTest\testOwnerAndTokenParams
testOwnerAndTokenParams()
Definition: ApiQueryWatchlistIntegrationTest.php:1465
ApiQueryWatchlistIntegrationTest\testAllRevParam
testAllRevParam()
Definition: ApiQueryWatchlistIntegrationTest.php:1260
ApiQueryWatchlistIntegrationTest\cleanTestUsersWatchlist
cleanTestUsersWatchlist()
Definition: ApiQueryWatchlistIntegrationTest.php:243
ApiQueryWatchlistIntegrationTest\testPatrolPropParameter
testPatrolPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:619
ApiQueryWatchlistIntegrationTest\testNamespaceParam
testNamespaceParam()
Definition: ApiQueryWatchlistIntegrationTest.php:694
ApiQueryWatchlistIntegrationTest\getNonLoggedInTestUser
getNonLoggedInTestUser()
Definition: ApiQueryWatchlistIntegrationTest.php:33
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:121
ApiQueryWatchlistIntegrationTest\getPrefixedText
getPrefixedText(LinkTarget $target)
Definition: ApiQueryWatchlistIntegrationTest.php:238
ApiQueryWatchlistIntegrationTest\testFlagsPropParameter
testFlagsPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:350
ApiQueryWatchlistIntegrationTest\getExternalRC
getExternalRC(LinkTarget $target)
Definition: ApiQueryWatchlistIntegrationTest.php:1061
WatchedItemQueryService\FILTER_MINOR
const FILTER_MINOR
Definition: WatchedItemQueryService.php:34
ApiQueryWatchlistIntegrationTest\testLoginfoPropParameter
testLoginfoPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:648
ApiQueryWatchlistIntegrationTest\testShowPatrolledParams
testShowPatrolledParams()
Definition: ApiQueryWatchlistIntegrationTest.php:957
Title\newFromLinkTarget
static newFromLinkTarget(LinkTarget $linkTarget)
Create a new Title from a LinkTarget.
Definition: Title.php:239
ApiQueryWatchlistIntegrationTest\testGeneratorWatchlistPropRevisions_returnsWatchedItemsRevisions
testGeneratorWatchlistPropRevisions_returnsWatchedItemsRevisions()
Definition: ApiQueryWatchlistIntegrationTest.php:1555
WatchedItemQueryService\FILTER_NOT_BOT
const FILTER_NOT_BOT
Definition: WatchedItemQueryService.php:37
ApiQueryWatchlistIntegrationTest\testCommentPropParameter
testCommentPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:483
ApiQueryWatchlistIntegrationTest\testNewAndEditTypeParameters
testNewAndEditTypeParameters()
Definition: ApiQueryWatchlistIntegrationTest.php:983
WatchedItemQueryService\FILTER_BOT
const FILTER_BOT
Definition: WatchedItemQueryService.php:36
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:79
ApiQueryWatchlistIntegrationTest\doPageEdits
doPageEdits(User $user, array $editData)
Performs a batch of page edits as a specified user.
Definition: ApiQueryWatchlistIntegrationTest.php:123
ApiQueryWatchlistIntegrationTest\testUserPropParameter
testUserPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:411
ApiQueryWatchlistIntegrationTest\testUserIdPropParameter
testUserIdPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:446
ApiQueryWatchlistIntegrationTest\testSizesPropParameter
testSizesPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:550
ApiQueryWatchlistIntegrationTest\getWatchedItemStore
getWatchedItemStore()
Definition: ApiQueryWatchlistIntegrationTest.php:152
ContentHandler\makeContent
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Definition: ContentHandler.php:129
ApiQueryWatchlistIntegrationTest\testEmptyPropParameter
testEmptyPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:671
ApiQueryWatchlistIntegrationTest\testLogTypeParameters
testLogTypeParameters()
Definition: ApiQueryWatchlistIntegrationTest.php:1034
ApiQueryWatchlistIntegrationTest\testTitlePropParameter
testTitlePropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:310
ApiQueryWatchlistIntegrationTest\doBotPageEdit
doBotPageEdit(User $user, LinkTarget $target, $content, $summary)
Definition: ApiQueryWatchlistIntegrationTest.php:61
ApiQueryWatchlistIntegrationTest\__construct
__construct( $name=null, array $data=[], $dataName='')
Definition: ApiQueryWatchlistIntegrationTest.php:15
ApiTestCase\doLogin
doLogin( $testUser='sysop')
Definition: ApiTestCase.php:152
ApiTestCase
Definition: ApiTestCase.php:3
ApiQueryWatchlistIntegrationTest\testUserParam
testUserParam()
Definition: ApiQueryWatchlistIntegrationTest.php:729
MediaWikiTestCase\getMutableTestUser
static getMutableTestUser( $groups=[])
Convenience method for getting a mutable test user.
Definition: MediaWikiTestCase.php:160
ApiQueryWatchlistIntegrationTest\testCategorizeTypeParameter
testCategorizeTypeParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:1140
WatchedItemQueryService\FILTER_NOT_PATROLLED
const FILTER_NOT_PATROLLED
Definition: WatchedItemQueryService.php:41
WatchedItemQueryService\FILTER_NOT_MINOR
const FILTER_NOT_MINOR
Definition: WatchedItemQueryService.php:35
ApiQueryWatchlistIntegrationTest\testGeneratorWatchlistPropInfo_returnsWatchedPages
testGeneratorWatchlistPropInfo_returnsWatchedPages()
Definition: ApiQueryWatchlistIntegrationTest.php:1523
$response
this hook is for auditing only $response
Definition: hooks.txt:781
ApiQueryWatchlistIntegrationTest\testListWatchlist_returnsWatchedItemsWithRCInfo
testListWatchlist_returnsWatchedItemsWithRCInfo()
Definition: ApiQueryWatchlistIntegrationTest.php:252
ApiTestCase\doApiRequest
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null)
Does the API request and returns the result.
Definition: ApiTestCase.php:73
ApiQueryWatchlistIntegrationTest\doAnonPageEdit
doAnonPageEdit(LinkTarget $target, $content, $summary)
Definition: ApiQueryWatchlistIntegrationTest.php:73
ApiQueryWatchlistIntegrationTest\getItemsFromApiResponse
getItemsFromApiResponse(array $response)
Definition: ApiQueryWatchlistIntegrationTest.php:183
WatchedItemQueryService\FILTER_NOT_UNREAD
const FILTER_NOT_UNREAD
Definition: WatchedItemQueryService.php:43
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1750
ApiQueryWatchlistIntegrationTest\doPageEdit
doPageEdit(User $user, LinkTarget $target, $content, $summary)
Definition: ApiQueryWatchlistIntegrationTest.php:37
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
WatchedItemQueryService\FILTER_NOT_ANON
const FILTER_NOT_ANON
Definition: WatchedItemQueryService.php:39
ApiQueryWatchlistIntegrationTest\testShowAnonParams
testShowAnonParams()
Definition: ApiQueryWatchlistIntegrationTest.php:870
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:183
ApiQueryWatchlistIntegrationTest\testExcludeUserParam
testExcludeUserParam()
Definition: ApiQueryWatchlistIntegrationTest.php:766
ApiQueryWatchlistIntegrationTest\testOwnerAndTokenParams_wrongToken
testOwnerAndTokenParams_wrongToken()
Definition: ApiQueryWatchlistIntegrationTest.php:1501
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
ApiQueryWatchlistIntegrationTest\doPatrolledPageEdit
doPatrolledPageEdit(User $user, LinkTarget $target, $content, $summary, User $patrollingUser)
Definition: ApiQueryWatchlistIntegrationTest.php:85
EDIT_MINOR
const EDIT_MINOR
Definition: Defines.php:155
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:27
WatchedItemQueryService\FILTER_ANON
const FILTER_ANON
Definition: WatchedItemQueryService.php:38
ApiQueryWatchlistIntegrationTest\testOwnerAndTokenParams_noWatchlistTokenSet
testOwnerAndTokenParams_noWatchlistTokenSet()
Definition: ApiQueryWatchlistIntegrationTest.php:1514
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:51
WatchedItemQueryService\FILTER_UNREAD
const FILTER_UNREAD
Definition: WatchedItemQueryService.php:42
ApiQueryWatchlistIntegrationTest\doMinorPageEdit
doMinorPageEdit(User $user, LinkTarget $target, $content, $summary)
Definition: ApiQueryWatchlistIntegrationTest.php:49
ApiQueryWatchlistIntegrationTest\testShowMinorParams
testShowMinorParams()
Definition: ApiQueryWatchlistIntegrationTest.php:803
array
the array() calling protocol came about after MediaWiki 1.4rc1.
TitleValue
Represents a page (or page fragment) title within MediaWiki.
Definition: TitleValue.php:36
ApiQueryWatchlistIntegrationTest\testNotificationTimestampPropParameter
testNotificationTimestampPropParameter()
Definition: ApiQueryWatchlistIntegrationTest.php:575
ApiQueryWatchlistIntegrationTest\getTitleFormatter
getTitleFormatter()
Definition: ApiQueryWatchlistIntegrationTest.php:231