MediaWiki REL1_30
ChangesListSpecialPage.php
Go to the documentation of this file.
1<?php
27
34abstract class ChangesListSpecialPage extends SpecialPage {
40
42 protected $rcSubpage;
43
45 protected $rcOptions;
46
48 protected $customFilters;
49
50 // Order of both groups and filters is significant; first is top-most priority,
51 // descending from there.
52 // 'showHideSuffix' is a shortcut to and avoid spelling out
53 // details specific to subclasses here.
68
69 // Same format as filterGroupDefinitions, but for a single group (reviewStatus)
70 // that is registered conditionally.
72
73 // Single filter registered conditionally
75
82 protected $filterGroups = [];
83
84 public function __construct( $name, $restriction ) {
85 parent::__construct( $name, $restriction );
86
87 $this->filterGroupDefinitions = [
88 [
89 'name' => 'registration',
90 'title' => 'rcfilters-filtergroup-registration',
91 'class' => ChangesListBooleanFilterGroup::class,
92 'filters' => [
93 [
94 'name' => 'hideliu',
95 // rcshowhideliu-show, rcshowhideliu-hide,
96 // wlshowhideliu
97 'showHideSuffix' => 'showhideliu',
98 'default' => false,
99 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
100 &$query_options, &$join_conds
101 ) {
102 $conds[] = 'rc_user = 0';
103 },
104 'isReplacedInStructuredUi' => true,
105
106 ],
107 [
108 'name' => 'hideanons',
109 // rcshowhideanons-show, rcshowhideanons-hide,
110 // wlshowhideanons
111 'showHideSuffix' => 'showhideanons',
112 'default' => false,
113 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
114 &$query_options, &$join_conds
115 ) {
116 $conds[] = 'rc_user != 0';
117 },
118 'isReplacedInStructuredUi' => true,
119 ]
120 ],
121 ],
122
123 [
124 'name' => 'userExpLevel',
125 'title' => 'rcfilters-filtergroup-userExpLevel',
126 'class' => ChangesListStringOptionsFilterGroup::class,
127 'isFullCoverage' => true,
128 'filters' => [
129 [
130 'name' => 'unregistered',
131 'label' => 'rcfilters-filter-user-experience-level-unregistered-label',
132 'description' => 'rcfilters-filter-user-experience-level-unregistered-description',
133 'cssClassSuffix' => 'user-unregistered',
134 'isRowApplicableCallable' => function ( $ctx, $rc ) {
135 return !$rc->getAttribute( 'rc_user' );
136 }
137 ],
138 [
139 'name' => 'registered',
140 'label' => 'rcfilters-filter-user-experience-level-registered-label',
141 'description' => 'rcfilters-filter-user-experience-level-registered-description',
142 'cssClassSuffix' => 'user-registered',
143 'isRowApplicableCallable' => function ( $ctx, $rc ) {
144 return $rc->getAttribute( 'rc_user' );
145 }
146 ],
147 [
148 'name' => 'newcomer',
149 'label' => 'rcfilters-filter-user-experience-level-newcomer-label',
150 'description' => 'rcfilters-filter-user-experience-level-newcomer-description',
151 'cssClassSuffix' => 'user-newcomer',
152 'isRowApplicableCallable' => function ( $ctx, $rc ) {
153 $performer = $rc->getPerformer();
154 return $performer && $performer->isLoggedIn() &&
155 $performer->getExperienceLevel() === 'newcomer';
156 }
157 ],
158 [
159 'name' => 'learner',
160 'label' => 'rcfilters-filter-user-experience-level-learner-label',
161 'description' => 'rcfilters-filter-user-experience-level-learner-description',
162 'cssClassSuffix' => 'user-learner',
163 'isRowApplicableCallable' => function ( $ctx, $rc ) {
164 $performer = $rc->getPerformer();
165 return $performer && $performer->isLoggedIn() &&
166 $performer->getExperienceLevel() === 'learner';
167 },
168 ],
169 [
170 'name' => 'experienced',
171 'label' => 'rcfilters-filter-user-experience-level-experienced-label',
172 'description' => 'rcfilters-filter-user-experience-level-experienced-description',
173 'cssClassSuffix' => 'user-experienced',
174 'isRowApplicableCallable' => function ( $ctx, $rc ) {
175 $performer = $rc->getPerformer();
176 return $performer && $performer->isLoggedIn() &&
177 $performer->getExperienceLevel() === 'experienced';
178 },
179 ]
180 ],
182 'queryCallable' => [ $this, 'filterOnUserExperienceLevel' ],
183 ],
184
185 [
186 'name' => 'authorship',
187 'title' => 'rcfilters-filtergroup-authorship',
188 'class' => ChangesListBooleanFilterGroup::class,
189 'filters' => [
190 [
191 'name' => 'hidemyself',
192 'label' => 'rcfilters-filter-editsbyself-label',
193 'description' => 'rcfilters-filter-editsbyself-description',
194 // rcshowhidemine-show, rcshowhidemine-hide,
195 // wlshowhidemine
196 'showHideSuffix' => 'showhidemine',
197 'default' => false,
198 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
199 &$query_options, &$join_conds
200 ) {
201 $user = $ctx->getUser();
202 $conds[] = 'rc_user_text != ' . $dbr->addQuotes( $user->getName() );
203 },
204 'cssClassSuffix' => 'self',
205 'isRowApplicableCallable' => function ( $ctx, $rc ) {
206 return $ctx->getUser()->equals( $rc->getPerformer() );
207 },
208 ],
209 [
210 'name' => 'hidebyothers',
211 'label' => 'rcfilters-filter-editsbyother-label',
212 'description' => 'rcfilters-filter-editsbyother-description',
213 'default' => false,
214 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
215 &$query_options, &$join_conds
216 ) {
217 $user = $ctx->getUser();
218 $conds[] = 'rc_user_text = ' . $dbr->addQuotes( $user->getName() );
219 },
220 'cssClassSuffix' => 'others',
221 'isRowApplicableCallable' => function ( $ctx, $rc ) {
222 return !$ctx->getUser()->equals( $rc->getPerformer() );
223 },
224 ]
225 ]
226 ],
227
228 [
229 'name' => 'automated',
230 'title' => 'rcfilters-filtergroup-automated',
231 'class' => ChangesListBooleanFilterGroup::class,
232 'filters' => [
233 [
234 'name' => 'hidebots',
235 'label' => 'rcfilters-filter-bots-label',
236 'description' => 'rcfilters-filter-bots-description',
237 // rcshowhidebots-show, rcshowhidebots-hide,
238 // wlshowhidebots
239 'showHideSuffix' => 'showhidebots',
240 'default' => false,
241 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
242 &$query_options, &$join_conds
243 ) {
244 $conds[] = 'rc_bot = 0';
245 },
246 'cssClassSuffix' => 'bot',
247 'isRowApplicableCallable' => function ( $ctx, $rc ) {
248 return $rc->getAttribute( 'rc_bot' );
249 },
250 ],
251 [
252 'name' => 'hidehumans',
253 'label' => 'rcfilters-filter-humans-label',
254 'description' => 'rcfilters-filter-humans-description',
255 'default' => false,
256 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
257 &$query_options, &$join_conds
258 ) {
259 $conds[] = 'rc_bot = 1';
260 },
261 'cssClassSuffix' => 'human',
262 'isRowApplicableCallable' => function ( $ctx, $rc ) {
263 return !$rc->getAttribute( 'rc_bot' );
264 },
265 ]
266 ]
267 ],
268
269 // reviewStatus (conditional)
270
271 [
272 'name' => 'significance',
273 'title' => 'rcfilters-filtergroup-significance',
274 'class' => ChangesListBooleanFilterGroup::class,
275 'priority' => -6,
276 'filters' => [
277 [
278 'name' => 'hideminor',
279 'label' => 'rcfilters-filter-minor-label',
280 'description' => 'rcfilters-filter-minor-description',
281 // rcshowhideminor-show, rcshowhideminor-hide,
282 // wlshowhideminor
283 'showHideSuffix' => 'showhideminor',
284 'default' => false,
285 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
286 &$query_options, &$join_conds
287 ) {
288 $conds[] = 'rc_minor = 0';
289 },
290 'cssClassSuffix' => 'minor',
291 'isRowApplicableCallable' => function ( $ctx, $rc ) {
292 return $rc->getAttribute( 'rc_minor' );
293 }
294 ],
295 [
296 'name' => 'hidemajor',
297 'label' => 'rcfilters-filter-major-label',
298 'description' => 'rcfilters-filter-major-description',
299 'default' => false,
300 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
301 &$query_options, &$join_conds
302 ) {
303 $conds[] = 'rc_minor = 1';
304 },
305 'cssClassSuffix' => 'major',
306 'isRowApplicableCallable' => function ( $ctx, $rc ) {
307 return !$rc->getAttribute( 'rc_minor' );
308 }
309 ]
310 ]
311 ],
312
313 [
314 'name' => 'lastRevision',
315 'title' => 'rcfilters-filtergroup-lastRevision',
316 'class' => ChangesListBooleanFilterGroup::class,
317 'priority' => -7,
318 'filters' => [
319 [
320 'name' => 'hidelastrevision',
321 'label' => 'rcfilters-filter-lastrevision-label',
322 'description' => 'rcfilters-filter-lastrevision-description',
323 'default' => false,
324 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
325 &$query_options, &$join_conds ) {
326 $conds[] = 'rc_this_oldid <> page_latest';
327 },
328 'cssClassSuffix' => 'last',
329 'isRowApplicableCallable' => function ( $ctx, $rc ) {
330 return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
331 }
332 ],
333 [
334 'name' => 'hidepreviousrevisions',
335 'label' => 'rcfilters-filter-previousrevision-label',
336 'description' => 'rcfilters-filter-previousrevision-description',
337 'default' => false,
338 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
339 &$query_options, &$join_conds ) {
340 $conds[] = 'rc_this_oldid = page_latest';
341 },
342 'cssClassSuffix' => 'previous',
343 'isRowApplicableCallable' => function ( $ctx, $rc ) {
344 return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
345 }
346 ]
347 ]
348 ],
349
350 // With extensions, there can be change types that will not be hidden by any of these.
351 [
352 'name' => 'changeType',
353 'title' => 'rcfilters-filtergroup-changetype',
354 'class' => ChangesListBooleanFilterGroup::class,
355 'priority' => -8,
356 'filters' => [
357 [
358 'name' => 'hidepageedits',
359 'label' => 'rcfilters-filter-pageedits-label',
360 'description' => 'rcfilters-filter-pageedits-description',
361 'default' => false,
362 'priority' => -2,
363 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
364 &$query_options, &$join_conds
365 ) {
366 $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT );
367 },
368 'cssClassSuffix' => 'src-mw-edit',
369 'isRowApplicableCallable' => function ( $ctx, $rc ) {
370 return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_EDIT;
371 },
372 ],
373 [
374 'name' => 'hidenewpages',
375 'label' => 'rcfilters-filter-newpages-label',
376 'description' => 'rcfilters-filter-newpages-description',
377 'default' => false,
378 'priority' => -3,
379 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
380 &$query_options, &$join_conds
381 ) {
382 $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW );
383 },
384 'cssClassSuffix' => 'src-mw-new',
385 'isRowApplicableCallable' => function ( $ctx, $rc ) {
386 return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_NEW;
387 },
388 ],
389
390 // hidecategorization
391
392 [
393 'name' => 'hidelog',
394 'label' => 'rcfilters-filter-logactions-label',
395 'description' => 'rcfilters-filter-logactions-description',
396 'default' => false,
397 'priority' => -5,
398 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
399 &$query_options, &$join_conds
400 ) {
401 $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG );
402 },
403 'cssClassSuffix' => 'src-mw-log',
404 'isRowApplicableCallable' => function ( $ctx, $rc ) {
405 return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_LOG;
406 }
407 ],
408 ],
409 ],
410
411 ];
412
413 $this->reviewStatusFilterGroupDefinition = [
414 [
415 'name' => 'reviewStatus',
416 'title' => 'rcfilters-filtergroup-reviewstatus',
417 'class' => ChangesListBooleanFilterGroup::class,
418 'priority' => -5,
419 'filters' => [
420 [
421 'name' => 'hidepatrolled',
422 'label' => 'rcfilters-filter-patrolled-label',
423 'description' => 'rcfilters-filter-patrolled-description',
424 // rcshowhidepatr-show, rcshowhidepatr-hide
425 // wlshowhidepatr
426 'showHideSuffix' => 'showhidepatr',
427 'default' => false,
428 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
429 &$query_options, &$join_conds
430 ) {
431 $conds[] = 'rc_patrolled = 0';
432 },
433 'cssClassSuffix' => 'patrolled',
434 'isRowApplicableCallable' => function ( $ctx, $rc ) {
435 return $rc->getAttribute( 'rc_patrolled' );
436 },
437 ],
438 [
439 'name' => 'hideunpatrolled',
440 'label' => 'rcfilters-filter-unpatrolled-label',
441 'description' => 'rcfilters-filter-unpatrolled-description',
442 'default' => false,
443 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
444 &$query_options, &$join_conds
445 ) {
446 $conds[] = 'rc_patrolled = 1';
447 },
448 'cssClassSuffix' => 'unpatrolled',
449 'isRowApplicableCallable' => function ( $ctx, $rc ) {
450 return !$rc->getAttribute( 'rc_patrolled' );
451 },
452 ],
453 ],
454 ]
455 ];
456
457 $this->hideCategorizationFilterDefinition = [
458 'name' => 'hidecategorization',
459 'label' => 'rcfilters-filter-categorization-label',
460 'description' => 'rcfilters-filter-categorization-description',
461 // rcshowhidecategorization-show, rcshowhidecategorization-hide.
462 // wlshowhidecategorization
463 'showHideSuffix' => 'showhidecategorization',
464 'default' => false,
465 'priority' => -4,
466 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
467 &$query_options, &$join_conds
468 ) {
469 $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE );
470 },
471 'cssClassSuffix' => 'src-mw-categorize',
472 'isRowApplicableCallable' => function ( $ctx, $rc ) {
473 return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_CATEGORIZE;
474 },
475 ];
476 }
477
483 protected function areFiltersInConflict() {
484 $opts = $this->getOptions();
486 foreach ( $this->getFilterGroups() as $group ) {
487 if ( $group->getConflictingGroups() ) {
489 $group->getName() .
490 " specifies conflicts with other groups but these are not supported yet."
491 );
492 }
493
495 foreach ( $group->getConflictingFilters() as $conflictingFilter ) {
496 if ( $conflictingFilter->activelyInConflictWithGroup( $group, $opts ) ) {
497 return true;
498 }
499 }
500
502 foreach ( $group->getFilters() as $filter ) {
504 foreach ( $filter->getConflictingFilters() as $conflictingFilter ) {
505 if (
506 $conflictingFilter->activelyInConflictWithFilter( $filter, $opts ) &&
507 $filter->activelyInConflictWithFilter( $conflictingFilter, $opts )
508 ) {
509 return true;
510 }
511 }
512
513 }
514
515 }
516
517 return false;
518 }
519
525 public function execute( $subpage ) {
526 $this->rcSubpage = $subpage;
527
528 $rows = $this->getRows();
529 $opts = $this->getOptions();
530 if ( $rows === false ) {
531 $rows = new FakeResultWrapper( [] );
532 }
533
534 // Used by Structured UI app to get results without MW chrome
535 if ( $this->getRequest()->getVal( 'action' ) === 'render' ) {
536 $this->getOutput()->setArticleBodyOnly( true );
537 }
538
539 // Used by "live update" and "view newest" to check
540 // if there's new changes with minimal data transfer
541 if ( $this->getRequest()->getBool( 'peek' ) ) {
542 $code = $rows->numRows() > 0 ? 200 : 204;
543 $this->getOutput()->setStatusCode( $code );
544 return;
545 }
546
547 $batch = new LinkBatch;
548 foreach ( $rows as $row ) {
549 $batch->add( NS_USER, $row->rc_user_text );
550 $batch->add( NS_USER_TALK, $row->rc_user_text );
551 $batch->add( $row->rc_namespace, $row->rc_title );
552 if ( $row->rc_source === RecentChange::SRC_LOG ) {
553 $formatter = LogFormatter::newFromRow( $row );
554 foreach ( $formatter->getPreloadTitles() as $title ) {
555 $batch->addObj( $title );
556 }
557 }
558 }
559 $batch->execute();
560
561 $this->setHeaders();
562 $this->outputHeader();
563 $this->addModules();
564 $this->webOutput( $rows, $opts );
565
566 $rows->free();
567
568 if ( $this->getConfig()->get( 'EnableWANCacheReaper' ) ) {
569 // Clean up any bad page entries for titles showing up in RC
570 DeferredUpdates::addUpdate( new WANCacheReapUpdate(
571 $this->getDB(),
572 LoggerFactory::getInstance( 'objectcache' )
573 ) );
574 }
575
576 $this->includeRcFiltersApp();
577 }
578
585 protected function includeRcFiltersApp() {
586 $out = $this->getOutput();
587 if ( $this->isStructuredFilterUiEnabled() ) {
588 $jsData = $this->getStructuredFilterJsData();
589
590 $messages = [];
591 foreach ( $jsData['messageKeys'] as $key ) {
592 $messages[$key] = $this->msg( $key )->plain();
593 }
594
595 $out->addBodyClasses( 'mw-rcfilters-enabled' );
596
597 $out->addHTML(
600 )
601 );
602
603 $experimentalStructuredChangeFilters =
604 $this->getConfig()->get( 'StructuredChangeFiltersEnableExperimentalViews' );
605
606 $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
607 $out->addJsConfigVars(
608 'wgStructuredChangeFiltersEnableExperimentalViews',
609 $experimentalStructuredChangeFilters
610 );
611
612 $out->addJsConfigVars(
613 'wgRCFiltersChangeTags',
614 $this->buildChangeTagList()
615 );
616 $out->addJsConfigVars(
617 'StructuredChangeFiltersDisplayConfig',
618 [
619 'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
620 'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
621 'limitDefault' => $this->getDefaultLimit(),
622 'daysArray' => $this->getConfig()->get( 'RCLinkDays' ),
623 'daysDefault' => $this->getDefaultDays(),
624 ]
625 );
626
627 if ( static::$savedQueriesPreferenceName ) {
628 $savedQueries = FormatJson::decode(
629 $this->getUser()->getOption( static::$savedQueriesPreferenceName )
630 );
631 if ( $savedQueries && isset( $savedQueries->default ) ) {
632 // If there is a default saved query, show a loading spinner,
633 // since the frontend is going to reload the results
634 $out->addBodyClasses( 'mw-rcfilters-ui-loading' );
635 }
636 $out->addJsConfigVars(
637 'wgStructuredChangeFiltersSavedQueriesPreferenceName',
638 static::$savedQueriesPreferenceName
639 );
640 }
641 } else {
642 $out->addBodyClasses( 'mw-rcfilters-disabled' );
643 }
644 }
645
651 protected function buildChangeTagList() {
652 $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
653 $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
654
655 // Hit counts disabled for perf reasons, see T169997
656 /*
657 $tagStats = ChangeTags::tagUsageStatistics();
658 $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
659
660 // Sort by hits
661 arsort( $tagHitCounts );
662 */
663 $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags );
664
665 // Build the list and data
666 $result = [];
667 foreach ( $tagHitCounts as $tagName => $hits ) {
668 if (
669 // Only get active tags
670 isset( $explicitlyDefinedTags[ $tagName ] ) ||
671 isset( $softwareActivatedTags[ $tagName ] )
672 ) {
673 // Parse description
674 $desc = ChangeTags::tagLongDescriptionMessage( $tagName, $this->getContext() );
675
676 $result[] = [
677 'name' => $tagName,
678 'label' => Sanitizer::stripAllTags(
679 ChangeTags::tagDescription( $tagName, $this->getContext() )
680 ),
681 'description' => $desc ? Sanitizer::stripAllTags( $desc->parse() ) : '',
682 'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
683 'hits' => $hits,
684 ];
685 }
686 }
687
688 // Instead of sorting by hit count (disabled, see above), sort by display name
689 usort( $result, function ( $a, $b ) {
690 return strcasecmp( $a['label'], $b['label'] );
691 } );
692
693 return $result;
694 }
695
699 protected function outputNoResults() {
700 $this->getOutput()->addHTML(
701 '<div class="mw-changeslist-empty">' .
702 $this->msg( 'recentchanges-noresult' )->parse() .
703 '</div>'
704 );
705 }
706
712 public function getRows() {
713 $opts = $this->getOptions();
714
715 $tables = [];
716 $fields = [];
717 $conds = [];
718 $query_options = [];
719 $join_conds = [];
720 $this->buildQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
721
722 return $this->doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
723 }
724
730 public function getOptions() {
731 if ( $this->rcOptions === null ) {
732 $this->rcOptions = $this->setup( $this->rcSubpage );
733 }
734
735 return $this->rcOptions;
736 }
737
747 protected function registerFilters() {
748 $this->registerFiltersFromDefinitions( $this->filterGroupDefinitions );
749
750 // Make sure this is not being transcluded (we don't want to show this
751 // information to all users just because the user that saves the edit can
752 // patrol or is logged in)
753 if ( !$this->including() && $this->getUser()->useRCPatrol() ) {
754 $this->registerFiltersFromDefinitions( $this->reviewStatusFilterGroupDefinition );
755 }
756
757 $changeTypeGroup = $this->getFilterGroup( 'changeType' );
758
759 if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
760 $transformedHideCategorizationDef = $this->transformFilterDefinition(
761 $this->hideCategorizationFilterDefinition
762 );
763
764 $transformedHideCategorizationDef['group'] = $changeTypeGroup;
765
766 $hideCategorization = new ChangesListBooleanFilter(
767 $transformedHideCategorizationDef
768 );
769 }
770
771 Hooks::run( 'ChangesListSpecialPageStructuredFilters', [ $this ] );
772
773 $unstructuredGroupDefinition =
775 $this->getCustomFilters()
776 );
777 $this->registerFiltersFromDefinitions( [ $unstructuredGroupDefinition ] );
778
779 $userExperienceLevel = $this->getFilterGroup( 'userExpLevel' );
780 $registered = $userExperienceLevel->getFilter( 'registered' );
781 $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'newcomer' ) );
782 $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'learner' ) );
783 $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'experienced' ) );
784
785 $categoryFilter = $changeTypeGroup->getFilter( 'hidecategorization' );
786 $logactionsFilter = $changeTypeGroup->getFilter( 'hidelog' );
787 $pagecreationFilter = $changeTypeGroup->getFilter( 'hidenewpages' );
788
789 $significanceTypeGroup = $this->getFilterGroup( 'significance' );
790 $hideMinorFilter = $significanceTypeGroup->getFilter( 'hideminor' );
791
792 // categoryFilter is conditional; see registerFilters
793 if ( $categoryFilter !== null ) {
794 $hideMinorFilter->conflictsWith(
795 $categoryFilter,
796 'rcfilters-hideminor-conflicts-typeofchange-global',
797 'rcfilters-hideminor-conflicts-typeofchange',
798 'rcfilters-typeofchange-conflicts-hideminor'
799 );
800 }
801 $hideMinorFilter->conflictsWith(
802 $logactionsFilter,
803 'rcfilters-hideminor-conflicts-typeofchange-global',
804 'rcfilters-hideminor-conflicts-typeofchange',
805 'rcfilters-typeofchange-conflicts-hideminor'
806 );
807 $hideMinorFilter->conflictsWith(
808 $pagecreationFilter,
809 'rcfilters-hideminor-conflicts-typeofchange-global',
810 'rcfilters-hideminor-conflicts-typeofchange',
811 'rcfilters-typeofchange-conflicts-hideminor'
812 );
813 }
814
824 protected function transformFilterDefinition( array $filterDefinition ) {
825 return $filterDefinition;
826 }
827
837 protected function registerFiltersFromDefinitions( array $definition ) {
838 $autoFillPriority = -1;
839 foreach ( $definition as $groupDefinition ) {
840 if ( !isset( $groupDefinition['priority'] ) ) {
841 $groupDefinition['priority'] = $autoFillPriority;
842 } else {
843 // If it's explicitly specified, start over the auto-fill
844 $autoFillPriority = $groupDefinition['priority'];
845 }
846
847 $autoFillPriority--;
848
849 $className = $groupDefinition['class'];
850 unset( $groupDefinition['class'] );
851
852 foreach ( $groupDefinition['filters'] as &$filterDefinition ) {
853 $filterDefinition = $this->transformFilterDefinition( $filterDefinition );
854 }
855
856 $this->registerFilterGroup( new $className( $groupDefinition ) );
857 }
858 }
859
867 // Special internal unstructured group
868 $unstructuredGroupDefinition = [
869 'name' => 'unstructured',
870 'class' => ChangesListBooleanFilterGroup::class,
871 'priority' => -1, // Won't display in structured
872 'filters' => [],
873 ];
874
875 foreach ( $customFilters as $name => $params ) {
876 $unstructuredGroupDefinition['filters'][] = [
877 'name' => $name,
878 'showHide' => $params['msg'],
879 'default' => $params['default'],
880 ];
881 }
882
883 return $unstructuredGroupDefinition;
884 }
885
894 public function setup( $parameters ) {
895 $this->registerFilters();
896
897 $opts = $this->getDefaultOptions();
898
899 $opts = $this->fetchOptionsFromRequest( $opts );
900
901 // Give precedence to subpage syntax
902 if ( $parameters !== null ) {
903 $this->parseParameters( $parameters, $opts );
904 }
905
906 $this->validateOptions( $opts );
907
908 return $opts;
909 }
910
920 public function getDefaultOptions() {
921 $opts = new FormOptions();
922 $structuredUI = $this->isStructuredFilterUiEnabled();
923 // If urlversion=2 is set, ignore the filter defaults and set them all to false/empty
924 $useDefaults = $this->getRequest()->getInt( 'urlversion' ) !== 2;
925
926 // Add all filters
928 foreach ( $this->filterGroups as $filterGroup ) {
929 // URL parameters can be per-group, like 'userExpLevel',
930 // or per-filter, like 'hideminor'.
931 if ( $filterGroup->isPerGroupRequestParameter() ) {
932 $opts->add( $filterGroup->getName(), $useDefaults ? $filterGroup->getDefault() : '' );
933 } else {
935 foreach ( $filterGroup->getFilters() as $filter ) {
936 $opts->add( $filter->getName(), $useDefaults ? $filter->getDefault( $structuredUI ) : false );
937 }
938 }
939 }
940
941 $opts->add( 'namespace', '', FormOptions::STRING );
942 $opts->add( 'invert', false );
943 $opts->add( 'associated', false );
944 $opts->add( 'urlversion', 1 );
945 $opts->add( 'tagfilter', '' );
946
947 return $opts;
948 }
949
955 public function registerFilterGroup( ChangesListFilterGroup $group ) {
956 $groupName = $group->getName();
957
958 $this->filterGroups[$groupName] = $group;
959 }
960
966 protected function getFilterGroups() {
967 return $this->filterGroups;
968 }
969
977 public function getFilterGroup( $groupName ) {
978 return isset( $this->filterGroups[$groupName] ) ?
979 $this->filterGroups[$groupName] :
980 null;
981 }
982
983 // Currently, this intentionally only includes filters that display
984 // in the structured UI. This can be changed easily, though, if we want
985 // to include data on filters that use the unstructured UI. messageKeys is a
986 // special top-level value, with the value being an array of the message keys to
987 // send to the client.
995 public function getStructuredFilterJsData() {
996 $output = [
997 'groups' => [],
998 'messageKeys' => [],
999 ];
1000
1001 usort( $this->filterGroups, function ( $a, $b ) {
1002 return $b->getPriority() - $a->getPriority();
1003 } );
1004
1005 foreach ( $this->filterGroups as $groupName => $group ) {
1006 $groupOutput = $group->getJsData( $this );
1007 if ( $groupOutput !== null ) {
1008 $output['messageKeys'] = array_merge(
1009 $output['messageKeys'],
1010 $groupOutput['messageKeys']
1011 );
1012
1013 unset( $groupOutput['messageKeys'] );
1014 $output['groups'][] = $groupOutput;
1015 }
1016 }
1017
1018 return $output;
1019 }
1020
1027 protected function getCustomFilters() {
1028 if ( $this->customFilters === null ) {
1029 $this->customFilters = [];
1030 Hooks::run( 'ChangesListSpecialPageFilters', [ $this, &$this->customFilters ], '1.29' );
1031 }
1032
1033 return $this->customFilters;
1034 }
1035
1044 protected function fetchOptionsFromRequest( $opts ) {
1045 $opts->fetchValuesFromRequest( $this->getRequest() );
1046
1047 return $opts;
1048 }
1049
1056 public function parseParameters( $par, FormOptions $opts ) {
1057 $stringParameterNameSet = [];
1058 $hideParameterNameSet = [];
1059
1060 // URL parameters can be per-group, like 'userExpLevel',
1061 // or per-filter, like 'hideminor'.
1062
1063 foreach ( $this->filterGroups as $filterGroup ) {
1064 if ( $filterGroup->isPerGroupRequestParameter() ) {
1065 $stringParameterNameSet[$filterGroup->getName()] = true;
1066 } elseif ( $filterGroup->getType() === ChangesListBooleanFilterGroup::TYPE ) {
1067 foreach ( $filterGroup->getFilters() as $filter ) {
1068 $hideParameterNameSet[$filter->getName()] = true;
1069 }
1070 }
1071 }
1072
1073 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
1074 foreach ( $bits as $bit ) {
1075 $m = [];
1076 if ( isset( $hideParameterNameSet[$bit] ) ) {
1077 // hidefoo => hidefoo=true
1078 $opts[$bit] = true;
1079 } elseif ( isset( $hideParameterNameSet["hide$bit"] ) ) {
1080 // foo => hidefoo=false
1081 $opts["hide$bit"] = false;
1082 } elseif ( preg_match( '/^(.*)=(.*)$/', $bit, $m ) ) {
1083 if ( isset( $stringParameterNameSet[$m[1]] ) ) {
1084 $opts[$m[1]] = $m[2];
1085 }
1086 }
1087 }
1088 }
1089
1095 public function validateOptions( FormOptions $opts ) {
1096 if ( $this->fixContradictoryOptions( $opts ) ) {
1098 $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) );
1099 }
1100 }
1101
1108 private function fixContradictoryOptions( FormOptions $opts ) {
1109 $fixed = $this->fixBackwardsCompatibilityOptions( $opts );
1110
1111 foreach ( $this->filterGroups as $filterGroup ) {
1112 if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1113 $filters = $filterGroup->getFilters();
1114
1115 if ( count( $filters ) === 1 ) {
1116 // legacy boolean filters should not be considered
1117 continue;
1118 }
1119
1120 $allInGroupEnabled = array_reduce(
1121 $filters,
1122 function ( $carry, $filter ) use ( $opts ) {
1123 return $carry && $opts[ $filter->getName() ];
1124 },
1125 /* initialValue */ count( $filters ) > 0
1126 );
1127
1128 if ( $allInGroupEnabled ) {
1129 foreach ( $filters as $filter ) {
1130 $opts[ $filter->getName() ] = false;
1131 }
1132
1133 $fixed = true;
1134 }
1135 }
1136 }
1137
1138 return $fixed;
1139 }
1140
1151 if ( $opts['hideanons'] && $opts['hideliu'] ) {
1152 $opts->reset( 'hideanons' );
1153 if ( !$opts['hidebots'] ) {
1154 $opts->reset( 'hideliu' );
1155 $opts['hidehumans'] = 1;
1156 }
1157
1158 return true;
1159 }
1160
1161 return false;
1162 }
1163
1172 protected function convertParamsForLink( $params ) {
1173 foreach ( $params as &$value ) {
1174 if ( $value === false ) {
1175 $value = '0';
1176 }
1177 }
1178 unset( $value );
1179 return $params;
1180 }
1181
1193 protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
1194 &$join_conds, FormOptions $opts
1195 ) {
1196 $dbr = $this->getDB();
1197 $isStructuredUI = $this->isStructuredFilterUiEnabled();
1198
1199 foreach ( $this->filterGroups as $filterGroup ) {
1200 // URL parameters can be per-group, like 'userExpLevel',
1201 // or per-filter, like 'hideminor'.
1202 if ( $filterGroup->isPerGroupRequestParameter() ) {
1203 $filterGroup->modifyQuery( $dbr, $this, $tables, $fields, $conds,
1204 $query_options, $join_conds, $opts[$filterGroup->getName()] );
1205 } else {
1206 foreach ( $filterGroup->getFilters() as $filter ) {
1207 if ( $filter->isActive( $opts, $isStructuredUI ) ) {
1208 $filter->modifyQuery( $dbr, $this, $tables, $fields, $conds,
1209 $query_options, $join_conds );
1210 }
1211 }
1212 }
1213 }
1214
1215 // Namespace filtering
1216 if ( $opts[ 'namespace' ] !== '' ) {
1217 $namespaces = explode( ';', $opts[ 'namespace' ] );
1218
1219 if ( $opts[ 'associated' ] ) {
1220 $associatedNamespaces = array_map(
1221 function ( $ns ) {
1222 return MWNamespace::getAssociated( $ns );
1223 },
1225 );
1226 $namespaces = array_unique( array_merge( $namespaces, $associatedNamespaces ) );
1227 }
1228
1229 if ( count( $namespaces ) === 1 ) {
1230 $operator = $opts[ 'invert' ] ? '!=' : '=';
1231 $value = $dbr->addQuotes( reset( $namespaces ) );
1232 } else {
1233 $operator = $opts[ 'invert' ] ? 'NOT IN' : 'IN';
1234 sort( $namespaces );
1235 $value = '(' . $dbr->makeList( $namespaces ) . ')';
1236 }
1237 $conds[] = "rc_namespace $operator $value";
1238 }
1239 }
1240
1252 protected function doMainQuery( $tables, $fields, $conds,
1253 $query_options, $join_conds, FormOptions $opts
1254 ) {
1255 $tables[] = 'recentchanges';
1256 $fields = array_merge( RecentChange::selectFields(), $fields );
1257
1259 $tables,
1260 $fields,
1261 $conds,
1262 $join_conds,
1263 $query_options,
1264 ''
1265 );
1266
1267 if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
1268 $opts )
1269 ) {
1270 return false;
1271 }
1272
1273 $dbr = $this->getDB();
1274
1275 return $dbr->select(
1276 $tables,
1277 $fields,
1278 $conds,
1279 __METHOD__,
1280 $query_options,
1281 $join_conds
1282 );
1283 }
1284
1285 protected function runMainQueryHook( &$tables, &$fields, &$conds,
1286 &$query_options, &$join_conds, $opts
1287 ) {
1288 return Hooks::run(
1289 'ChangesListSpecialPageQuery',
1290 [ $this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ]
1291 );
1292 }
1293
1299 protected function getDB() {
1300 return wfGetDB( DB_REPLICA );
1301 }
1302
1309 public function webOutput( $rows, $opts ) {
1310 if ( !$this->including() ) {
1311 $this->outputFeedLinks();
1312 $this->doHeader( $opts, $rows->numRows() );
1313 }
1314
1315 $this->outputChangesList( $rows, $opts );
1316 }
1317
1321 public function outputFeedLinks() {
1322 // nothing by default
1323 }
1324
1331 abstract public function outputChangesList( $rows, $opts );
1332
1339 public function doHeader( $opts, $numRows ) {
1340 $this->setTopText( $opts );
1341
1342 // @todo Lots of stuff should be done here.
1343
1344 $this->setBottomText( $opts );
1345 }
1346
1353 public function setTopText( FormOptions $opts ) {
1354 // nothing by default
1355 }
1356
1363 public function setBottomText( FormOptions $opts ) {
1364 // nothing by default
1365 }
1366
1376 public function getExtraOptions( $opts ) {
1377 return [];
1378 }
1379
1385 public function makeLegend() {
1386 $context = $this->getContext();
1387 $user = $context->getUser();
1388 # The legend showing what the letters and stuff mean
1389 $legend = Html::openElement( 'dl' ) . "\n";
1390 # Iterates through them and gets the messages for both letter and tooltip
1391 $legendItems = $context->getConfig()->get( 'RecentChangesFlags' );
1392 if ( !( $user->useRCPatrol() || $user->useNPPatrol() ) ) {
1393 unset( $legendItems['unpatrolled'] );
1394 }
1395 foreach ( $legendItems as $key => $item ) { # generate items of the legend
1396 $label = isset( $item['legend'] ) ? $item['legend'] : $item['title'];
1397 $letter = $item['letter'];
1398 $cssClass = isset( $item['class'] ) ? $item['class'] : $key;
1399
1400 $legend .= Html::element( 'dt',
1401 [ 'class' => $cssClass ], $context->msg( $letter )->text()
1402 ) . "\n" .
1403 Html::rawElement( 'dd',
1404 [ 'class' => Sanitizer::escapeClass( 'mw-changeslist-legend-' . $key ) ],
1405 $context->msg( $label )->parse()
1406 ) . "\n";
1407 }
1408 # (+-123)
1409 $legend .= Html::rawElement( 'dt',
1410 [ 'class' => 'mw-plusminus-pos' ],
1411 $context->msg( 'recentchanges-legend-plusminus' )->parse()
1412 ) . "\n";
1413 $legend .= Html::element(
1414 'dd',
1415 [ 'class' => 'mw-changeslist-legend-plusminus' ],
1416 $context->msg( 'recentchanges-label-plusminus' )->text()
1417 ) . "\n";
1418 $legend .= Html::closeElement( 'dl' ) . "\n";
1419
1420 $legendHeading = $this->isStructuredFilterUiEnabled() ?
1421 $context->msg( 'rcfilters-legend-heading' )->parse() :
1422 $context->msg( 'recentchanges-legend-heading' )->parse();
1423
1424 # Collapsible
1425 $legend =
1426 '<div class="mw-changeslist-legend">' .
1427 $legendHeading .
1428 '<div class="mw-collapsible-content">' . $legend . '</div>' .
1429 '</div>';
1430
1431 return $legend;
1432 }
1433
1437 protected function addModules() {
1438 $out = $this->getOutput();
1439 // Styles and behavior for the legend box (see makeLegend())
1440 $out->addModuleStyles( [
1441 'mediawiki.special.changeslist.legend',
1442 'mediawiki.special.changeslist',
1443 ] );
1444 $out->addModules( 'mediawiki.special.changeslist.legend.js' );
1445
1446 if ( $this->isStructuredFilterUiEnabled() ) {
1447 $out->addModules( 'mediawiki.rcfilters.filters.ui' );
1448 $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
1449 }
1450 }
1451
1452 protected function getGroupName() {
1453 return 'changes';
1454 }
1455
1472 public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
1473 &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
1474 ) {
1479
1480 $LEVEL_COUNT = 5;
1481
1482 // If all levels are selected, don't filter
1483 if ( count( $selectedExpLevels ) === $LEVEL_COUNT ) {
1484 return;
1485 }
1486
1487 // both 'registered' and 'unregistered', experience levels, if any, are included in 'registered'
1488 if (
1489 in_array( 'registered', $selectedExpLevels ) &&
1490 in_array( 'unregistered', $selectedExpLevels )
1491 ) {
1492 return;
1493 }
1494
1495 // 'registered' but not 'unregistered', experience levels, if any, are included in 'registered'
1496 if (
1497 in_array( 'registered', $selectedExpLevels ) &&
1498 !in_array( 'unregistered', $selectedExpLevels )
1499 ) {
1500 $conds[] = 'rc_user != 0';
1501 return;
1502 }
1503
1504 if ( $selectedExpLevels === [ 'unregistered' ] ) {
1505 $conds[] = 'rc_user = 0';
1506 return;
1507 }
1508
1509 $tables[] = 'user';
1510 $join_conds['user'] = [ 'LEFT JOIN', 'rc_user = user_id' ];
1511
1512 if ( $now === 0 ) {
1513 $now = time();
1514 }
1515 $secondsPerDay = 86400;
1516 $learnerCutoff = $now - $wgLearnerMemberSince * $secondsPerDay;
1517 $experiencedUserCutoff = $now - $wgExperiencedUserMemberSince * $secondsPerDay;
1518
1519 $aboveNewcomer = $dbr->makeList(
1520 [
1521 'user_editcount >= ' . intval( $wgLearnerEdits ),
1522 'user_registration <= ' . $dbr->addQuotes( $dbr->timestamp( $learnerCutoff ) ),
1523 ],
1524 IDatabase::LIST_AND
1525 );
1526
1527 $aboveLearner = $dbr->makeList(
1528 [
1529 'user_editcount >= ' . intval( $wgExperiencedUserEdits ),
1530 'user_registration <= ' .
1531 $dbr->addQuotes( $dbr->timestamp( $experiencedUserCutoff ) ),
1532 ],
1533 IDatabase::LIST_AND
1534 );
1535
1536 $conditions = [];
1537
1538 if ( in_array( 'unregistered', $selectedExpLevels ) ) {
1539 $selectedExpLevels = array_diff( $selectedExpLevels, [ 'unregistered' ] );
1540 $conditions[] = 'rc_user = 0';
1541 }
1542
1543 if ( $selectedExpLevels === [ 'newcomer' ] ) {
1544 $conditions[] = "NOT ( $aboveNewcomer )";
1545 } elseif ( $selectedExpLevels === [ 'learner' ] ) {
1546 $conditions[] = $dbr->makeList(
1547 [ $aboveNewcomer, "NOT ( $aboveLearner )" ],
1548 IDatabase::LIST_AND
1549 );
1550 } elseif ( $selectedExpLevels === [ 'experienced' ] ) {
1551 $conditions[] = $aboveLearner;
1552 } elseif ( $selectedExpLevels === [ 'learner', 'newcomer' ] ) {
1553 $conditions[] = "NOT ( $aboveLearner )";
1554 } elseif ( $selectedExpLevels === [ 'experienced', 'newcomer' ] ) {
1555 $conditions[] = $dbr->makeList(
1556 [ "NOT ( $aboveNewcomer )", $aboveLearner ],
1557 IDatabase::LIST_OR
1558 );
1559 } elseif ( $selectedExpLevels === [ 'experienced', 'learner' ] ) {
1560 $conditions[] = $aboveNewcomer;
1561 } elseif ( $selectedExpLevels === [ 'experienced', 'learner', 'newcomer' ] ) {
1562 $conditions[] = 'rc_user != 0';
1563 }
1564
1565 if ( count( $conditions ) > 1 ) {
1566 $conds[] = $dbr->makeList( $conditions, IDatabase::LIST_OR );
1567 } elseif ( count( $conditions ) === 1 ) {
1568 $conds[] = reset( $conditions );
1569 }
1570 }
1571
1578 if ( $this->getRequest()->getBool( 'rcfilters' ) ) {
1579 return true;
1580 }
1581
1582 if ( $this->getConfig()->get( 'StructuredChangeFiltersShowPreference' ) ) {
1583 return !$this->getUser()->getOption( 'rcenhancedfilters-disable' );
1584 } else {
1585 return $this->getUser()->getOption( 'rcenhancedfilters' );
1586 }
1587 }
1588
1596 if ( $this->getConfig()->get( 'StructuredChangeFiltersShowPreference' ) ) {
1597 return !$this->getUser()->getDefaultOption( 'rcenhancedfilters-disable' );
1598 } else {
1599 return $this->getUser()->getDefaultOption( 'rcenhancedfilters' );
1600 }
1601 }
1602
1603 abstract function getDefaultLimit();
1604
1612 abstract function getDefaultDays();
1613}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgLearnerMemberSince
Name of the external diff engine to use.
$wgExperiencedUserMemberSince
Name of the external diff engine to use.
$wgLearnerEdits
The following variables define 3 user experience levels:
$wgExperiencedUserEdits
Name of the external diff engine to use.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
$messages
static tagLongDescriptionMessage( $tag, IContextSource $context)
Get the message object for the tag's long description.
static tagDescription( $tag, IContextSource $context)
Get a short description for a tag.
static listSoftwareActivatedTags()
Lists those tags which core or extensions report as being "active".
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the valid_tag table of the database.
If the group is active, any unchecked filters will translate to hide parameters in the URL.
const TYPE
Type marker, used by JavaScript.
An individual filter in a boolean group.
Represents a filter group (used on ChangesListSpecialPage and descendants)
Special page which uses a ChangesList to show query results.
validateOptions(FormOptions $opts)
Validate a FormOptions object generated by getDefaultOptions() with values already populated.
getDefaultOptions()
Get a FormOptions object containing the default options.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
setTopText(FormOptions $opts)
Send the text to be displayed before the options.
filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now=0)
Filter on users' experience levels; this will not be called if nothing is selected.
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
buildChangeTagList()
Fetch the change tags list for the front end.
registerFiltersFromDefinitions(array $definition)
Register filters from a definition object.
convertParamsForLink( $params)
Convert parameters values from true/false to 1/0 so they are not omitted by wfArrayToCgi() Bug 36524.
parseParameters( $par, FormOptions $opts)
Process $par and put options found in $opts.
getFilterGroup( $groupName)
Gets a specified ChangesListFilterGroup by name.
isStructuredFilterUiEnabled()
Check whether the structured filter UI is enabled.
getExtraOptions( $opts)
Get options to be displayed in a form.
setup( $parameters)
Register all the filters, including legacy hook-driven ones.
isStructuredFilterUiEnabledByDefault()
Check whether the structured filter UI is enabled by default (regardless of this particular user's se...
static string $savedQueriesPreferenceName
Preference name for saved queries.
getFilterGroupDefinitionFromLegacyCustomFilters(array $customFilters)
Get filter group definition from legacy custom filters.
registerFilters()
Register all filters and their groups (including those from hooks), plus handle conflicts and default...
areFiltersInConflict()
Check if filters are in conflict and guaranteed to return no results.
getDefaultDays()
Get the default value of the number of days to display when loading the result set.
fixBackwardsCompatibilityOptions(FormOptions $opts)
Fix a special case (hideanons=1 and hideliu=1) in a special way, for backwards compatibility.
getCustomFilters()
Get custom show/hide filters using deprecated ChangesListSpecialPageFilters hook.
outputNoResults()
Add the "no results" message to the output.
getFilterGroups()
Gets the currently registered filters groups.
registerFilterGroup(ChangesListFilterGroup $group)
Register a structured changes list filter group.
addModules()
Add page-specific modules.
fixContradictoryOptions(FormOptions $opts)
Fix invalid options by resetting pairs that should never appear together.
__construct( $name, $restriction)
outputFeedLinks()
Output feed links.
doHeader( $opts, $numRows)
Set the text to be displayed above the changes.
fetchOptionsFromRequest( $opts)
Fetch values for a FormOptions object from the WebRequest associated with this instance.
getOptions()
Get the current FormOptions for this request.
doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, FormOptions $opts)
Process the query.
execute( $subpage)
Main execution point.
setBottomText(FormOptions $opts)
Send the text to be displayed after the options.
getStructuredFilterJsData()
Gets structured filter information needed by JS.
buildQuery(&$tables, &$fields, &$conds, &$query_options, &$join_conds, FormOptions $opts)
Sets appropriate tables, fields, conditions, etc.
makeLegend()
Return the legend displayed within the fieldset.
webOutput( $rows, $opts)
Send output to the OutputPage object, only called if not used feeds.
transformFilterDefinition(array $filterDefinition)
Transforms filter definition to prepare it for constructor.
getDB()
Return a IDatabase object for reading.
$filterGroups
Filter groups, and their contained filters This is an associative array (with group name as key) of C...
outputChangesList( $rows, $opts)
Build and output the actual changes list.
getRows()
Get the database result for this special page instance.
$filterGroupDefinitions
Definition information for the filters and their groups.
includeRcFiltersApp()
Include the modules and configuration for the RCFilters app.
const NONE
Signifies that no options in the group are selected, meaning the group has no effect.
Helper class to keep track of options when mixing links and form elements.
reset( $name)
Delete the option value.
const STRING
String type, maps guessType() to WebRequest::getText()
getChangedValues()
Return options modified as an array ( name => value )
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition LinkBatch.php:34
add( $ns, $dbkey)
Definition LinkBatch.php:80
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
PSR-3 logger instance factory.
static selectFields()
Return the list of recentchanges fields that should be selected to create a new recentchanges object.
const SRC_CATEGORIZE
static makeInlineScript( $script)
Construct an inline script tag with given JS code.
static makeMessageSetScript( $messages)
Returns JS code which, when called, will register a given list of messages.
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getName()
Get the name of this Special Page.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
including( $x=null)
Whether the special page is being evaluated via transclusion.
Class for fixing stale WANObjectCache keys using a purge event source.
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Result wrapper for grabbing data queried from an IDatabase object.
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
Definition globals.txt:10
const NS_USER
Definition Defines.php:67
const RC_NEW
Definition Defines.php:144
const RC_LOG
Definition Defines.php:145
const NS_USER_TALK
Definition Defines.php:68
const RC_EDIT
Definition Defines.php:143
const RC_CATEGORIZE
Definition Defines.php:147
the array() calling protocol came about after MediaWiki 1.4rc1.
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 $rows
Definition hooks.txt:2746
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
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
Definition hooks.txt:2225
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:1013
namespace and then decline to actually register it & $namespaces
Definition hooks.txt:932
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition hooks.txt:863
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:2780
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:962
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:862
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition hooks.txt:1610
processing should stop and the error should be shown to the user * false
Definition hooks.txt:187
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 local account $user
Definition hooks.txt:247
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:37
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:40
$batch
Definition linkcache.txt:23
const DB_REPLICA
Definition defines.php:25
$params