MediaWiki REL1_28
ChangeTags.php
Go to the documentation of this file.
1<?php
30 const MAX_DELETE_USES = 5000;
31
35 private static $coreTags = [ 'mw-contentmodelchange' ];
36
50 public static function formatSummaryRow( $tags, $page, IContextSource $context = null ) {
51 if ( !$tags ) {
52 return [ '', [] ];
53 }
54 if ( !$context ) {
56 }
57
58 $classes = [];
59
60 $tags = explode( ',', $tags );
61 $displayTags = [];
62 foreach ( $tags as $tag ) {
63 if ( !$tag ) {
64 continue;
65 }
66 $description = self::tagDescription( $tag );
67 if ( $description === false ) {
68 continue;
69 }
70 $displayTags[] = Xml::tags(
71 'span',
72 [ 'class' => 'mw-tag-marker ' .
73 Sanitizer::escapeClass( "mw-tag-marker-$tag" ) ],
74 $description
75 );
76 $classes[] = Sanitizer::escapeClass( "mw-tag-$tag" );
77 }
78
79 if ( !$displayTags ) {
80 return [ '', [] ];
81 }
82
83 $markers = $context->msg( 'tag-list-wrapper' )
84 ->numParams( count( $displayTags ) )
85 ->rawParams( $context->getLanguage()->commaList( $displayTags ) )
86 ->parse();
87 $markers = Xml::tags( 'span', [ 'class' => 'mw-tag-markers' ], $markers );
88
89 return [ $markers, $classes ];
90 }
91
104 public static function tagDescription( $tag ) {
105 $msg = wfMessage( "tag-$tag" );
106 if ( !$msg->exists() ) {
107 // No such message, so return the HTML-escaped tag name.
108 return htmlspecialchars( $tag );
109 }
110 if ( $msg->isDisabled() ) {
111 // The message exists but is disabled, hide the tag.
112 return false;
113 }
114
115 // Message exists and isn't disabled, use it.
116 return $msg->parse();
117 }
118
133 public static function addTags( $tags, $rc_id = null, $rev_id = null,
134 $log_id = null, $params = null, RecentChange $rc = null
135 ) {
136 $result = self::updateTags( $tags, null, $rc_id, $rev_id, $log_id, $params, $rc );
137 return (bool)$result[0];
138 }
139
170 public static function updateTags( $tagsToAdd, $tagsToRemove, &$rc_id = null,
171 &$rev_id = null, &$log_id = null, $params = null, RecentChange $rc = null,
172 User $user = null
173 ) {
174
175 $tagsToAdd = array_filter( (array)$tagsToAdd ); // Make sure we're submitting all tags...
176 $tagsToRemove = array_filter( (array)$tagsToRemove );
177
178 if ( !$rc_id && !$rev_id && !$log_id ) {
179 throw new MWException( 'At least one of: RCID, revision ID, and log ID MUST be ' .
180 'specified when adding or removing a tag from a change!' );
181 }
182
183 $dbw = wfGetDB( DB_MASTER );
184
185 // Might as well look for rcids and so on.
186 if ( !$rc_id ) {
187 // Info might be out of date, somewhat fractionally, on replica DB.
188 // LogEntry/LogPage and WikiPage match rev/log/rc timestamps,
189 // so use that relation to avoid full table scans.
190 if ( $log_id ) {
191 $rc_id = $dbw->selectField(
192 [ 'logging', 'recentchanges' ],
193 'rc_id',
194 [
195 'log_id' => $log_id,
196 'rc_timestamp = log_timestamp',
197 'rc_logid = log_id'
198 ],
199 __METHOD__
200 );
201 } elseif ( $rev_id ) {
202 $rc_id = $dbw->selectField(
203 [ 'revision', 'recentchanges' ],
204 'rc_id',
205 [
206 'rev_id' => $rev_id,
207 'rc_timestamp = rev_timestamp',
208 'rc_this_oldid = rev_id'
209 ],
210 __METHOD__
211 );
212 }
213 } elseif ( !$log_id && !$rev_id ) {
214 // Info might be out of date, somewhat fractionally, on replica DB.
215 $log_id = $dbw->selectField(
216 'recentchanges',
217 'rc_logid',
218 [ 'rc_id' => $rc_id ],
219 __METHOD__
220 );
221 $rev_id = $dbw->selectField(
222 'recentchanges',
223 'rc_this_oldid',
224 [ 'rc_id' => $rc_id ],
225 __METHOD__
226 );
227 }
228
229 if ( $log_id && !$rev_id ) {
230 $rev_id = $dbw->selectField(
231 'log_search',
232 'ls_value',
233 [ 'ls_field' => 'associated_rev_id', 'ls_log_id' => $log_id ],
234 __METHOD__
235 );
236 } elseif ( !$log_id && $rev_id ) {
237 $log_id = $dbw->selectField(
238 'log_search',
239 'ls_log_id',
240 [ 'ls_field' => 'associated_rev_id', 'ls_value' => $rev_id ],
241 __METHOD__
242 );
243 }
244
245 // update the tag_summary row
246 $prevTags = [];
247 if ( !self::updateTagSummaryRow( $tagsToAdd, $tagsToRemove, $rc_id, $rev_id,
248 $log_id, $prevTags ) ) {
249
250 // nothing to do
251 return [ [], [], $prevTags ];
252 }
253
254 // insert a row into change_tag for each new tag
255 if ( count( $tagsToAdd ) ) {
256 $tagsRows = [];
257 foreach ( $tagsToAdd as $tag ) {
258 // Filter so we don't insert NULLs as zero accidentally.
259 // Keep in mind that $rc_id === null means "I don't care/know about the
260 // rc_id, just delete $tag on this revision/log entry". It doesn't
261 // mean "only delete tags on this revision/log WHERE rc_id IS NULL".
262 $tagsRows[] = array_filter(
263 [
264 'ct_tag' => $tag,
265 'ct_rc_id' => $rc_id,
266 'ct_log_id' => $log_id,
267 'ct_rev_id' => $rev_id,
268 'ct_params' => $params
269 ]
270 );
271 }
272
273 $dbw->insert( 'change_tag', $tagsRows, __METHOD__, [ 'IGNORE' ] );
274 }
275
276 // delete from change_tag
277 if ( count( $tagsToRemove ) ) {
278 foreach ( $tagsToRemove as $tag ) {
279 $conds = array_filter(
280 [
281 'ct_tag' => $tag,
282 'ct_rc_id' => $rc_id,
283 'ct_log_id' => $log_id,
284 'ct_rev_id' => $rev_id
285 ]
286 );
287 $dbw->delete( 'change_tag', $conds, __METHOD__ );
288 }
289 }
290
292
293 Hooks::run( 'ChangeTagsAfterUpdateTags', [ $tagsToAdd, $tagsToRemove, $prevTags,
294 $rc_id, $rev_id, $log_id, $params, $rc, $user ] );
295
296 return [ $tagsToAdd, $tagsToRemove, $prevTags ];
297 }
298
315 protected static function updateTagSummaryRow( &$tagsToAdd, &$tagsToRemove,
316 $rc_id, $rev_id, $log_id, &$prevTags = [] ) {
317
318 $dbw = wfGetDB( DB_MASTER );
319
320 $tsConds = array_filter( [
321 'ts_rc_id' => $rc_id,
322 'ts_rev_id' => $rev_id,
323 'ts_log_id' => $log_id
324 ] );
325
326 // Can't both add and remove a tag at the same time...
327 $tagsToAdd = array_diff( $tagsToAdd, $tagsToRemove );
328
329 // Update the summary row.
330 // $prevTags can be out of date on replica DBs, especially when addTags is called consecutively,
331 // causing loss of tags added recently in tag_summary table.
332 $prevTags = $dbw->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ );
333 $prevTags = $prevTags ? $prevTags : '';
334 $prevTags = array_filter( explode( ',', $prevTags ) );
335
336 // add tags
337 $tagsToAdd = array_values( array_diff( $tagsToAdd, $prevTags ) );
338 $newTags = array_unique( array_merge( $prevTags, $tagsToAdd ) );
339
340 // remove tags
341 $tagsToRemove = array_values( array_intersect( $tagsToRemove, $newTags ) );
342 $newTags = array_values( array_diff( $newTags, $tagsToRemove ) );
343
344 sort( $prevTags );
345 sort( $newTags );
346 if ( $prevTags == $newTags ) {
347 // No change.
348 return false;
349 }
350
351 if ( !$newTags ) {
352 // no tags left, so delete the row altogether
353 $dbw->delete( 'tag_summary', $tsConds, __METHOD__ );
354 } else {
355 $dbw->replace( 'tag_summary',
356 [ 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ],
357 array_filter( array_merge( $tsConds, [ 'ts_tags' => implode( ',', $newTags ) ] ) ),
358 __METHOD__
359 );
360 }
361
362 return true;
363 }
364
375 protected static function restrictedTagError( $msgOne, $msgMulti, $tags ) {
376 $lang = RequestContext::getMain()->getLanguage();
377 $count = count( $tags );
378 return Status::newFatal( ( $count > 1 ) ? $msgMulti : $msgOne,
379 $lang->commaList( $tags ), $count );
380 }
381
392 public static function canAddTagsAccompanyingChange( array $tags,
393 User $user = null ) {
394
395 if ( !is_null( $user ) ) {
396 if ( !$user->isAllowed( 'applychangetags' ) ) {
397 return Status::newFatal( 'tags-apply-no-permission' );
398 } elseif ( $user->isBlocked() ) {
399 return Status::newFatal( 'tags-apply-blocked' );
400 }
401 }
402
403 // to be applied, a tag has to be explicitly defined
404 // @todo Allow extensions to define tags that can be applied by users...
405 $allowedTags = self::listExplicitlyDefinedTags();
406 $disallowedTags = array_diff( $tags, $allowedTags );
407 if ( $disallowedTags ) {
408 return self::restrictedTagError( 'tags-apply-not-allowed-one',
409 'tags-apply-not-allowed-multi', $disallowedTags );
410 }
411
412 return Status::newGood();
413 }
414
436 array $tags, $rc_id, $rev_id, $log_id, $params, User $user
437 ) {
438
439 // are we allowed to do this?
441 if ( !$result->isOK() ) {
442 $result->value = null;
443 return $result;
444 }
445
446 // do it!
447 self::addTags( $tags, $rc_id, $rev_id, $log_id, $params );
448
449 return Status::newGood( true );
450 }
451
463 public static function canUpdateTags( array $tagsToAdd, array $tagsToRemove,
464 User $user = null ) {
465
466 if ( !is_null( $user ) ) {
467 if ( !$user->isAllowed( 'changetags' ) ) {
468 return Status::newFatal( 'tags-update-no-permission' );
469 } elseif ( $user->isBlocked() ) {
470 return Status::newFatal( 'tags-update-blocked' );
471 }
472 }
473
474 if ( $tagsToAdd ) {
475 // to be added, a tag has to be explicitly defined
476 // @todo Allow extensions to define tags that can be applied by users...
477 $explicitlyDefinedTags = self::listExplicitlyDefinedTags();
478 $diff = array_diff( $tagsToAdd, $explicitlyDefinedTags );
479 if ( $diff ) {
480 return self::restrictedTagError( 'tags-update-add-not-allowed-one',
481 'tags-update-add-not-allowed-multi', $diff );
482 }
483 }
484
485 if ( $tagsToRemove ) {
486 // to be removed, a tag must not be defined by an extension, or equivalently it
487 // has to be either explicitly defined or not defined at all
488 // (assuming no edge case of a tag both explicitly-defined and extension-defined)
489 $softwareDefinedTags = self::listSoftwareDefinedTags();
490 $intersect = array_intersect( $tagsToRemove, $softwareDefinedTags );
491 if ( $intersect ) {
492 return self::restrictedTagError( 'tags-update-remove-not-allowed-one',
493 'tags-update-remove-not-allowed-multi', $intersect );
494 }
495 }
496
497 return Status::newGood();
498 }
499
526 public static function updateTagsWithChecks( $tagsToAdd, $tagsToRemove,
527 $rc_id, $rev_id, $log_id, $params, $reason, User $user ) {
528
529 if ( is_null( $tagsToAdd ) ) {
530 $tagsToAdd = [];
531 }
532 if ( is_null( $tagsToRemove ) ) {
533 $tagsToRemove = [];
534 }
535 if ( !$tagsToAdd && !$tagsToRemove ) {
536 // no-op, don't bother
537 return Status::newGood( (object)[
538 'logId' => null,
539 'addedTags' => [],
540 'removedTags' => [],
541 ] );
542 }
543
544 // are we allowed to do this?
545 $result = self::canUpdateTags( $tagsToAdd, $tagsToRemove, $user );
546 if ( !$result->isOK() ) {
547 $result->value = null;
548 return $result;
549 }
550
551 // basic rate limiting
552 if ( $user->pingLimiter( 'changetag' ) ) {
553 return Status::newFatal( 'actionthrottledtext' );
554 }
555
556 // do it!
557 list( $tagsAdded, $tagsRemoved, $initialTags ) = self::updateTags( $tagsToAdd,
558 $tagsToRemove, $rc_id, $rev_id, $log_id, $params, null, $user );
559 if ( !$tagsAdded && !$tagsRemoved ) {
560 // no-op, don't log it
561 return Status::newGood( (object)[
562 'logId' => null,
563 'addedTags' => [],
564 'removedTags' => [],
565 ] );
566 }
567
568 // log it
569 $logEntry = new ManualLogEntry( 'tag', 'update' );
570 $logEntry->setPerformer( $user );
571 $logEntry->setComment( $reason );
572
573 // find the appropriate target page
574 if ( $rev_id ) {
575 $rev = Revision::newFromId( $rev_id );
576 if ( $rev ) {
577 $logEntry->setTarget( $rev->getTitle() );
578 }
579 } elseif ( $log_id ) {
580 // This function is from revision deletion logic and has nothing to do with
581 // change tags, but it appears to be the only other place in core where we
582 // perform logged actions on log items.
583 $logEntry->setTarget( RevDelLogList::suggestTarget( null, [ $log_id ] ) );
584 }
585
586 if ( !$logEntry->getTarget() ) {
587 // target is required, so we have to set something
588 $logEntry->setTarget( SpecialPage::getTitleFor( 'Tags' ) );
589 }
590
591 $logParams = [
592 '4::revid' => $rev_id,
593 '5::logid' => $log_id,
594 '6:list:tagsAdded' => $tagsAdded,
595 '7:number:tagsAddedCount' => count( $tagsAdded ),
596 '8:list:tagsRemoved' => $tagsRemoved,
597 '9:number:tagsRemovedCount' => count( $tagsRemoved ),
598 'initialTags' => $initialTags,
599 ];
600 $logEntry->setParameters( $logParams );
601 $logEntry->setRelations( [ 'Tag' => array_merge( $tagsAdded, $tagsRemoved ) ] );
602
603 $dbw = wfGetDB( DB_MASTER );
604 $logId = $logEntry->insert( $dbw );
605 // Only send this to UDP, not RC, similar to patrol events
606 $logEntry->publish( $logId, 'udp' );
607
608 return Status::newGood( (object)[
609 'logId' => $logId,
610 'addedTags' => $tagsAdded,
611 'removedTags' => $tagsRemoved,
612 ] );
613 }
614
629 public static function modifyDisplayQuery( &$tables, &$fields, &$conds,
630 &$join_conds, &$options, $filter_tag = false ) {
632
633 if ( $filter_tag === false ) {
634 $filter_tag = $wgRequest->getVal( 'tagfilter' );
635 }
636
637 // Figure out which conditions can be done.
638 if ( in_array( 'recentchanges', $tables ) ) {
639 $join_cond = 'ct_rc_id=rc_id';
640 } elseif ( in_array( 'logging', $tables ) ) {
641 $join_cond = 'ct_log_id=log_id';
642 } elseif ( in_array( 'revision', $tables ) ) {
643 $join_cond = 'ct_rev_id=rev_id';
644 } elseif ( in_array( 'archive', $tables ) ) {
645 $join_cond = 'ct_rev_id=ar_rev_id';
646 } else {
647 throw new MWException( 'Unable to determine appropriate JOIN condition for tagging.' );
648 }
649
650 $fields['ts_tags'] = wfGetDB( DB_REPLICA )->buildGroupConcatField(
651 ',', 'change_tag', 'ct_tag', $join_cond
652 );
653
654 if ( $wgUseTagFilter && $filter_tag ) {
655 // Somebody wants to filter on a tag.
656 // Add an INNER JOIN on change_tag
657
658 $tables[] = 'change_tag';
659 $join_conds['change_tag'] = [ 'INNER JOIN', $join_cond ];
660 $conds['ct_tag'] = $filter_tag;
661 }
662 }
663
672 public static function buildTagFilterSelector( $selected = '', $ooui = false ) {
674
675 if ( !$wgUseTagFilter || !count( self::listDefinedTags() ) ) {
676 return [];
677 }
678
679 $data = [
680 Html::rawElement(
681 'label',
682 [ 'for' => 'tagfilter' ],
683 wfMessage( 'tag-filter' )->parse()
684 )
685 ];
686
687 if ( $ooui ) {
688 $data[] = new OOUI\TextInputWidget( [
689 'id' => 'tagfilter',
690 'name' => 'tagfilter',
691 'value' => $selected,
692 'classes' => 'mw-tagfilter-input',
693 ] );
694 } else {
695 $data[] = Xml::input(
696 'tagfilter',
697 20,
698 $selected,
699 [ 'class' => 'mw-tagfilter-input mw-ui-input mw-ui-input-inline', 'id' => 'tagfilter' ]
700 );
701 }
702
703 return $data;
704 }
705
715 public static function defineTag( $tag ) {
716 $dbw = wfGetDB( DB_MASTER );
717 $dbw->replace( 'valid_tag',
718 [ 'vt_tag' ],
719 [ 'vt_tag' => $tag ],
720 __METHOD__ );
721
722 // clear the memcache of defined tags
724 }
725
734 public static function undefineTag( $tag ) {
735 $dbw = wfGetDB( DB_MASTER );
736 $dbw->delete( 'valid_tag', [ 'vt_tag' => $tag ], __METHOD__ );
737
738 // clear the memcache of defined tags
740 }
741
754 protected static function logTagManagementAction( $action, $tag, $reason,
755 User $user, $tagCount = null ) {
756
757 $dbw = wfGetDB( DB_MASTER );
758
759 $logEntry = new ManualLogEntry( 'managetags', $action );
760 $logEntry->setPerformer( $user );
761 // target page is not relevant, but it has to be set, so we just put in
762 // the title of Special:Tags
763 $logEntry->setTarget( Title::newFromText( 'Special:Tags' ) );
764 $logEntry->setComment( $reason );
765
766 $params = [ '4::tag' => $tag ];
767 if ( !is_null( $tagCount ) ) {
768 $params['5:number:count'] = $tagCount;
769 }
770 $logEntry->setParameters( $params );
771 $logEntry->setRelations( [ 'Tag' => $tag ] );
772
773 $logId = $logEntry->insert( $dbw );
774 $logEntry->publish( $logId );
775 return $logId;
776 }
777
787 public static function canActivateTag( $tag, User $user = null ) {
788 if ( !is_null( $user ) ) {
789 if ( !$user->isAllowed( 'managechangetags' ) ) {
790 return Status::newFatal( 'tags-manage-no-permission' );
791 } elseif ( $user->isBlocked() ) {
792 return Status::newFatal( 'tags-manage-blocked' );
793 }
794 }
795
796 // defined tags cannot be activated (a defined tag is either extension-
797 // defined, in which case the extension chooses whether or not to active it;
798 // or user-defined, in which case it is considered active)
799 $definedTags = self::listDefinedTags();
800 if ( in_array( $tag, $definedTags ) ) {
801 return Status::newFatal( 'tags-activate-not-allowed', $tag );
802 }
803
804 // non-existing tags cannot be activated
805 $tagUsage = self::tagUsageStatistics();
806 if ( !isset( $tagUsage[$tag] ) ) { // we already know the tag is undefined
807 return Status::newFatal( 'tags-activate-not-found', $tag );
808 }
809
810 return Status::newGood();
811 }
812
828 public static function activateTagWithChecks( $tag, $reason, User $user,
829 $ignoreWarnings = false ) {
830
831 // are we allowed to do this?
833 if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
834 $result->value = null;
835 return $result;
836 }
837
838 // do it!
840
841 // log it
842 $logId = self::logTagManagementAction( 'activate', $tag, $reason, $user );
843 return Status::newGood( $logId );
844 }
845
855 public static function canDeactivateTag( $tag, User $user = null ) {
856 if ( !is_null( $user ) ) {
857 if ( !$user->isAllowed( 'managechangetags' ) ) {
858 return Status::newFatal( 'tags-manage-no-permission' );
859 } elseif ( $user->isBlocked() ) {
860 return Status::newFatal( 'tags-manage-blocked' );
861 }
862 }
863
864 // only explicitly-defined tags can be deactivated
865 $explicitlyDefinedTags = self::listExplicitlyDefinedTags();
866 if ( !in_array( $tag, $explicitlyDefinedTags ) ) {
867 return Status::newFatal( 'tags-deactivate-not-allowed', $tag );
868 }
869 return Status::newGood();
870 }
871
887 public static function deactivateTagWithChecks( $tag, $reason, User $user,
888 $ignoreWarnings = false ) {
889
890 // are we allowed to do this?
892 if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
893 $result->value = null;
894 return $result;
895 }
896
897 // do it!
899
900 // log it
901 $logId = self::logTagManagementAction( 'deactivate', $tag, $reason, $user );
902 return Status::newGood( $logId );
903 }
904
914 public static function canCreateTag( $tag, User $user = null ) {
915 if ( !is_null( $user ) ) {
916 if ( !$user->isAllowed( 'managechangetags' ) ) {
917 return Status::newFatal( 'tags-manage-no-permission' );
918 } elseif ( $user->isBlocked() ) {
919 return Status::newFatal( 'tags-manage-blocked' );
920 }
921 }
922
923 // no empty tags
924 if ( $tag === '' ) {
925 return Status::newFatal( 'tags-create-no-name' );
926 }
927
928 // tags cannot contain commas (used as a delimiter in tag_summary table) or
929 // slashes (would break tag description messages in MediaWiki namespace)
930 if ( strpos( $tag, ',' ) !== false || strpos( $tag, '/' ) !== false ) {
931 return Status::newFatal( 'tags-create-invalid-chars' );
932 }
933
934 // could the MediaWiki namespace description messages be created?
935 $title = Title::makeTitleSafe( NS_MEDIAWIKI, "Tag-$tag-description" );
936 if ( is_null( $title ) ) {
937 return Status::newFatal( 'tags-create-invalid-title-chars' );
938 }
939
940 // does the tag already exist?
941 $tagUsage = self::tagUsageStatistics();
942 if ( isset( $tagUsage[$tag] ) || in_array( $tag, self::listDefinedTags() ) ) {
943 return Status::newFatal( 'tags-create-already-exists', $tag );
944 }
945
946 // check with hooks
947 $canCreateResult = Status::newGood();
948 Hooks::run( 'ChangeTagCanCreate', [ $tag, $user, &$canCreateResult ] );
949 return $canCreateResult;
950 }
951
966 public static function createTagWithChecks( $tag, $reason, User $user,
967 $ignoreWarnings = false ) {
968
969 // are we allowed to do this?
971 if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
972 $result->value = null;
973 return $result;
974 }
975
976 // do it!
978
979 // log it
980 $logId = self::logTagManagementAction( 'create', $tag, $reason, $user );
981 return Status::newGood( $logId );
982 }
983
996 public static function deleteTagEverywhere( $tag ) {
997 $dbw = wfGetDB( DB_MASTER );
998 $dbw->startAtomic( __METHOD__ );
999
1000 // delete from valid_tag
1002
1003 // find out which revisions use this tag, so we can delete from tag_summary
1004 $result = $dbw->select( 'change_tag',
1005 [ 'ct_rc_id', 'ct_log_id', 'ct_rev_id', 'ct_tag' ],
1006 [ 'ct_tag' => $tag ],
1007 __METHOD__ );
1008 foreach ( $result as $row ) {
1009 // remove the tag from the relevant row of tag_summary
1010 $tagsToAdd = [];
1011 $tagsToRemove = [ $tag ];
1012 self::updateTagSummaryRow( $tagsToAdd, $tagsToRemove, $row->ct_rc_id,
1013 $row->ct_rev_id, $row->ct_log_id );
1014 }
1015
1016 // delete from change_tag
1017 $dbw->delete( 'change_tag', [ 'ct_tag' => $tag ], __METHOD__ );
1018
1019 $dbw->endAtomic( __METHOD__ );
1020
1021 // give extensions a chance
1022 $status = Status::newGood();
1023 Hooks::run( 'ChangeTagAfterDelete', [ $tag, &$status ] );
1024 // let's not allow error results, as the actual tag deletion succeeded
1025 if ( !$status->isOK() ) {
1026 wfDebug( 'ChangeTagAfterDelete error condition downgraded to warning' );
1027 $status->setOK( true );
1028 }
1029
1030 // clear the memcache of defined tags
1032
1033 return $status;
1034 }
1035
1045 public static function canDeleteTag( $tag, User $user = null ) {
1046 $tagUsage = self::tagUsageStatistics();
1047
1048 if ( !is_null( $user ) ) {
1049 if ( !$user->isAllowed( 'deletechangetags' ) ) {
1050 return Status::newFatal( 'tags-delete-no-permission' );
1051 } elseif ( $user->isBlocked() ) {
1052 return Status::newFatal( 'tags-manage-blocked' );
1053 }
1054 }
1055
1056 if ( !isset( $tagUsage[$tag] ) && !in_array( $tag, self::listDefinedTags() ) ) {
1057 return Status::newFatal( 'tags-delete-not-found', $tag );
1058 }
1059
1060 if ( isset( $tagUsage[$tag] ) && $tagUsage[$tag] > self::MAX_DELETE_USES ) {
1061 return Status::newFatal( 'tags-delete-too-many-uses', $tag, self::MAX_DELETE_USES );
1062 }
1063
1064 $softwareDefined = self::listSoftwareDefinedTags();
1065 if ( in_array( $tag, $softwareDefined ) ) {
1066 // extension-defined tags can't be deleted unless the extension
1067 // specifically allows it
1068 $status = Status::newFatal( 'tags-delete-not-allowed' );
1069 } else {
1070 // user-defined tags are deletable unless otherwise specified
1071 $status = Status::newGood();
1072 }
1073
1074 Hooks::run( 'ChangeTagCanDelete', [ $tag, $user, &$status ] );
1075 return $status;
1076 }
1077
1093 public static function deleteTagWithChecks( $tag, $reason, User $user,
1094 $ignoreWarnings = false ) {
1095
1096 // are we allowed to do this?
1098 if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
1099 $result->value = null;
1100 return $result;
1101 }
1102
1103 // store the tag usage statistics
1104 $tagUsage = self::tagUsageStatistics();
1105 $hitcount = isset( $tagUsage[$tag] ) ? $tagUsage[$tag] : 0;
1106
1107 // do it!
1108 $deleteResult = self::deleteTagEverywhere( $tag );
1109 if ( !$deleteResult->isOK() ) {
1110 return $deleteResult;
1111 }
1112
1113 // log it
1114 $logId = self::logTagManagementAction( 'delete', $tag, $reason, $user, $hitcount );
1115 $deleteResult->value = $logId;
1116 return $deleteResult;
1117 }
1118
1125 public static function listSoftwareActivatedTags() {
1126 // core active tags
1127 $tags = self::$coreTags;
1128 if ( !Hooks::isRegistered( 'ChangeTagsListActive' ) ) {
1129 return $tags;
1130 }
1131 return ObjectCache::getMainWANInstance()->getWithSetCallback(
1132 wfMemcKey( 'active-tags' ),
1133 WANObjectCache::TTL_MINUTE * 5,
1134 function ( $oldValue, &$ttl, array &$setOpts ) use ( $tags ) {
1135 $setOpts += Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) );
1136
1137 // Ask extensions which tags they consider active
1138 Hooks::run( 'ChangeTagsListActive', [ &$tags ] );
1139 return $tags;
1140 },
1141 [
1142 'checkKeys' => [ wfMemcKey( 'active-tags' ) ],
1143 'lockTSE' => WANObjectCache::TTL_MINUTE * 5,
1144 'pcTTL' => WANObjectCache::TTL_PROC_LONG
1145 ]
1146 );
1147 }
1148
1154 public static function listExtensionActivatedTags() {
1155 wfDeprecated( __METHOD__, '1.28' );
1157 }
1158
1166 public static function listDefinedTags() {
1169 return array_values( array_unique( array_merge( $tags1, $tags2 ) ) );
1170 }
1171
1182 public static function listExplicitlyDefinedTags() {
1183 $fname = __METHOD__;
1184
1185 return ObjectCache::getMainWANInstance()->getWithSetCallback(
1186 wfMemcKey( 'valid-tags-db' ),
1187 WANObjectCache::TTL_MINUTE * 5,
1188 function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
1189 $dbr = wfGetDB( DB_REPLICA );
1190
1191 $setOpts += Database::getCacheSetOptions( $dbr );
1192
1193 $tags = $dbr->selectFieldValues( 'valid_tag', 'vt_tag', [], $fname );
1194
1195 return array_filter( array_unique( $tags ) );
1196 },
1197 [
1198 'checkKeys' => [ wfMemcKey( 'valid-tags-db' ) ],
1199 'lockTSE' => WANObjectCache::TTL_MINUTE * 5,
1200 'pcTTL' => WANObjectCache::TTL_PROC_LONG
1201 ]
1202 );
1203 }
1204
1214 public static function listSoftwareDefinedTags() {
1215 // core defined tags
1216 $tags = self::$coreTags;
1217 if ( !Hooks::isRegistered( 'ListDefinedTags' ) ) {
1218 return $tags;
1219 }
1220 return ObjectCache::getMainWANInstance()->getWithSetCallback(
1221 wfMemcKey( 'valid-tags-hook' ),
1222 WANObjectCache::TTL_MINUTE * 5,
1223 function ( $oldValue, &$ttl, array &$setOpts ) use ( $tags ) {
1224 $setOpts += Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) );
1225
1226 Hooks::run( 'ListDefinedTags', [ &$tags ] );
1227 return array_filter( array_unique( $tags ) );
1228 },
1229 [
1230 'checkKeys' => [ wfMemcKey( 'valid-tags-hook' ) ],
1231 'lockTSE' => WANObjectCache::TTL_MINUTE * 5,
1232 'pcTTL' => WANObjectCache::TTL_PROC_LONG
1233 ]
1234 );
1235 }
1236
1243 public static function listExtensionDefinedTags() {
1244 wfDeprecated( __METHOD__, '1.28' );
1246 }
1247
1253 public static function purgeTagCacheAll() {
1254 $cache = ObjectCache::getMainWANInstance();
1255
1256 $cache->touchCheckKey( wfMemcKey( 'active-tags' ) );
1257 $cache->touchCheckKey( wfMemcKey( 'valid-tags-db' ) );
1258 $cache->touchCheckKey( wfMemcKey( 'valid-tags-hook' ) );
1259
1261 }
1262
1267 public static function purgeTagUsageCache() {
1268 $cache = ObjectCache::getMainWANInstance();
1269
1270 $cache->touchCheckKey( wfMemcKey( 'change-tag-statistics' ) );
1271 }
1272
1283 public static function tagUsageStatistics() {
1284 $fname = __METHOD__;
1285 return ObjectCache::getMainWANInstance()->getWithSetCallback(
1286 wfMemcKey( 'change-tag-statistics' ),
1287 WANObjectCache::TTL_MINUTE * 5,
1288 function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
1289 $dbr = wfGetDB( DB_REPLICA, 'vslow' );
1290
1291 $setOpts += Database::getCacheSetOptions( $dbr );
1292
1293 $res = $dbr->select(
1294 'change_tag',
1295 [ 'ct_tag', 'hitcount' => 'count(*)' ],
1296 [],
1297 $fname,
1298 [ 'GROUP BY' => 'ct_tag', 'ORDER BY' => 'hitcount DESC' ]
1299 );
1300
1301 $out = [];
1302 foreach ( $res as $row ) {
1303 $out[$row->ct_tag] = $row->hitcount;
1304 }
1305
1306 return $out;
1307 },
1308 [
1309 'checkKeys' => [ wfMemcKey( 'change-tag-statistics' ) ],
1310 'lockTSE' => WANObjectCache::TTL_MINUTE * 5,
1311 'pcTTL' => WANObjectCache::TTL_PROC_LONG
1312 ]
1313 );
1314 }
1315
1330 public static function showTagEditingUI( User $user ) {
1331 return $user->isAllowed( 'changetags' ) && (bool)self::listExplicitlyDefinedTags();
1332 }
1333}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgUseTagFilter
Allow filtering by change tag in recentchanges, history, etc Has no effect if no tags are defined in ...
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfMemcKey()
Make a cache key for the local wiki.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition Setup.php:36
if(! $wgDBerrorLogTZ) $wgRequest
Definition Setup.php:664
static listSoftwareDefinedTags()
Lists tags defined by core or extensions using the ListDefinedTags hook.
static purgeTagUsageCache()
Invalidates the tag statistics cache only.
static updateTags( $tagsToAdd, $tagsToRemove, &$rc_id=null, &$rev_id=null, &$log_id=null, $params=null, RecentChange $rc=null, User $user=null)
Add and remove tags to/from a change given its rc_id, rev_id and/or log_id, without verifying that th...
static tagDescription( $tag)
Get a short description for a tag.
static updateTagSummaryRow(&$tagsToAdd, &$tagsToRemove, $rc_id, $rev_id, $log_id, &$prevTags=[])
Adds or removes a given set of tags to/from the relevant row of the tag_summary table.
static logTagManagementAction( $action, $tag, $reason, User $user, $tagCount=null)
Writes a tag action into the tag management log.
static restrictedTagError( $msgOne, $msgMulti, $tags)
Helper function to generate a fatal status with a 'not-allowed' type error.
static listSoftwareActivatedTags()
Lists those tags which core or extensions report as being "active".
static deactivateTagWithChecks( $tag, $reason, User $user, $ignoreWarnings=false)
Deactivates a tag, checking whether it is allowed first, and adding a log entry afterwards.
static undefineTag( $tag)
Removes a tag from the valid_tag table.
static activateTagWithChecks( $tag, $reason, User $user, $ignoreWarnings=false)
Activates a tag, checking whether it is allowed first, and adding a log entry afterwards.
static canCreateTag( $tag, User $user=null)
Is it OK to allow the user to create this tag?
static deleteTagWithChecks( $tag, $reason, User $user, $ignoreWarnings=false)
Deletes a tag, checking whether it is allowed first, and adding a log entry afterwards.
static purgeTagCacheAll()
Invalidates the short-term cache of defined tags used by the list*DefinedTags functions,...
static addTags( $tags, $rc_id=null, $rev_id=null, $log_id=null, $params=null, RecentChange $rc=null)
Add tags to a change given its rc_id, rev_id and/or log_id.
static tagUsageStatistics()
Returns a map of any tags used on the wiki to number of edits tagged with them, ordered descending by...
static addTagsAccompanyingChangeWithChecks(array $tags, $rc_id, $rev_id, $log_id, $params, User $user)
Adds tags to a given change, checking whether it is allowed first, but without adding a log entry.
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
static listExtensionActivatedTags()
static updateTagsWithChecks( $tagsToAdd, $tagsToRemove, $rc_id, $rev_id, $log_id, $params, $reason, User $user)
Adds and/or removes tags to/from a given change, checking whether it is allowed first,...
static canActivateTag( $tag, User $user=null)
Is it OK to allow the user to activate this tag?
static listDefinedTags()
Basically lists defined tags which count even if they aren't applied to anything.
static buildTagFilterSelector( $selected='', $ooui=false)
Build a text box to select a change tag.
static defineTag( $tag)
Defines a tag in the valid_tag table, without checking that the tag name is valid.
static canDeactivateTag( $tag, User $user=null)
Is it OK to allow the user to deactivate this tag?
static showTagEditingUI(User $user)
Indicate whether change tag editing UI is relevant.
static canDeleteTag( $tag, User $user=null)
Is it OK to allow the user to delete this tag?
static createTagWithChecks( $tag, $reason, User $user, $ignoreWarnings=false)
Creates a tag by adding a row to the valid_tag table.
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag=false)
Applies all tags-related changes to a query.
static deleteTagEverywhere( $tag)
Permanently removes all traces of a tag from the DB.
const MAX_DELETE_USES
Can't delete tags with more than this many uses.
static listExtensionDefinedTags()
Call listSoftwareDefinedTags directly.
static canUpdateTags(array $tagsToAdd, array $tagsToRemove, User $user=null)
Is it OK to allow the user to adds and remove the given tags tags to/from a change?
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the valid_tag table of the database.
static string[] $coreTags
static canAddTagsAccompanyingChange(array $tags, User $user=null)
Is it OK to allow the user to apply all the specified tags at the same time as they edit/make the cha...
MediaWiki exception.
Class for creating log entries manually, to inject them into the database.
Definition LogEntry.php:394
Utility class for creating new RC entries.
static getMain()
Static methods.
static suggestTarget( $target, array $ids)
Suggest a target for the revision deletion Optionally override this function.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition Revision.php:110
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:48
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
Definition Xml.php:275
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition Xml.php:131
$res
Definition database.txt:21
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
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
const NS_MEDIAWIKI
Definition Defines.php:64
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition hooks.txt:1049
the array() calling protocol came about after MediaWiki 1.4rc1.
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:249
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
Definition hooks.txt:1028
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:Associative array mapping language codes to prefixed links of the form "language:title". & $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:1937
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:986
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition hooks.txt:1096
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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:886
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books $tag
Definition hooks.txt:1033
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition hooks.txt:2534
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition hooks.txt:1734
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
Interface for objects which can provide a MediaWiki context on request.
$context
Definition load.php:50
$cache
Definition mcc.php:33
const DB_REPLICA
Definition defines.php:22
const DB_MASTER
Definition defines.php:23
$params
if(!isset( $args[0])) $lang