MediaWiki  1.27.1
ChangeTags.php
Go to the documentation of this file.
1 <?php
24 class ChangeTags {
30  const MAX_DELETE_USES = 5000;
31 
45  public static function formatSummaryRow( $tags, $page, IContextSource $context = null ) {
46  if ( !$tags ) {
47  return [ '', [] ];
48  }
49  if ( !$context ) {
51  }
52 
53  $classes = [];
54 
55  $tags = explode( ',', $tags );
56  $displayTags = [];
57  foreach ( $tags as $tag ) {
58  if ( !$tag ) {
59  continue;
60  }
61  $description = self::tagDescription( $tag );
62  if ( $description === false ) {
63  continue;
64  }
65  $displayTags[] = Xml::tags(
66  'span',
67  [ 'class' => 'mw-tag-marker ' .
68  Sanitizer::escapeClass( "mw-tag-marker-$tag" ) ],
69  $description
70  );
71  $classes[] = Sanitizer::escapeClass( "mw-tag-$tag" );
72  }
73 
74  if ( !$displayTags ) {
75  return [ '', [] ];
76  }
77 
78  $markers = $context->msg( 'tag-list-wrapper' )
79  ->numParams( count( $displayTags ) )
80  ->rawParams( $context->getLanguage()->commaList( $displayTags ) )
81  ->parse();
82  $markers = Xml::tags( 'span', [ 'class' => 'mw-tag-markers' ], $markers );
83 
84  return [ $markers, $classes ];
85  }
86 
99  public static function tagDescription( $tag ) {
100  $msg = wfMessage( "tag-$tag" );
101  if ( !$msg->exists() ) {
102  // No such message, so return the HTML-escaped tag name.
103  return htmlspecialchars( $tag );
104  }
105  if ( $msg->isDisabled() ) {
106  // The message exists but is disabled, hide the tag.
107  return false;
108  }
109 
110  // Message exists and isn't disabled, use it.
111  return $msg->parse();
112  }
113 
126  public static function addTags( $tags, $rc_id = null, $rev_id = null,
127  $log_id = null, $params = null
128  ) {
129  $result = self::updateTags( $tags, null, $rc_id, $rev_id, $log_id, $params );
130  return (bool)$result[0];
131  }
132 
160  public static function updateTags(
161  $tagsToAdd, $tagsToRemove,
162  &$rc_id = null, &$rev_id = null, &$log_id = null, $params = null
163  ) {
164 
165  $tagsToAdd = array_filter( (array)$tagsToAdd ); // Make sure we're submitting all tags...
166  $tagsToRemove = array_filter( (array)$tagsToRemove );
167 
168  if ( !$rc_id && !$rev_id && !$log_id ) {
169  throw new MWException( 'At least one of: RCID, revision ID, and log ID MUST be ' .
170  'specified when adding or removing a tag from a change!' );
171  }
172 
173  $dbw = wfGetDB( DB_MASTER );
174 
175  // Might as well look for rcids and so on.
176  if ( !$rc_id ) {
177  // Info might be out of date, somewhat fractionally, on slave.
178  // LogEntry/LogPage and WikiPage match rev/log/rc timestamps,
179  // so use that relation to avoid full table scans.
180  if ( $log_id ) {
181  $rc_id = $dbw->selectField(
182  [ 'logging', 'recentchanges' ],
183  'rc_id',
184  [
185  'log_id' => $log_id,
186  'rc_timestamp = log_timestamp',
187  'rc_logid = log_id'
188  ],
189  __METHOD__
190  );
191  } elseif ( $rev_id ) {
192  $rc_id = $dbw->selectField(
193  [ 'revision', 'recentchanges' ],
194  'rc_id',
195  [
196  'rev_id' => $rev_id,
197  'rc_timestamp = rev_timestamp',
198  'rc_this_oldid = rev_id'
199  ],
200  __METHOD__
201  );
202  }
203  } elseif ( !$log_id && !$rev_id ) {
204  // Info might be out of date, somewhat fractionally, on slave.
205  $log_id = $dbw->selectField(
206  'recentchanges',
207  'rc_logid',
208  [ 'rc_id' => $rc_id ],
209  __METHOD__
210  );
211  $rev_id = $dbw->selectField(
212  'recentchanges',
213  'rc_this_oldid',
214  [ 'rc_id' => $rc_id ],
215  __METHOD__
216  );
217  }
218 
219  if ( $log_id && !$rev_id ) {
220  $rev_id = $dbw->selectField(
221  'log_search',
222  'ls_value',
223  [ 'ls_field' => 'associated_rev_id', 'ls_log_id' => $log_id ],
224  __METHOD__
225  );
226  } elseif ( !$log_id && $rev_id ) {
227  $log_id = $dbw->selectField(
228  'log_search',
229  'ls_log_id',
230  [ 'ls_field' => 'associated_rev_id', 'ls_value' => $rev_id ],
231  __METHOD__
232  );
233  }
234 
235  // update the tag_summary row
236  $prevTags = [];
237  if ( !self::updateTagSummaryRow( $tagsToAdd, $tagsToRemove, $rc_id, $rev_id,
238  $log_id, $prevTags ) ) {
239 
240  // nothing to do
241  return [ [], [], $prevTags ];
242  }
243 
244  // insert a row into change_tag for each new tag
245  if ( count( $tagsToAdd ) ) {
246  $tagsRows = [];
247  foreach ( $tagsToAdd as $tag ) {
248  // Filter so we don't insert NULLs as zero accidentally.
249  // Keep in mind that $rc_id === null means "I don't care/know about the
250  // rc_id, just delete $tag on this revision/log entry". It doesn't
251  // mean "only delete tags on this revision/log WHERE rc_id IS NULL".
252  $tagsRows[] = array_filter(
253  [
254  'ct_tag' => $tag,
255  'ct_rc_id' => $rc_id,
256  'ct_log_id' => $log_id,
257  'ct_rev_id' => $rev_id,
258  'ct_params' => $params
259  ]
260  );
261  }
262 
263  $dbw->insert( 'change_tag', $tagsRows, __METHOD__, [ 'IGNORE' ] );
264  }
265 
266  // delete from change_tag
267  if ( count( $tagsToRemove ) ) {
268  foreach ( $tagsToRemove as $tag ) {
269  $conds = array_filter(
270  [
271  'ct_tag' => $tag,
272  'ct_rc_id' => $rc_id,
273  'ct_log_id' => $log_id,
274  'ct_rev_id' => $rev_id
275  ]
276  );
277  $dbw->delete( 'change_tag', $conds, __METHOD__ );
278  }
279  }
280 
281  self::purgeTagUsageCache();
282  return [ $tagsToAdd, $tagsToRemove, $prevTags ];
283  }
284 
301  protected static function updateTagSummaryRow( &$tagsToAdd, &$tagsToRemove,
302  $rc_id, $rev_id, $log_id, &$prevTags = [] ) {
303 
304  $dbw = wfGetDB( DB_MASTER );
305 
306  $tsConds = array_filter( [
307  'ts_rc_id' => $rc_id,
308  'ts_rev_id' => $rev_id,
309  'ts_log_id' => $log_id
310  ] );
311 
312  // Can't both add and remove a tag at the same time...
313  $tagsToAdd = array_diff( $tagsToAdd, $tagsToRemove );
314 
315  // Update the summary row.
316  // $prevTags can be out of date on slaves, especially when addTags is called consecutively,
317  // causing loss of tags added recently in tag_summary table.
318  $prevTags = $dbw->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ );
319  $prevTags = $prevTags ? $prevTags : '';
320  $prevTags = array_filter( explode( ',', $prevTags ) );
321 
322  // add tags
323  $tagsToAdd = array_values( array_diff( $tagsToAdd, $prevTags ) );
324  $newTags = array_unique( array_merge( $prevTags, $tagsToAdd ) );
325 
326  // remove tags
327  $tagsToRemove = array_values( array_intersect( $tagsToRemove, $newTags ) );
328  $newTags = array_values( array_diff( $newTags, $tagsToRemove ) );
329 
330  sort( $prevTags );
331  sort( $newTags );
332  if ( $prevTags == $newTags ) {
333  // No change.
334  return false;
335  }
336 
337  if ( !$newTags ) {
338  // no tags left, so delete the row altogether
339  $dbw->delete( 'tag_summary', $tsConds, __METHOD__ );
340  } else {
341  $dbw->replace( 'tag_summary',
342  [ 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ],
343  array_filter( array_merge( $tsConds, [ 'ts_tags' => implode( ',', $newTags ) ] ) ),
344  __METHOD__
345  );
346  }
347 
348  return true;
349  }
350 
361  protected static function restrictedTagError( $msgOne, $msgMulti, $tags ) {
362  $lang = RequestContext::getMain()->getLanguage();
363  $count = count( $tags );
364  return Status::newFatal( ( $count > 1 ) ? $msgMulti : $msgOne,
365  $lang->commaList( $tags ), $count );
366  }
367 
378  public static function canAddTagsAccompanyingChange( array $tags,
379  User $user = null ) {
380 
381  if ( !is_null( $user ) ) {
382  if ( !$user->isAllowed( 'applychangetags' ) ) {
383  return Status::newFatal( 'tags-apply-no-permission' );
384  } elseif ( $user->isBlocked() ) {
385  return Status::newFatal( 'tags-apply-blocked' );
386  }
387  }
388 
389  // to be applied, a tag has to be explicitly defined
390  // @todo Allow extensions to define tags that can be applied by users...
391  $allowedTags = self::listExplicitlyDefinedTags();
392  $disallowedTags = array_diff( $tags, $allowedTags );
393  if ( $disallowedTags ) {
394  return self::restrictedTagError( 'tags-apply-not-allowed-one',
395  'tags-apply-not-allowed-multi', $disallowedTags );
396  }
397 
398  return Status::newGood();
399  }
400 
421  public static function addTagsAccompanyingChangeWithChecks(
422  array $tags, $rc_id, $rev_id, $log_id, $params, User $user
423  ) {
424 
425  // are we allowed to do this?
426  $result = self::canAddTagsAccompanyingChange( $tags, $user );
427  if ( !$result->isOK() ) {
428  $result->value = null;
429  return $result;
430  }
431 
432  // do it!
433  self::addTags( $tags, $rc_id, $rev_id, $log_id, $params );
434 
435  return Status::newGood( true );
436  }
437 
449  public static function canUpdateTags( array $tagsToAdd, array $tagsToRemove,
450  User $user = null ) {
451 
452  if ( !is_null( $user ) ) {
453  if ( !$user->isAllowed( 'changetags' ) ) {
454  return Status::newFatal( 'tags-update-no-permission' );
455  } elseif ( $user->isBlocked() ) {
456  return Status::newFatal( 'tags-update-blocked' );
457  }
458  }
459 
460  if ( $tagsToAdd ) {
461  // to be added, a tag has to be explicitly defined
462  // @todo Allow extensions to define tags that can be applied by users...
463  $explicitlyDefinedTags = self::listExplicitlyDefinedTags();
464  $diff = array_diff( $tagsToAdd, $explicitlyDefinedTags );
465  if ( $diff ) {
466  return self::restrictedTagError( 'tags-update-add-not-allowed-one',
467  'tags-update-add-not-allowed-multi', $diff );
468  }
469  }
470 
471  if ( $tagsToRemove ) {
472  // to be removed, a tag must not be defined by an extension, or equivalently it
473  // has to be either explicitly defined or not defined at all
474  // (assuming no edge case of a tag both explicitly-defined and extension-defined)
475  $extensionDefinedTags = self::listExtensionDefinedTags();
476  $intersect = array_intersect( $tagsToRemove, $extensionDefinedTags );
477  if ( $intersect ) {
478  return self::restrictedTagError( 'tags-update-remove-not-allowed-one',
479  'tags-update-remove-not-allowed-multi', $intersect );
480  }
481  }
482 
483  return Status::newGood();
484  }
485 
512  public static function updateTagsWithChecks( $tagsToAdd, $tagsToRemove,
513  $rc_id, $rev_id, $log_id, $params, $reason, User $user ) {
514 
515  if ( is_null( $tagsToAdd ) ) {
516  $tagsToAdd = [];
517  }
518  if ( is_null( $tagsToRemove ) ) {
519  $tagsToRemove = [];
520  }
521  if ( !$tagsToAdd && !$tagsToRemove ) {
522  // no-op, don't bother
523  return Status::newGood( (object)[
524  'logId' => null,
525  'addedTags' => [],
526  'removedTags' => [],
527  ] );
528  }
529 
530  // are we allowed to do this?
531  $result = self::canUpdateTags( $tagsToAdd, $tagsToRemove, $user );
532  if ( !$result->isOK() ) {
533  $result->value = null;
534  return $result;
535  }
536 
537  // basic rate limiting
538  if ( $user->pingLimiter( 'changetag' ) ) {
539  return Status::newFatal( 'actionthrottledtext' );
540  }
541 
542  // do it!
543  list( $tagsAdded, $tagsRemoved, $initialTags ) = self::updateTags( $tagsToAdd,
544  $tagsToRemove, $rc_id, $rev_id, $log_id, $params );
545  if ( !$tagsAdded && !$tagsRemoved ) {
546  // no-op, don't log it
547  return Status::newGood( (object)[
548  'logId' => null,
549  'addedTags' => [],
550  'removedTags' => [],
551  ] );
552  }
553 
554  // log it
555  $logEntry = new ManualLogEntry( 'tag', 'update' );
556  $logEntry->setPerformer( $user );
557  $logEntry->setComment( $reason );
558 
559  // find the appropriate target page
560  if ( $rev_id ) {
561  $rev = Revision::newFromId( $rev_id );
562  if ( $rev ) {
563  $logEntry->setTarget( $rev->getTitle() );
564  }
565  } elseif ( $log_id ) {
566  // This function is from revision deletion logic and has nothing to do with
567  // change tags, but it appears to be the only other place in core where we
568  // perform logged actions on log items.
569  $logEntry->setTarget( RevDelLogList::suggestTarget( 0, [ $log_id ] ) );
570  }
571 
572  if ( !$logEntry->getTarget() ) {
573  // target is required, so we have to set something
574  $logEntry->setTarget( SpecialPage::getTitleFor( 'Tags' ) );
575  }
576 
577  $logParams = [
578  '4::revid' => $rev_id,
579  '5::logid' => $log_id,
580  '6:list:tagsAdded' => $tagsAdded,
581  '7:number:tagsAddedCount' => count( $tagsAdded ),
582  '8:list:tagsRemoved' => $tagsRemoved,
583  '9:number:tagsRemovedCount' => count( $tagsRemoved ),
584  'initialTags' => $initialTags,
585  ];
586  $logEntry->setParameters( $logParams );
587  $logEntry->setRelations( [ 'Tag' => array_merge( $tagsAdded, $tagsRemoved ) ] );
588 
589  $dbw = wfGetDB( DB_MASTER );
590  $logId = $logEntry->insert( $dbw );
591  // Only send this to UDP, not RC, similar to patrol events
592  $logEntry->publish( $logId, 'udp' );
593 
594  return Status::newGood( (object)[
595  'logId' => $logId,
596  'addedTags' => $tagsAdded,
597  'removedTags' => $tagsRemoved,
598  ] );
599  }
600 
615  public static function modifyDisplayQuery( &$tables, &$fields, &$conds,
616  &$join_conds, &$options, $filter_tag = false ) {
617  global $wgRequest, $wgUseTagFilter;
618 
619  if ( $filter_tag === false ) {
620  $filter_tag = $wgRequest->getVal( 'tagfilter' );
621  }
622 
623  // Figure out which conditions can be done.
624  if ( in_array( 'recentchanges', $tables ) ) {
625  $join_cond = 'ct_rc_id=rc_id';
626  } elseif ( in_array( 'logging', $tables ) ) {
627  $join_cond = 'ct_log_id=log_id';
628  } elseif ( in_array( 'revision', $tables ) ) {
629  $join_cond = 'ct_rev_id=rev_id';
630  } elseif ( in_array( 'archive', $tables ) ) {
631  $join_cond = 'ct_rev_id=ar_rev_id';
632  } else {
633  throw new MWException( 'Unable to determine appropriate JOIN condition for tagging.' );
634  }
635 
636  $fields['ts_tags'] = wfGetDB( DB_SLAVE )->buildGroupConcatField(
637  ',', 'change_tag', 'ct_tag', $join_cond
638  );
639 
640  if ( $wgUseTagFilter && $filter_tag ) {
641  // Somebody wants to filter on a tag.
642  // Add an INNER JOIN on change_tag
643 
644  $tables[] = 'change_tag';
645  $join_conds['change_tag'] = [ 'INNER JOIN', $join_cond ];
646  $conds['ct_tag'] = $filter_tag;
647  }
648  }
649 
662  public static function buildTagFilterSelector( $selected = '',
663  $fullForm = false, Title $title = null, $ooui = false
664  ) {
665  global $wgUseTagFilter;
666 
667  if ( !$wgUseTagFilter || !count( self::listDefinedTags() ) ) {
668  return $fullForm ? '' : [];
669  }
670 
671  $data = [
673  'label',
674  [ 'for' => 'tagfilter' ],
675  wfMessage( 'tag-filter' )->parse()
676  )
677  ];
678 
679  if ( $ooui ) {
680  $data[] = new OOUI\TextInputWidget( [
681  'id' => 'tagfilter',
682  'name' => 'tagfilter',
683  'value' => $selected,
684  'classes' => 'mw-tagfilter-input',
685  ] );
686  } else {
687  $data[] = Xml::input(
688  'tagfilter',
689  20,
690  $selected,
691  [ 'class' => 'mw-tagfilter-input mw-ui-input mw-ui-input-inline', 'id' => 'tagfilter' ]
692  );
693  }
694 
695  if ( !$fullForm ) {
696  return $data;
697  }
698 
699  $html = implode( '&#160;', $data );
700  $html .= "\n" .
701  Xml::element(
702  'input',
703  [ 'type' => 'submit', 'value' => wfMessage( 'tag-filter-submit' )->text() ]
704  );
705  $html .= "\n" . Html::hidden( 'title', $title->getPrefixedText() );
706  $html = Xml::tags(
707  'form',
708  [ 'action' => $title->getLocalURL(), 'class' => 'mw-tagfilter-form', 'method' => 'get' ],
709  $html
710  );
711 
712  return $html;
713  }
714 
724  public static function defineTag( $tag ) {
725  $dbw = wfGetDB( DB_MASTER );
726  $dbw->replace( 'valid_tag',
727  [ 'vt_tag' ],
728  [ 'vt_tag' => $tag ],
729  __METHOD__ );
730 
731  // clear the memcache of defined tags
732  self::purgeTagCacheAll();
733  }
734 
743  public static function undefineTag( $tag ) {
744  $dbw = wfGetDB( DB_MASTER );
745  $dbw->delete( 'valid_tag', [ 'vt_tag' => $tag ], __METHOD__ );
746 
747  // clear the memcache of defined tags
748  self::purgeTagCacheAll();
749  }
750 
763  protected static function logTagManagementAction( $action, $tag, $reason,
764  User $user, $tagCount = null ) {
765 
766  $dbw = wfGetDB( DB_MASTER );
767 
768  $logEntry = new ManualLogEntry( 'managetags', $action );
769  $logEntry->setPerformer( $user );
770  // target page is not relevant, but it has to be set, so we just put in
771  // the title of Special:Tags
772  $logEntry->setTarget( Title::newFromText( 'Special:Tags' ) );
773  $logEntry->setComment( $reason );
774 
775  $params = [ '4::tag' => $tag ];
776  if ( !is_null( $tagCount ) ) {
777  $params['5:number:count'] = $tagCount;
778  }
779  $logEntry->setParameters( $params );
780  $logEntry->setRelations( [ 'Tag' => $tag ] );
781 
782  $logId = $logEntry->insert( $dbw );
783  $logEntry->publish( $logId );
784  return $logId;
785  }
786 
796  public static function canActivateTag( $tag, User $user = null ) {
797  if ( !is_null( $user ) ) {
798  if ( !$user->isAllowed( 'managechangetags' ) ) {
799  return Status::newFatal( 'tags-manage-no-permission' );
800  } elseif ( $user->isBlocked() ) {
801  return Status::newFatal( 'tags-manage-blocked' );
802  }
803  }
804 
805  // defined tags cannot be activated (a defined tag is either extension-
806  // defined, in which case the extension chooses whether or not to active it;
807  // or user-defined, in which case it is considered active)
808  $definedTags = self::listDefinedTags();
809  if ( in_array( $tag, $definedTags ) ) {
810  return Status::newFatal( 'tags-activate-not-allowed', $tag );
811  }
812 
813  // non-existing tags cannot be activated
814  $tagUsage = self::tagUsageStatistics();
815  if ( !isset( $tagUsage[$tag] ) ) { // we already know the tag is undefined
816  return Status::newFatal( 'tags-activate-not-found', $tag );
817  }
818 
819  return Status::newGood();
820  }
821 
837  public static function activateTagWithChecks( $tag, $reason, User $user,
838  $ignoreWarnings = false ) {
839 
840  // are we allowed to do this?
841  $result = self::canActivateTag( $tag, $user );
842  if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
843  $result->value = null;
844  return $result;
845  }
846 
847  // do it!
848  self::defineTag( $tag );
849 
850  // log it
851  $logId = self::logTagManagementAction( 'activate', $tag, $reason, $user );
852  return Status::newGood( $logId );
853  }
854 
864  public static function canDeactivateTag( $tag, User $user = null ) {
865  if ( !is_null( $user ) ) {
866  if ( !$user->isAllowed( 'managechangetags' ) ) {
867  return Status::newFatal( 'tags-manage-no-permission' );
868  } elseif ( $user->isBlocked() ) {
869  return Status::newFatal( 'tags-manage-blocked' );
870  }
871  }
872 
873  // only explicitly-defined tags can be deactivated
874  $explicitlyDefinedTags = self::listExplicitlyDefinedTags();
875  if ( !in_array( $tag, $explicitlyDefinedTags ) ) {
876  return Status::newFatal( 'tags-deactivate-not-allowed', $tag );
877  }
878  return Status::newGood();
879  }
880 
896  public static function deactivateTagWithChecks( $tag, $reason, User $user,
897  $ignoreWarnings = false ) {
898 
899  // are we allowed to do this?
900  $result = self::canDeactivateTag( $tag, $user );
901  if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
902  $result->value = null;
903  return $result;
904  }
905 
906  // do it!
907  self::undefineTag( $tag );
908 
909  // log it
910  $logId = self::logTagManagementAction( 'deactivate', $tag, $reason, $user );
911  return Status::newGood( $logId );
912  }
913 
923  public static function canCreateTag( $tag, User $user = null ) {
924  if ( !is_null( $user ) ) {
925  if ( !$user->isAllowed( 'managechangetags' ) ) {
926  return Status::newFatal( 'tags-manage-no-permission' );
927  } elseif ( $user->isBlocked() ) {
928  return Status::newFatal( 'tags-manage-blocked' );
929  }
930  }
931 
932  // no empty tags
933  if ( $tag === '' ) {
934  return Status::newFatal( 'tags-create-no-name' );
935  }
936 
937  // tags cannot contain commas (used as a delimiter in tag_summary table) or
938  // slashes (would break tag description messages in MediaWiki namespace)
939  if ( strpos( $tag, ',' ) !== false || strpos( $tag, '/' ) !== false ) {
940  return Status::newFatal( 'tags-create-invalid-chars' );
941  }
942 
943  // could the MediaWiki namespace description messages be created?
944  $title = Title::makeTitleSafe( NS_MEDIAWIKI, "Tag-$tag-description" );
945  if ( is_null( $title ) ) {
946  return Status::newFatal( 'tags-create-invalid-title-chars' );
947  }
948 
949  // does the tag already exist?
950  $tagUsage = self::tagUsageStatistics();
951  if ( isset( $tagUsage[$tag] ) || in_array( $tag, self::listDefinedTags() ) ) {
952  return Status::newFatal( 'tags-create-already-exists', $tag );
953  }
954 
955  // check with hooks
956  $canCreateResult = Status::newGood();
957  Hooks::run( 'ChangeTagCanCreate', [ $tag, $user, &$canCreateResult ] );
958  return $canCreateResult;
959  }
960 
975  public static function createTagWithChecks( $tag, $reason, User $user,
976  $ignoreWarnings = false ) {
977 
978  // are we allowed to do this?
979  $result = self::canCreateTag( $tag, $user );
980  if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
981  $result->value = null;
982  return $result;
983  }
984 
985  // do it!
986  self::defineTag( $tag );
987 
988  // log it
989  $logId = self::logTagManagementAction( 'create', $tag, $reason, $user );
990  return Status::newGood( $logId );
991  }
992 
1005  public static function deleteTagEverywhere( $tag ) {
1006  $dbw = wfGetDB( DB_MASTER );
1007  $dbw->startAtomic( __METHOD__ );
1008 
1009  // delete from valid_tag
1010  self::undefineTag( $tag );
1011 
1012  // find out which revisions use this tag, so we can delete from tag_summary
1013  $result = $dbw->select( 'change_tag',
1014  [ 'ct_rc_id', 'ct_log_id', 'ct_rev_id', 'ct_tag' ],
1015  [ 'ct_tag' => $tag ],
1016  __METHOD__ );
1017  foreach ( $result as $row ) {
1018  // remove the tag from the relevant row of tag_summary
1019  $tagsToAdd = [];
1020  $tagsToRemove = [ $tag ];
1021  self::updateTagSummaryRow( $tagsToAdd, $tagsToRemove, $row->ct_rc_id,
1022  $row->ct_rev_id, $row->ct_log_id );
1023  }
1024 
1025  // delete from change_tag
1026  $dbw->delete( 'change_tag', [ 'ct_tag' => $tag ], __METHOD__ );
1027 
1028  $dbw->endAtomic( __METHOD__ );
1029 
1030  // give extensions a chance
1032  Hooks::run( 'ChangeTagAfterDelete', [ $tag, &$status ] );
1033  // let's not allow error results, as the actual tag deletion succeeded
1034  if ( !$status->isOK() ) {
1035  wfDebug( 'ChangeTagAfterDelete error condition downgraded to warning' );
1036  $status->ok = true;
1037  }
1038 
1039  // clear the memcache of defined tags
1040  self::purgeTagCacheAll();
1041 
1042  return $status;
1043  }
1044 
1054  public static function canDeleteTag( $tag, User $user = null ) {
1055  $tagUsage = self::tagUsageStatistics();
1056 
1057  if ( !is_null( $user ) ) {
1058  if ( !$user->isAllowed( 'managechangetags' ) ) {
1059  return Status::newFatal( 'tags-manage-no-permission' );
1060  } elseif ( $user->isBlocked() ) {
1061  return Status::newFatal( 'tags-manage-blocked' );
1062  }
1063  }
1064 
1065  if ( !isset( $tagUsage[$tag] ) && !in_array( $tag, self::listDefinedTags() ) ) {
1066  return Status::newFatal( 'tags-delete-not-found', $tag );
1067  }
1068 
1069  if ( isset( $tagUsage[$tag] ) && $tagUsage[$tag] > self::MAX_DELETE_USES ) {
1070  return Status::newFatal( 'tags-delete-too-many-uses', $tag, self::MAX_DELETE_USES );
1071  }
1072 
1073  $extensionDefined = self::listExtensionDefinedTags();
1074  if ( in_array( $tag, $extensionDefined ) ) {
1075  // extension-defined tags can't be deleted unless the extension
1076  // specifically allows it
1077  $status = Status::newFatal( 'tags-delete-not-allowed' );
1078  } else {
1079  // user-defined tags are deletable unless otherwise specified
1081  }
1082 
1083  Hooks::run( 'ChangeTagCanDelete', [ $tag, $user, &$status ] );
1084  return $status;
1085  }
1086 
1102  public static function deleteTagWithChecks( $tag, $reason, User $user,
1103  $ignoreWarnings = false ) {
1104 
1105  // are we allowed to do this?
1106  $result = self::canDeleteTag( $tag, $user );
1107  if ( $ignoreWarnings ? !$result->isOK() : !$result->isGood() ) {
1108  $result->value = null;
1109  return $result;
1110  }
1111 
1112  // store the tag usage statistics
1113  $tagUsage = self::tagUsageStatistics();
1114  $hitcount = isset( $tagUsage[$tag] ) ? $tagUsage[$tag] : 0;
1115 
1116  // do it!
1117  $deleteResult = self::deleteTagEverywhere( $tag );
1118  if ( !$deleteResult->isOK() ) {
1119  return $deleteResult;
1120  }
1121 
1122  // log it
1123  $logId = self::logTagManagementAction( 'delete', $tag, $reason, $user, $hitcount );
1124  $deleteResult->value = $logId;
1125  return $deleteResult;
1126  }
1127 
1134  public static function listExtensionActivatedTags() {
1135  return ObjectCache::getMainWANInstance()->getWithSetCallback(
1136  wfMemcKey( 'active-tags' ),
1137  300,
1138  function ( $oldValue, &$ttl, array &$setOpts ) {
1139  $setOpts += Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) );
1140 
1141  // Ask extensions which tags they consider active
1142  $extensionActive = [];
1143  Hooks::run( 'ChangeTagsListActive', [ &$extensionActive ] );
1144  return $extensionActive;
1145  },
1146  [
1147  'checkKeys' => [ wfMemcKey( 'active-tags' ) ],
1148  'lockTSE' => 300,
1149  'pcTTL' => 30
1150  ]
1151  );
1152  }
1153 
1161  public static function listDefinedTags() {
1162  $tags1 = self::listExplicitlyDefinedTags();
1163  $tags2 = self::listExtensionDefinedTags();
1164  return array_values( array_unique( array_merge( $tags1, $tags2 ) ) );
1165  }
1166 
1177  public static function listExplicitlyDefinedTags() {
1178  $fname = __METHOD__;
1179 
1180  return ObjectCache::getMainWANInstance()->getWithSetCallback(
1181  wfMemcKey( 'valid-tags-db' ),
1182  300,
1183  function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
1184  $dbr = wfGetDB( DB_SLAVE );
1185 
1186  $setOpts += Database::getCacheSetOptions( $dbr );
1187 
1188  $tags = $dbr->selectFieldValues( 'valid_tag', 'vt_tag', [], $fname );
1189 
1190  return array_filter( array_unique( $tags ) );
1191  },
1192  [
1193  'checkKeys' => [ wfMemcKey( 'valid-tags-db' ) ],
1194  'lockTSE' => 300,
1195  'pcTTL' => 30
1196  ]
1197  );
1198  }
1199 
1209  public static function listExtensionDefinedTags() {
1210  return ObjectCache::getMainWANInstance()->getWithSetCallback(
1211  wfMemcKey( 'valid-tags-hook' ),
1212  300,
1213  function ( $oldValue, &$ttl, array &$setOpts ) {
1214  $setOpts += Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) );
1215 
1216  $tags = [];
1217  Hooks::run( 'ListDefinedTags', [ &$tags ] );
1218  return array_filter( array_unique( $tags ) );
1219  },
1220  [
1221  'checkKeys' => [ wfMemcKey( 'valid-tags-hook' ) ],
1222  'lockTSE' => 300,
1223  'pcTTL' => 30
1224  ]
1225  );
1226  }
1227 
1233  public static function purgeTagCacheAll() {
1235 
1236  $cache->touchCheckKey( wfMemcKey( 'active-tags' ) );
1237  $cache->touchCheckKey( wfMemcKey( 'valid-tags-db' ) );
1238  $cache->touchCheckKey( wfMemcKey( 'valid-tags-hook' ) );
1239 
1240  self::purgeTagUsageCache();
1241  }
1242 
1247  public static function purgeTagUsageCache() {
1249 
1250  $cache->touchCheckKey( wfMemcKey( 'change-tag-statistics' ) );
1251  }
1252 
1263  public static function tagUsageStatistics() {
1264  $fname = __METHOD__;
1265  return ObjectCache::getMainWANInstance()->getWithSetCallback(
1266  wfMemcKey( 'change-tag-statistics' ),
1267  300,
1268  function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
1269  $dbr = wfGetDB( DB_SLAVE, 'vslow' );
1270 
1271  $setOpts += Database::getCacheSetOptions( $dbr );
1272 
1273  $res = $dbr->select(
1274  'change_tag',
1275  [ 'ct_tag', 'hitcount' => 'count(*)' ],
1276  [],
1277  $fname,
1278  [ 'GROUP BY' => 'ct_tag', 'ORDER BY' => 'hitcount DESC' ]
1279  );
1280 
1281  $out = [];
1282  foreach ( $res as $row ) {
1283  $out[$row->ct_tag] = $row->hitcount;
1284  }
1285 
1286  return $out;
1287  },
1288  [
1289  'checkKeys' => [ wfMemcKey( 'change-tag-statistics' ) ],
1290  'lockTSE' => 300,
1291  'pcTTL' => 30
1292  ]
1293  );
1294  }
1295 
1310  public static function showTagEditingUI( User $user ) {
1311  return $user->isAllowed( 'changetags' ) && (bool)self::listExplicitlyDefinedTags();
1312  }
1313 }
static getMainWANInstance()
Get the main WAN cache object.
static listDefinedTags()
Basically lists defined tags which count even if they aren't applied to anything. ...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition: hooks.txt:1798
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
Interface for objects which can provide a MediaWiki context on request.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
static canActivateTag($tag, User $user=null)
Is it OK to allow the user to activate this tag?
Definition: ChangeTags.php:796
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:762
the array() calling protocol came about after MediaWiki 1.4rc1.
static buildTagFilterSelector($selected= '', $fullForm=false, Title $title=null, $ooui=false)
Build a text box to select a change tag.
Definition: ChangeTags.php:662
$context
Definition: load.php:44
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:75
pingLimiter($action= 'edit', $incrBy=1)
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.
Definition: User.php:1778
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
Definition: Html.php:210
static createTagWithChecks($tag, $reason, User $user, $ignoreWarnings=false)
Creates a tag by adding a row to the valid_tag table.
Definition: ChangeTags.php:975
if(!isset($args[0])) $lang
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:759
static input($name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
Definition: Xml.php:275
static escapeClass($class)
Given a value, escape it so that it can be used as a CSS class and return it.
Definition: Sanitizer.php:1208
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the valid_tag table of the database.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:277
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?
Definition: ChangeTags.php:449
Represents a title within MediaWiki.
Definition: Title.php:34
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
static newFatal($message)
Factory function for fatal errors.
Definition: Status.php:89
static deleteTagEverywhere($tag)
Permanently removes all traces of a tag from the DB.
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.
Definition: ChangeTags.php:301
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
Definition: hooks.txt:965
static undefineTag($tag)
Removes a tag from the valid_tag table.
Definition: ChangeTags.php:743
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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':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:1796
static tagDescription($tag)
Get a short description for a tag.
Definition: ChangeTags.php:99
static getMain()
Static methods.
static formatSummaryRow($tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
Definition: ChangeTags.php:45
isAllowed($action= '')
Internal mechanics of testing a permission.
Definition: User.php:3410
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:1004
static canDeactivateTag($tag, User $user=null)
Is it OK to allow the user to deactivate this tag?
Definition: ChangeTags.php:864
$res
Definition: database.txt:21
const MAX_DELETE_USES
Can't delete tags with more than this many uses.
Definition: ChangeTags.php:30
static restrictedTagError($msgOne, $msgMulti, $tags)
Helper function to generate a fatal status with a 'not-allowed' type error.
Definition: ChangeTags.php:361
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing 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 unsetoffset-wrap String Wrap the message in html(usually something like"&lt
$cache
Definition: mcc.php:33
$params
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 makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:548
static purgeTagUsageCache()
Invalidates the tag statistics cache only.
const DB_SLAVE
Definition: Defines.php:46
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
static deactivateTagWithChecks($tag, $reason, User $user, $ignoreWarnings=false)
Deactivates a tag, checking whether it is allowed first, and adding a log entry afterwards.
Definition: ChangeTags.php:896
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
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:965
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:1584
static getCacheSetOptions(IDatabase $db1)
Merge the result of getSessionLagStatus() for several DBs using the most pessimistic values to estima...
Definition: Database.php:2904
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
const NS_MEDIAWIKI
Definition: Defines.php:77
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:242
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...
Definition: ChangeTags.php:421
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag=false)
Applies all tags-related changes to a query.
Definition: ChangeTags.php:615
static newFromId($id, $flags=0)
Load a page revision from a given revision ID number.
Definition: Revision.php:99
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
static logTagManagementAction($action, $tag, $reason, User $user, $tagCount=null)
Writes a tag action into the tag management log.
Definition: ChangeTags.php:763
static tags($element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
Class for creating log entries manually, to inject them into the database.
Definition: LogEntry.php:394
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
Definition: Setup.php:35
static purgeTagCacheAll()
Invalidates the short-term cache of defined tags used by the list*DefinedTags functions, as well as the tag statistics cache.
static updateTags($tagsToAdd, $tagsToRemove, &$rc_id=null, &$rev_id=null, &$log_id=null, $params=null)
Add and remove tags to/from a change given its rc_id, rev_id and/or log_id, without verifying that th...
Definition: ChangeTags.php:160
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:1004
$count
static addTags($tags, $rc_id=null, $rev_id=null, $log_id=null, $params=null)
Add tags to a change given its rc_id, rev_id and/or log_id.
Definition: ChangeTags.php:126
static canCreateTag($tag, User $user=null)
Is it OK to allow the user to create this tag?
Definition: ChangeTags.php:923
wfMemcKey()
Make a cache key for the local wiki.
const DB_MASTER
Definition: Defines.php:47
static listExtensionDefinedTags()
Lists tags defined by extensions using the ListDefinedTags hook.
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...
Definition: ChangeTags.php:378
static activateTagWithChecks($tag, $reason, User $user, $ignoreWarnings=false)
Activates a tag, checking whether it is allowed first, and adding a log entry afterwards.
Definition: ChangeTags.php:837
static defineTag($tag)
Defines a tag in the valid_tag table, without checking that the tag name is valid.
Definition: ChangeTags.php:724
static suggestTarget($target, array $ids)
if(is_null($wgLocalTZoffset)) if(!$wgDBerrorLogTZ) $wgRequest
Definition: Setup.php:657
static deleteTagWithChecks($tag, $reason, User $user, $ignoreWarnings=false)
Deletes a tag, checking whether it is allowed first, and adding a log entry afterwards.
static newGood($value=null)
Factory function for good results.
Definition: Status.php:101
static listExtensionActivatedTags()
Lists those tags which extensions report as being "active".
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, and adding a log entry afterwards.
Definition: ChangeTags.php:512
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:2338
static tagUsageStatistics()
Returns a map of any tags used on the wiki to number of edits tagged with them, ordered descending by...