MediaWiki  1.30.0
ChangesListSpecialPageTest.php
Go to the documentation of this file.
1 <?php
2 
3 use Wikimedia\TestingAccessWrapper;
4 
18  protected function getPage() {
19  $mock = $this->getMockBuilder( ChangesListSpecialPage::class )
20  ->setConstructorArgs(
21  [
22  'ChangesListSpecialPage',
23  ''
24  ]
25  )
26  ->setMethods( [ 'getPageTitle' ] )
27  ->getMockForAbstractClass();
28 
29  $mock->method( 'getPageTitle' )->willReturn(
30  Title::makeTitle( NS_SPECIAL, 'ChangesListSpecialPage' )
31  );
32 
33  $mock = TestingAccessWrapper::newFromObject(
34  $mock
35  );
36 
37  return $mock;
38  }
39 
40  private function buildQuery(
41  $requestOptions = null,
42  $user = null
43  ) {
45  $context->setRequest( new FauxRequest( $requestOptions ) );
46  if ( $user ) {
47  $context->setUser( $user );
48  }
49 
50  $this->changesListSpecialPage->setContext( $context );
51  $this->changesListSpecialPage->filterGroups = [];
52  $formOptions = $this->changesListSpecialPage->setup( null );
53 
54  #  Filter out rc_timestamp conditions which depends on the test runtime
55  # This condition is not needed as of march 2, 2011 -- hashar
56  # @todo FIXME: Find a way to generate the correct rc_timestamp
57 
58  $tables = [];
59  $fields = [];
60  $queryConditions = [];
61  $query_options = [];
62  $join_conds = [];
63 
64  call_user_func_array(
65  [ $this->changesListSpecialPage, 'buildQuery' ],
66  [
67  &$tables,
68  &$fields,
69  &$queryConditions,
70  &$query_options,
71  &$join_conds,
72  $formOptions
73  ]
74  );
75 
76  $queryConditions = array_filter(
77  $queryConditions,
78  'ChangesListSpecialPageTest::filterOutRcTimestampCondition'
79  );
80 
81  return $queryConditions;
82  }
83 
85  private function assertConditions(
86  $expected,
87  $requestOptions = null,
88  $message = '',
89  $user = null
90  ) {
91  $queryConditions = $this->buildQuery( $requestOptions, $user );
92 
93  $this->assertEquals(
94  self::normalizeCondition( $expected ),
95  self::normalizeCondition( $queryConditions ),
96  $message
97  );
98  }
99 
100  private static function normalizeCondition( $conds ) {
101  $normalized = array_map(
102  function ( $k, $v ) {
103  return is_numeric( $k ) ? $v : "$k = $v";
104  },
105  array_keys( $conds ),
106  $conds
107  );
108  sort( $normalized );
109  return $normalized;
110  }
111 
113  private static function filterOutRcTimestampCondition( $var ) {
114  return ( false === strpos( $var, 'rc_timestamp ' ) );
115  }
116 
117  public function testRcNsFilter() {
118  $this->assertConditions(
119  [ # expected
120  "rc_namespace = '0'",
121  ],
122  [
123  'namespace' => NS_MAIN,
124  ],
125  "rc conditions with one namespace"
126  );
127  }
128 
129  public function testRcNsFilterInversion() {
130  $this->assertConditions(
131  [ # expected
132  "rc_namespace != '0'",
133  ],
134  [
135  'namespace' => NS_MAIN,
136  'invert' => 1,
137  ],
138  "rc conditions with namespace inverted"
139  );
140  }
141 
142  public function testRcNsFilterMultiple() {
143  $this->assertConditions(
144  [ # expected
145  "rc_namespace IN ('1','2','3')",
146  ],
147  [
148  'namespace' => '1;2;3',
149  ],
150  "rc conditions with multiple namespaces"
151  );
152  }
153 
155  $this->assertConditions(
156  [ # expected
157  "rc_namespace IN ('0','1','4','5','6','7')",
158  ],
159  [
160  'namespace' => '1;4;7',
161  'associated' => 1,
162  ],
163  "rc conditions with multiple namespaces and associated"
164  );
165  }
166 
168  $this->assertConditions(
169  [ # expected
170  "rc_namespace NOT IN ('2','3','8','9')",
171  ],
172  [
173  'namespace' => '2;3;9',
174  'associated' => 1,
175  'invert' => 1
176  ],
177  "rc conditions with multiple namespaces, associated and inverted"
178  );
179  }
180 
181  public function testRcNsFilterMultipleInvert() {
182  $this->assertConditions(
183  [ # expected
184  "rc_namespace NOT IN ('1','2','3')",
185  ],
186  [
187  'namespace' => '1;2;3',
188  'invert' => 1,
189  ],
190  "rc conditions with multiple namespaces inverted"
191  );
192  }
193 
194  public function testRcHidemyselfFilter() {
195  $user = $this->getTestUser()->getUser();
196  $this->assertConditions(
197  [ # expected
198  "rc_user_text != '{$user->getName()}'",
199  ],
200  [
201  'hidemyself' => 1,
202  ],
203  "rc conditions: hidemyself=1 (logged in)",
204  $user
205  );
206 
207  $user = User::newFromName( '10.11.12.13', false );
208  $this->assertConditions(
209  [ # expected
210  "rc_user_text != '10.11.12.13'",
211  ],
212  [
213  'hidemyself' => 1,
214  ],
215  "rc conditions: hidemyself=1 (anon)",
216  $user
217  );
218  }
219 
220  public function testRcHidebyothersFilter() {
221  $user = $this->getTestUser()->getUser();
222  $this->assertConditions(
223  [ # expected
224  "rc_user_text = '{$user->getName()}'",
225  ],
226  [
227  'hidebyothers' => 1,
228  ],
229  "rc conditions: hidebyothers=1 (logged in)",
230  $user
231  );
232 
233  $user = User::newFromName( '10.11.12.13', false );
234  $this->assertConditions(
235  [ # expected
236  "rc_user_text = '10.11.12.13'",
237  ],
238  [
239  'hidebyothers' => 1,
240  ],
241  "rc conditions: hidebyothers=1 (anon)",
242  $user
243  );
244  }
245 
246  public function testRcHidepageedits() {
247  $this->assertConditions(
248  [ # expected
249  "rc_type != '0'",
250  ],
251  [
252  'hidepageedits' => 1,
253  ],
254  "rc conditions: hidepageedits=1"
255  );
256  }
257 
258  public function testRcHidenewpages() {
259  $this->assertConditions(
260  [ # expected
261  "rc_type != '1'",
262  ],
263  [
264  'hidenewpages' => 1,
265  ],
266  "rc conditions: hidenewpages=1"
267  );
268  }
269 
270  public function testRcHidelog() {
271  $this->assertConditions(
272  [ # expected
273  "rc_type != '3'",
274  ],
275  [
276  'hidelog' => 1,
277  ],
278  "rc conditions: hidelog=1"
279  );
280  }
281 
282  public function testRcHidehumans() {
283  $this->assertConditions(
284  [ # expected
285  'rc_bot' => 1,
286  ],
287  [
288  'hidebots' => 0,
289  'hidehumans' => 1,
290  ],
291  "rc conditions: hidebots=0 hidehumans=1"
292  );
293  }
294 
296  $user = $this->getTestUser()->getUser();
297  $this->assertConditions(
298  [ # expected
299  ],
300  [
301  'hidepatrolled' => 1,
302  ],
303  "rc conditions: hidepatrolled=1 (user not allowed)",
304  $user
305  );
306  }
307 
309  $user = $this->getTestUser()->getUser();
310  $this->assertConditions(
311  [ # expected
312  ],
313  [
314  'hideunpatrolled' => 1,
315  ],
316  "rc conditions: hideunpatrolled=1 (user not allowed)",
317  $user
318  );
319  }
320  public function testRcHidepatrolledFilter() {
321  $user = $this->getTestSysop()->getUser();
322  $this->assertConditions(
323  [ # expected
324  "rc_patrolled = 0",
325  ],
326  [
327  'hidepatrolled' => 1,
328  ],
329  "rc conditions: hidepatrolled=1",
330  $user
331  );
332  }
333 
334  public function testRcHideunpatrolledFilter() {
335  $user = $this->getTestSysop()->getUser();
336  $this->assertConditions(
337  [ # expected
338  "rc_patrolled = 1",
339  ],
340  [
341  'hideunpatrolled' => 1,
342  ],
343  "rc conditions: hideunpatrolled=1",
344  $user
345  );
346  }
347 
348  public function testRcHideminorFilter() {
349  $this->assertConditions(
350  [ # expected
351  "rc_minor = 0",
352  ],
353  [
354  'hideminor' => 1,
355  ],
356  "rc conditions: hideminor=1"
357  );
358  }
359 
360  public function testRcHidemajorFilter() {
361  $this->assertConditions(
362  [ # expected
363  "rc_minor = 1",
364  ],
365  [
366  'hidemajor' => 1,
367  ],
368  "rc conditions: hidemajor=1"
369  );
370  }
371 
372  public function testHideCategorization() {
373  $this->assertConditions(
374  [
375  # expected
376  "rc_type != '6'"
377  ],
378  [
379  'hidecategorization' => 1
380  ],
381  "rc conditions: hidecategorization=1"
382  );
383  }
384 
385  public function testFilterUserExpLevelAll() {
386  $this->assertConditions(
387  [
388  # expected
389  ],
390  [
391  'userExpLevel' => 'registered;unregistered;newcomer;learner;experienced',
392  ],
393  "rc conditions: userExpLevel=registered;unregistered;newcomer;learner;experienced"
394  );
395  }
396 
398  $this->assertConditions(
399  [
400  # expected
401  ],
402  [
403  'userExpLevel' => 'registered;unregistered',
404  ],
405  "rc conditions: userExpLevel=registered;unregistered"
406  );
407  }
408 
410  $this->assertConditions(
411  [
412  # expected
413  ],
414  [
415  'userExpLevel' => 'registered;unregistered;learner',
416  ],
417  "rc conditions: userExpLevel=registered;unregistered;learner"
418  );
419  }
420 
422  $this->assertConditions(
423  [
424  # expected
425  'rc_user != 0',
426  ],
427  [
428  'userExpLevel' => 'newcomer;learner;experienced',
429  ],
430  "rc conditions: userExpLevel=newcomer;learner;experienced"
431  );
432  }
433 
435  $this->assertConditions(
436  [
437  # expected
438  'rc_user != 0',
439  ],
440  [
441  'userExpLevel' => 'registered',
442  ],
443  "rc conditions: userExpLevel=registered"
444  );
445  }
446 
448  $this->assertConditions(
449  [
450  # expected
451  'rc_user' => 0,
452  ],
453  [
454  'userExpLevel' => 'unregistered',
455  ],
456  "rc conditions: userExpLevel=unregistered"
457  );
458  }
459 
461  $this->assertConditions(
462  [
463  # expected
464  'rc_user != 0',
465  ],
466  [
467  'userExpLevel' => 'registered;learner',
468  ],
469  "rc conditions: userExpLevel=registered;learner"
470  );
471  }
472 
474  $conds = $this->buildQuery( [ 'userExpLevel' => 'unregistered;experienced' ] );
475 
476  $this->assertRegExp(
477  '/\(rc_user = 0\) OR \(\(user_editcount >= 500\) AND \(user_registration <= \'[^\']+\'\)\)/',
478  reset( $conds ),
479  "rc conditions: userExpLevel=unregistered;experienced"
480  );
481  }
482 
483  public function testFilterUserExpLevel() {
484  $now = time();
485  $this->setMwGlobals( [
486  'wgLearnerEdits' => 10,
487  'wgLearnerMemberSince' => 4,
488  'wgExperiencedUserEdits' => 500,
489  'wgExperiencedUserMemberSince' => 30,
490  ] );
491 
492  $this->createUsers( [
493  'Newcomer1' => [ 'edits' => 2, 'days' => 2 ],
494  'Newcomer2' => [ 'edits' => 12, 'days' => 3 ],
495  'Newcomer3' => [ 'edits' => 8, 'days' => 5 ],
496  'Learner1' => [ 'edits' => 15, 'days' => 10 ],
497  'Learner2' => [ 'edits' => 450, 'days' => 20 ],
498  'Learner3' => [ 'edits' => 460, 'days' => 33 ],
499  'Learner4' => [ 'edits' => 525, 'days' => 28 ],
500  'Experienced1' => [ 'edits' => 538, 'days' => 33 ],
501  ], $now );
502 
503  // newcomers only
504  $this->assertArrayEquals(
505  [ 'Newcomer1', 'Newcomer2', 'Newcomer3' ],
506  $this->fetchUsers( [ 'newcomer' ], $now )
507  );
508 
509  // newcomers and learner
510  $this->assertArrayEquals(
511  [
512  'Newcomer1', 'Newcomer2', 'Newcomer3',
513  'Learner1', 'Learner2', 'Learner3', 'Learner4',
514  ],
515  $this->fetchUsers( [ 'newcomer', 'learner' ], $now )
516  );
517 
518  // newcomers and more learner
519  $this->assertArrayEquals(
520  [
521  'Newcomer1', 'Newcomer2', 'Newcomer3',
522  'Experienced1',
523  ],
524  $this->fetchUsers( [ 'newcomer', 'experienced' ], $now )
525  );
526 
527  // learner only
528  $this->assertArrayEquals(
529  [ 'Learner1', 'Learner2', 'Learner3', 'Learner4' ],
530  $this->fetchUsers( [ 'learner' ], $now )
531  );
532 
533  // more experienced only
534  $this->assertArrayEquals(
535  [ 'Experienced1' ],
536  $this->fetchUsers( [ 'experienced' ], $now )
537  );
538 
539  // learner and more experienced
540  $this->assertArrayEquals(
541  [
542  'Learner1', 'Learner2', 'Learner3', 'Learner4',
543  'Experienced1',
544  ],
545  $this->fetchUsers( [ 'learner', 'experienced' ], $now ),
546  'Learner and more experienced'
547  );
548  }
549 
550  private function createUsers( $specs, $now ) {
551  $dbw = wfGetDB( DB_MASTER );
552  foreach ( $specs as $name => $spec ) {
554  $name,
555  [
556  'editcount' => $spec['edits'],
557  'registration' => $dbw->timestamp( $this->daysAgo( $spec['days'], $now ) ),
558  'email' => 'ut',
559  ]
560  );
561  }
562  }
563 
564  private function fetchUsers( $filters, $now ) {
565  $tables = [];
566  $conds = [];
567  $fields = [];
568  $query_options = [];
569  $join_conds = [];
570 
571  sort( $filters );
572 
573  call_user_func_array(
574  [ $this->changesListSpecialPage, 'filterOnUserExperienceLevel' ],
575  [
576  get_class( $this->changesListSpecialPage ),
577  $this->changesListSpecialPage->getContext(),
578  $this->changesListSpecialPage->getDB(),
579  &$tables,
580  &$fields,
581  &$conds,
582  &$query_options,
583  &$join_conds,
584  $filters,
585  $now
586  ]
587  );
588 
589  $result = wfGetDB( DB_MASTER )->select(
590  $tables,
591  'user_name',
592  array_filter( $conds ) + [ 'user_email' => 'ut' ]
593  );
594 
595  $usernames = [];
596  foreach ( $result as $row ) {
597  $usernames[] = $row->user_name;
598  }
599 
600  return $usernames;
601  }
602 
603  private function daysAgo( $days, $now ) {
604  $secondsPerDay = 86400;
605  return $now - $days * $secondsPerDay;
606  }
607 
609  $customFilters = [
610  'hidefoo' => [
611  'msg' => 'showhidefoo',
612  'default' => true,
613  ],
614 
615  'hidebar' => [
616  'msg' => 'showhidebar',
617  'default' => false,
618  ],
619  ];
620 
621  $this->assertEquals(
622  [
623  'name' => 'unstructured',
625  'priority' => -1,
626  'filters' => [
627  [
628  'name' => 'hidefoo',
629  'showHide' => 'showhidefoo',
630  'default' => true,
631  ],
632  [
633  'name' => 'hidebar',
634  'showHide' => 'showhidebar',
635  'default' => false,
636  ]
637  ],
638  ],
639  $this->changesListSpecialPage->getFilterGroupDefinitionFromLegacyCustomFilters(
640  $customFilters
641  )
642  );
643  }
644 
645  public function testGetStructuredFilterJsData() {
646  $this->changesListSpecialPage->filterGroups = [];
647 
648  $definition = [
649  [
650  'name' => 'gub-group',
651  'title' => 'gub-group-title',
653  'filters' => [
654  [
655  'name' => 'hidefoo',
656  'label' => 'foo-label',
657  'description' => 'foo-description',
658  'default' => true,
659  'showHide' => 'showhidefoo',
660  'priority' => 2,
661  ],
662  [
663  'name' => 'hidebar',
664  'label' => 'bar-label',
665  'description' => 'bar-description',
666  'default' => false,
667  'priority' => 4,
668  ]
669  ],
670  ],
671 
672  [
673  'name' => 'des-group',
674  'title' => 'des-group-title',
676  'isFullCoverage' => true,
677  'filters' => [
678  [
679  'name' => 'grault',
680  'label' => 'grault-label',
681  'description' => 'grault-description',
682  ],
683  [
684  'name' => 'garply',
685  'label' => 'garply-label',
686  'description' => 'garply-description',
687  ],
688  ],
689  'queryCallable' => function () {
690  },
692  ],
693 
694  [
695  'name' => 'unstructured',
697  'filters' => [
698  [
699  'name' => 'hidethud',
700  'showHide' => 'showhidethud',
701  'default' => true,
702  ],
703 
704  [
705  'name' => 'hidemos',
706  'showHide' => 'showhidemos',
707  'default' => false,
708  ],
709  ],
710  ],
711 
712  ];
713 
714  $this->changesListSpecialPage->registerFiltersFromDefinitions( $definition );
715 
716  $this->assertArrayEquals(
717  [
718  // Filters that only display in the unstructured UI are
719  // are not included, and neither are groups that would
720  // be empty due to the above.
721  'groups' => [
722  [
723  'name' => 'gub-group',
724  'title' => 'gub-group-title',
726  'priority' => -1,
727  'filters' => [
728  [
729  'name' => 'hidebar',
730  'label' => 'bar-label',
731  'description' => 'bar-description',
732  'default' => false,
733  'priority' => 4,
734  'cssClass' => null,
735  'conflicts' => [],
736  'subset' => [],
737  ],
738  [
739  'name' => 'hidefoo',
740  'label' => 'foo-label',
741  'description' => 'foo-description',
742  'default' => true,
743  'priority' => 2,
744  'cssClass' => null,
745  'conflicts' => [],
746  'subset' => [],
747  ],
748  ],
749  'fullCoverage' => true,
750  'conflicts' => [],
751  ],
752 
753  [
754  'name' => 'des-group',
755  'title' => 'des-group-title',
757  'priority' => -2,
758  'fullCoverage' => true,
759  'filters' => [
760  [
761  'name' => 'grault',
762  'label' => 'grault-label',
763  'description' => 'grault-description',
764  'cssClass' => null,
765  'priority' => -2,
766  'conflicts' => [],
767  'subset' => [],
768  ],
769  [
770  'name' => 'garply',
771  'label' => 'garply-label',
772  'description' => 'garply-description',
773  'cssClass' => null,
774  'priority' => -3,
775  'conflicts' => [],
776  'subset' => [],
777  ],
778  ],
779  'conflicts' => [],
780  'separator' => ';',
782  ],
783  ],
784  'messageKeys' => [
785  'gub-group-title',
786  'bar-label',
787  'bar-description',
788  'foo-label',
789  'foo-description',
790  'des-group-title',
791  'grault-label',
792  'grault-description',
793  'garply-label',
794  'garply-description',
795  ],
796  ],
797  $this->changesListSpecialPage->getStructuredFilterJsData(), false, true
800  );
801  }
802 
803  public function provideParseParameters() {
804  return [
805  [ 'hidebots', [ 'hidebots' => true ] ],
806 
807  [ 'bots', [ 'hidebots' => false ] ],
808 
809  [ 'hideminor', [ 'hideminor' => true ] ],
810 
811  [ 'minor', [ 'hideminor' => false ] ],
812 
813  [ 'hidemajor', [ 'hidemajor' => true ] ],
814 
815  [ 'hideliu', [ 'hideliu' => true ] ],
816 
817  [ 'hidepatrolled', [ 'hidepatrolled' => true ] ],
818 
819  [ 'hideunpatrolled', [ 'hideunpatrolled' => true ] ],
820 
821  [ 'hideanons', [ 'hideanons' => true ] ],
822 
823  [ 'hidemyself', [ 'hidemyself' => true ] ],
824 
825  [ 'hidebyothers', [ 'hidebyothers' => true ] ],
826 
827  [ 'hidehumans', [ 'hidehumans' => true ] ],
828 
829  [ 'hidepageedits', [ 'hidepageedits' => true ] ],
830 
831  [ 'pagedits', [ 'hidepageedits' => false ] ],
832 
833  [ 'hidenewpages', [ 'hidenewpages' => true ] ],
834 
835  [ 'hidecategorization', [ 'hidecategorization' => true ] ],
836 
837  [ 'hidelog', [ 'hidelog' => true ] ],
838 
839  [
840  'userExpLevel=learner;experienced',
841  [
842  'userExpLevel' => 'learner;experienced'
843  ],
844  ],
845 
846  // A few random combos
847  [
848  'bots,hideliu,hidemyself',
849  [
850  'hidebots' => false,
851  'hideliu' => true,
852  'hidemyself' => true,
853  ],
854  ],
855 
856  [
857  'minor,hideanons,categorization',
858  [
859  'hideminor' => false,
860  'hideanons' => true,
861  'hidecategorization' => false,
862  ]
863  ],
864 
865  [
866  'hidehumans,bots,hidecategorization',
867  [
868  'hidehumans' => true,
869  'hidebots' => false,
870  'hidecategorization' => true,
871  ],
872  ],
873 
874  [
875  'hidemyself,userExpLevel=newcomer;learner,hideminor',
876  [
877  'hidemyself' => true,
878  'hideminor' => true,
879  'userExpLevel' => 'newcomer;learner',
880  ],
881  ],
882  ];
883  }
884 
885  public function provideGetFilterConflicts() {
886  return [
887  [
888  "parameters" => [],
889  "expectedConflicts" => false,
890  ],
891  [
892  "parameters" => [
893  "hideliu" => true,
894  "userExpLevel" => "newcomer",
895  ],
896  "expectedConflicts" => false,
897  ],
898  [
899  "parameters" => [
900  "hideanons" => true,
901  "userExpLevel" => "learner",
902  ],
903  "expectedConflicts" => false,
904  ],
905  [
906  "parameters" => [
907  "hidemajor" => true,
908  "hidenewpages" => true,
909  "hidepageedits" => true,
910  "hidecategorization" => false,
911  "hidelog" => true,
912  "hideWikidata" => true,
913  ],
914  "expectedConflicts" => true,
915  ],
916  [
917  "parameters" => [
918  "hidemajor" => true,
919  "hidenewpages" => false,
920  "hidepageedits" => true,
921  "hidecategorization" => false,
922  "hidelog" => false,
923  "hideWikidata" => true,
924  ],
925  "expectedConflicts" => true,
926  ],
927  [
928  "parameters" => [
929  "hidemajor" => true,
930  "hidenewpages" => false,
931  "hidepageedits" => false,
932  "hidecategorization" => true,
933  "hidelog" => true,
934  "hideWikidata" => true,
935  ],
936  "expectedConflicts" => false,
937  ],
938  [
939  "parameters" => [
940  "hideminor" => true,
941  "hidenewpages" => true,
942  "hidepageedits" => true,
943  "hidecategorization" => false,
944  "hidelog" => true,
945  "hideWikidata" => true,
946  ],
947  "expectedConflicts" => false,
948  ],
949  ];
950  }
951 
955  public function testGetFilterConflicts( $parameters, $expectedConflicts ) {
956  $context = new RequestContext;
957  $context->setRequest( new FauxRequest( $parameters ) );
958  $this->changesListSpecialPage->setContext( $context );
959 
960  $this->assertEquals(
961  $expectedConflicts,
962  $this->changesListSpecialPage->areFiltersInConflict()
963  );
964  }
965 
966  public function validateOptionsProvider() {
967  return [
968  [
969  [ 'hideanons' => 1, 'hideliu' => 1, 'hidebots' => 1 ],
970  true,
971  [ 'hideliu' => 1, 'hidebots' => 1, ],
972  ],
973 
974  [
975  [ 'hideanons' => 1, 'hideliu' => 1, 'hidebots' => 0 ],
976  true,
977  [ 'hidebots' => 0, 'hidehumans' => 1 ],
978  ],
979 
980  [
981  [ 'hidemyself' => 1, 'hidebyothers' => 1 ],
982  true,
983  [],
984  ],
985  [
986  [ 'hidebots' => 1, 'hidehumans' => 1 ],
987  true,
988  [],
989  ],
990  [
991  [ 'hidepatrolled' => 1, 'hideunpatrolled' => 1 ],
992  true,
993  [],
994  ],
995  [
996  [ 'hideminor' => 1, 'hidemajor' => 1 ],
997  true,
998  [],
999  ],
1000  [
1001  // changeType
1002  [ 'hidepageedits' => 1, 'hidenewpages' => 1, 'hidecategorization' => 1, 'hidelog' => 1, ],
1003  true,
1004  [],
1005  ],
1006  ];
1007  }
1008 }
ChangesListSpecialPageTest\testRcNsFilterMultipleAssociatedInvert
testRcNsFilterMultipleAssociatedInvert()
Definition: ChangesListSpecialPageTest.php:167
$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
FauxRequest
WebRequest clone which takes values from a provided array.
Definition: FauxRequest.php:33
MediaWikiTestCase\assertArrayEquals
assertArrayEquals(array $expected, array $actual, $ordered=false, $named=false)
Assert that two arrays are equal.
Definition: MediaWikiTestCase.php:1552
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
ChangesListSpecialPageTest\daysAgo
daysAgo( $days, $now)
Definition: ChangesListSpecialPageTest.php:603
ChangesListSpecialPageTest\testFilterUserExpLevelAllExperienceLevels
testFilterUserExpLevelAllExperienceLevels()
Definition: ChangesListSpecialPageTest.php:421
ChangesListSpecialPageTest\testFilterUserExpLevelRegisteredUnregisteredLearner
testFilterUserExpLevelRegisteredUnregisteredLearner()
Definition: ChangesListSpecialPageTest.php:409
$tables
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:988
$context
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2581
MediaWikiTestCase\getTestUser
static getTestUser( $groups=[])
Convenience method for getting an immutable test user.
Definition: MediaWikiTestCase.php:148
ChangesListSpecialPageTest\testRcHidemyselfFilter
testRcHidemyselfFilter()
Definition: ChangesListSpecialPageTest.php:194
ChangesListSpecialPageTest\testGetFilterGroupDefinitionFromLegacyCustomFilters
testGetFilterGroupDefinitionFromLegacyCustomFilters()
Definition: ChangesListSpecialPageTest.php:608
ChangesListSpecialPageTest\testRcHideunpatrolledFilter
testRcHideunpatrolledFilter()
Definition: ChangesListSpecialPageTest.php:334
ChangesListSpecialPageTest\assertConditions
assertConditions( $expected, $requestOptions=null, $message='', $user=null)
helper to test SpecialRecentchanges::buildQuery()
Definition: ChangesListSpecialPageTest.php:85
ChangesListSpecialPageTest\testFilterUserExpLevelRegistrered
testFilterUserExpLevelRegistrered()
Definition: ChangesListSpecialPageTest.php:434
ChangesListSpecialPageTest\testFilterUserExpLevelUnregistrered
testFilterUserExpLevelUnregistrered()
Definition: ChangesListSpecialPageTest.php:447
ChangesListSpecialPageTest\getPage
getPage()
Definition: ChangesListSpecialPageTest.php:18
$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
ChangesListSpecialPageTest\testRcNsFilterMultipleAssociated
testRcNsFilterMultipleAssociated()
Definition: ChangesListSpecialPageTest.php:154
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
ChangesListSpecialPageTest\testRcHidelog
testRcHidelog()
Definition: ChangesListSpecialPageTest.php:270
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:550
ChangesListSpecialPageTest\testFilterUserExpLevel
testFilterUserExpLevel()
Definition: ChangesListSpecialPageTest.php:483
ChangesListSpecialPageTest\testRcHidemajorFilter
testRcHidemajorFilter()
Definition: ChangesListSpecialPageTest.php:360
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
ChangesListSpecialPageTest\testRcHidepageedits
testRcHidepageedits()
Definition: ChangesListSpecialPageTest.php:246
ChangesListSpecialPageTest\testRcNsFilterInversion
testRcNsFilterInversion()
Definition: ChangesListSpecialPageTest.php:129
ChangesListSpecialPageTest\testFilterUserExpLevelRegistreredOrLearner
testFilterUserExpLevelRegistreredOrLearner()
Definition: ChangesListSpecialPageTest.php:460
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
User\createNew
static createNew( $name, $params=[])
Add a user to the database, return the user object.
Definition: User.php:4106
ChangesListSpecialPageTest\testRcNsFilterMultiple
testRcNsFilterMultiple()
Definition: ChangesListSpecialPageTest.php:142
NS_MAIN
const NS_MAIN
Definition: Defines.php:65
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:54
ChangesListSpecialPageTest
Test class for ChangesListSpecialPage class.
Definition: ChangesListSpecialPageTest.php:17
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2856
ChangesListSpecialPageTest\testRcNsFilter
testRcNsFilter()
Definition: ChangesListSpecialPageTest.php:117
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition: MediaWikiTestCase.php:672
ChangesListSpecialPageTest\testFilterUserExpLevelUnregistreredOrExperienced
testFilterUserExpLevelUnregistreredOrExperienced()
Definition: ChangesListSpecialPageTest.php:473
ChangesListSpecialPageTest\testGetFilterConflicts
testGetFilterConflicts( $parameters, $expectedConflicts)
provideGetFilterConflicts
Definition: ChangesListSpecialPageTest.php:955
ChangesListSpecialPageTest\testRcHidebyothersFilter
testRcHidebyothersFilter()
Definition: ChangesListSpecialPageTest.php:220
ChangesListSpecialPageTest\testFilterUserExpLevelAll
testFilterUserExpLevelAll()
Definition: ChangesListSpecialPageTest.php:385
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:529
RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition: RequestContext.php:33
ChangesListSpecialPageTest\testRcHideunpatrolledDisabledFilter
testRcHideunpatrolledDisabledFilter()
Definition: ChangesListSpecialPageTest.php:308
DB_MASTER
const DB_MASTER
Definition: defines.php:26
ChangesListSpecialPageTest\provideGetFilterConflicts
provideGetFilterConflicts()
Definition: ChangesListSpecialPageTest.php:885
ChangesListSpecialPageTest\fetchUsers
fetchUsers( $filters, $now)
Definition: ChangesListSpecialPageTest.php:564
ChangesListSpecialPageTest\createUsers
createUsers( $specs, $now)
Definition: ChangesListSpecialPageTest.php:550
ChangesListSpecialPageTest\normalizeCondition
static normalizeCondition( $conds)
Definition: ChangesListSpecialPageTest.php:100
ChangesListSpecialPageTest\testRcHidepatrolledFilter
testRcHidepatrolledFilter()
Definition: ChangesListSpecialPageTest.php:320
ChangesListSpecialPageTest\testRcHidenewpages
testRcHidenewpages()
Definition: ChangesListSpecialPageTest.php:258
MediaWikiTestCase\getTestSysop
static getTestSysop()
Convenience method for getting an immutable admin test user.
Definition: MediaWikiTestCase.php:172
ChangesListStringOptionsFilterGroup\NONE
const NONE
Signifies that no options in the group are selected, meaning the group has no effect.
Definition: ChangesListStringOptionsFilterGroup.php:61
ChangesListSpecialPageTest\buildQuery
buildQuery( $requestOptions=null, $user=null)
Definition: ChangesListSpecialPageTest.php:40
ChangesListSpecialPageTest\provideParseParameters
provideParseParameters()
Definition: ChangesListSpecialPageTest.php:803
ChangesListSpecialPageTest\testRcHidehumans
testRcHidehumans()
Definition: ChangesListSpecialPageTest.php:282
ChangesListSpecialPageTest\testRcHideminorFilter
testRcHideminorFilter()
Definition: ChangesListSpecialPageTest.php:348
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
true
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1965
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
ChangesListSpecialPageTest\testRcNsFilterMultipleInvert
testRcNsFilterMultipleInvert()
Definition: ChangesListSpecialPageTest.php:181
ChangesListBooleanFilterGroup\TYPE
const TYPE
Type marker, used by JavaScript.
Definition: ChangesListBooleanFilterGroup.php:14
ChangesListSpecialPageTest\testHideCategorization
testHideCategorization()
Definition: ChangesListSpecialPageTest.php:372
ChangesListSpecialPageTest\validateOptionsProvider
validateOptionsProvider()
Definition: ChangesListSpecialPageTest.php:966
ChangesListSpecialPageTest\filterOutRcTimestampCondition
static filterOutRcTimestampCondition( $var)
return false if condition begin with 'rc_timestamp '
Definition: ChangesListSpecialPageTest.php:113
ChangesListStringOptionsFilterGroup\TYPE
const TYPE
Type marker, used by JavaScript.
Definition: ChangesListStringOptionsFilterGroup.php:43
ChangesListSpecialPageTest\testFilterUserExpLevelRegisteredUnregistered
testFilterUserExpLevelRegisteredUnregistered()
Definition: ChangesListSpecialPageTest.php:397
AbstractChangesListSpecialPageTestCase
Abstract base class for shared logic when testing ChangesListSpecialPage and subclasses.
Definition: AbstractChangesListSpecialPageTestCase.php:9
ChangesListSpecialPageTest\testGetStructuredFilterJsData
testGetStructuredFilterJsData()
Definition: ChangesListSpecialPageTest.php:645
ChangesListSpecialPageTest\testRcHidepatrolledDisabledFilter
testRcHidepatrolledDisabledFilter()
Definition: ChangesListSpecialPageTest.php:295