MediaWiki  master
LogFormatter.php
Go to the documentation of this file.
1 <?php
29 
42 class LogFormatter {
43  // Audience options for viewing usernames, comments, and actions
44  public const FOR_PUBLIC = 1;
45  public const FOR_THIS_USER = 2;
46 
47  // Static->
48 
54  public static function newFromEntry( LogEntry $entry ) {
55  global $wgLogActionsHandlers;
56  $fulltype = $entry->getFullType();
57  $wildcard = $entry->getType() . '/*';
58  $handler = $wgLogActionsHandlers[$fulltype] ?? $wgLogActionsHandlers[$wildcard] ?? '';
59 
60  if ( $handler !== '' && is_string( $handler ) && class_exists( $handler ) ) {
61  return new $handler( $entry );
62  }
63 
64  return new LegacyLogFormatter( $entry );
65  }
66 
74  public static function newFromRow( $row ) {
76  }
77 
78  // Nonstatic->
79 
81  protected $entry;
82 
85 
87  public $context;
88 
90  protected $linkFlood = false;
91 
99  protected $plaintext = false;
100 
102  protected $irctext = false;
103 
107  private $linkRenderer;
108 
113  protected $parsedParameters;
114 
120  protected function __construct( LogEntry $entry ) {
121  $this->entry = $entry;
122  $this->context = RequestContext::getMain();
123  }
124 
129  public function setContext( IContextSource $context ) {
130  $this->context = $context;
131  }
132 
138  $this->linkRenderer = $linkRenderer;
139  }
140 
145  public function getLinkRenderer() {
146  if ( $this->linkRenderer !== null ) {
147  return $this->linkRenderer;
148  } else {
149  return MediaWikiServices::getInstance()->getLinkRenderer();
150  }
151  }
152 
159  public function setAudience( $audience ) {
160  $this->audience = ( $audience == self::FOR_THIS_USER )
161  ? self::FOR_THIS_USER
162  : self::FOR_PUBLIC;
163  }
164 
169  public function canViewLogType() {
170  // If the user doesn't have the right permission to view the specific
171  // log type, return false
172  $logRestrictions = $this->context->getConfig()->get( 'LogRestrictions' );
173  $type = $this->entry->getType();
174  return !isset( $logRestrictions[$type] )
175  || $this->context->getAuthority()->isAllowed( $logRestrictions[$type] );
176  }
177 
183  protected function canView( $field ) {
184  if ( $this->audience == self::FOR_THIS_USER ) {
186  $this->entry->getDeleted(), $field, $this->context->getUser() ) &&
188  } else {
189  return !$this->entry->isDeleted( $field ) && self::canViewLogType();
190  }
191  }
192 
199  public function setShowUserToolLinks( $value ) {
200  $this->linkFlood = $value;
201  }
202 
211  public function getPlainActionText() {
212  $this->plaintext = true;
213  $text = $this->getActionText();
214  $this->plaintext = false;
215 
216  return $text;
217  }
218 
225  public function getIRCActionComment() {
226  $actionComment = $this->getIRCActionText();
227  $comment = $this->entry->getComment();
228 
229  if ( $comment != '' ) {
230  if ( $actionComment == '' ) {
231  $actionComment = $comment;
232  } else {
233  $actionComment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $comment;
234  }
235  }
236 
237  return $actionComment;
238  }
239 
247  public function getIRCActionText() {
248  $this->plaintext = true;
249  $this->irctext = true;
250 
252  $parameters = $entry->getParameters();
253  // @see LogPage::actionText()
254  // Text of title the action is aimed at.
255  $target = $entry->getTarget()->getPrefixedText();
256  $text = null;
257  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
258  switch ( $entry->getType() ) {
259  case 'move':
260  switch ( $entry->getSubtype() ) {
261  case 'move':
262  $movesource = $parameters['4::target'];
263  $text = wfMessage( '1movedto2' )
264  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
265  break;
266  case 'move_redir':
267  $movesource = $parameters['4::target'];
268  $text = wfMessage( '1movedto2_redir' )
269  ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
270  break;
271  case 'move-noredirect':
272  break;
273  case 'move_redir-noredirect':
274  break;
275  }
276  break;
277 
278  case 'delete':
279  switch ( $entry->getSubtype() ) {
280  case 'delete':
281  $text = wfMessage( 'deletedarticle' )
282  ->rawParams( $target )->inContentLanguage()->escaped();
283  break;
284  case 'restore':
285  $text = wfMessage( 'undeletedarticle' )
286  ->rawParams( $target )->inContentLanguage()->escaped();
287  break;
288  }
289  break;
290 
291  case 'patrol':
292  // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff
293  // Create a diff link to the patrolled revision
294  if ( $entry->getSubtype() === 'patrol' ) {
295  $diffLink = htmlspecialchars(
296  wfMessage( 'patrol-log-diff', $parameters['4::curid'] )
297  ->inContentLanguage()->text() );
298  $text = wfMessage( 'patrol-log-line', $diffLink, "[[$target]]", "" )
299  ->inContentLanguage()->text();
300  } else {
301  // broken??
302  }
303  break;
304 
305  case 'protect':
306  switch ( $entry->getSubtype() ) {
307  case 'protect':
308  $text = wfMessage( 'protectedarticle' )
309  ->rawParams( $target . ' ' . $parameters['4::description'] )
310  ->inContentLanguage()
311  ->escaped();
312  break;
313  case 'unprotect':
314  $text = wfMessage( 'unprotectedarticle' )
315  ->rawParams( $target )->inContentLanguage()->escaped();
316  break;
317  case 'modify':
318  $text = wfMessage( 'modifiedarticleprotection' )
319  ->rawParams( $target . ' ' . $parameters['4::description'] )
320  ->inContentLanguage()
321  ->escaped();
322  break;
323  case 'move_prot':
324  $text = wfMessage( 'movedarticleprotection' )
325  ->rawParams( $target, $parameters['4::oldtitle'] )->inContentLanguage()->escaped();
326  break;
327  }
328  break;
329 
330  case 'newusers':
331  switch ( $entry->getSubtype() ) {
332  case 'newusers':
333  case 'create':
334  $text = wfMessage( 'newuserlog-create-entry' )
335  ->inContentLanguage()->escaped();
336  break;
337  case 'create2':
338  case 'byemail':
339  $text = wfMessage( 'newuserlog-create2-entry' )
340  ->rawParams( $target )->inContentLanguage()->escaped();
341  break;
342  case 'autocreate':
343  $text = wfMessage( 'newuserlog-autocreate-entry' )
344  ->inContentLanguage()->escaped();
345  break;
346  }
347  break;
348 
349  case 'upload':
350  switch ( $entry->getSubtype() ) {
351  case 'upload':
352  $text = wfMessage( 'uploadedimage' )
353  ->rawParams( $target )->inContentLanguage()->escaped();
354  break;
355  case 'overwrite':
356  case 'revert':
357  $text = wfMessage( 'overwroteimage' )
358  ->rawParams( $target )->inContentLanguage()->escaped();
359  break;
360  }
361  break;
362 
363  case 'rights':
364  if ( count( $parameters['4::oldgroups'] ) ) {
365  $oldgroups = implode( ', ', $parameters['4::oldgroups'] );
366  } else {
367  $oldgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
368  }
369  if ( count( $parameters['5::newgroups'] ) ) {
370  $newgroups = implode( ', ', $parameters['5::newgroups'] );
371  } else {
372  $newgroups = wfMessage( 'rightsnone' )->inContentLanguage()->escaped();
373  }
374  switch ( $entry->getSubtype() ) {
375  case 'rights':
376  $text = wfMessage( 'rightslogentry' )
377  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
378  break;
379  case 'autopromote':
380  $text = wfMessage( 'rightslogentry-autopromote' )
381  ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
382  break;
383  }
384  break;
385 
386  case 'merge':
387  $text = wfMessage( 'pagemerge-logentry' )
388  ->rawParams( $target, $parameters['4::dest'], $parameters['5::mergepoint'] )
389  ->inContentLanguage()->escaped();
390  break;
391 
392  case 'block':
393  switch ( $entry->getSubtype() ) {
394  case 'block':
395  // Keep compatibility with extensions by checking for
396  // new key (5::duration/6::flags) or old key (0/optional 1)
397  if ( $entry->isLegacy() ) {
398  $rawDuration = $parameters[0];
399  $rawFlags = $parameters[1] ?? '';
400  } else {
401  $rawDuration = $parameters['5::duration'];
402  $rawFlags = $parameters['6::flags'];
403  }
404  $duration = $contLang->translateBlockExpiry(
405  $rawDuration,
406  null,
407  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
408  );
409  $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
410  $text = wfMessage( 'blocklogentry' )
411  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
412  break;
413  case 'unblock':
414  $text = wfMessage( 'unblocklogentry' )
415  ->rawParams( $target )->inContentLanguage()->escaped();
416  break;
417  case 'reblock':
418  $duration = $contLang->translateBlockExpiry(
419  $parameters['5::duration'],
420  null,
421  wfTimestamp( TS_UNIX, $entry->getTimestamp() )
422  );
423  $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'],
424  $contLang );
425  $text = wfMessage( 'reblock-logentry' )
426  ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
427  break;
428  }
429  break;
430 
431  case 'import':
432  switch ( $entry->getSubtype() ) {
433  case 'upload':
434  $text = wfMessage( 'import-logentry-upload' )
435  ->rawParams( $target )->inContentLanguage()->escaped();
436  break;
437  case 'interwiki':
438  $text = wfMessage( 'import-logentry-interwiki' )
439  ->rawParams( $target )->inContentLanguage()->escaped();
440  break;
441  }
442  break;
443  // case 'suppress' --private log -- aaron (so we know who to blame in a few years :-D)
444  // default:
445  }
446  if ( $text === null ) {
447  $text = $this->getPlainActionText();
448  }
449 
450  $this->plaintext = false;
451  $this->irctext = false;
452 
453  return $text;
454  }
455 
463  public function getActionText() {
464  if ( $this->canView( LogPage::DELETED_ACTION ) ) {
465  $element = $this->getActionMessage();
466  if ( $element instanceof Message ) {
467  $element = $this->plaintext ? $element->text() : $element->escaped();
468  }
469  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
470  $element = $this->styleRestricedElement( $element );
471  }
472  } else {
473  $sep = $this->msg( 'word-separator' );
474  $sep = $this->plaintext ? $sep->text() : $sep->escaped();
475  $performer = $this->getPerformerElement();
476  $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
477  }
478 
479  return $element;
480  }
481 
488  protected function getActionMessage() {
489  $message = $this->msg( $this->getMessageKey() );
490  $message->params( $this->getMessageParameters() );
491 
492  return $message;
493  }
494 
503  protected function getMessageKey() {
504  $type = $this->entry->getType();
505  $subtype = $this->entry->getSubtype();
506 
507  return "logentry-$type-$subtype";
508  }
509 
516  public function getActionLinks() {
517  return '';
518  }
519 
526  protected function extractParameters() {
528  $params = [];
529 
530  if ( $entry->isLegacy() ) {
531  foreach ( $entry->getParameters() as $index => $value ) {
532  $params[$index + 3] = $value;
533  }
534  }
535 
536  // Filter out parameters which are not in format #:foo
537  foreach ( $entry->getParameters() as $key => $value ) {
538  if ( strpos( $key, ':' ) === false ) {
539  continue;
540  }
541  list( $index, $type, ) = explode( ':', $key, 3 );
542  if ( ctype_digit( $index ) ) {
543  $params[$index - 1] = $this->formatParameterValue( $type, $value );
544  }
545  }
546 
547  /* Message class doesn't like non consecutive numbering.
548  * Fill in missing indexes with empty strings to avoid
549  * incorrect renumbering.
550  */
551  if ( count( $params ) ) {
552  $max = max( array_keys( $params ) );
553  // index 0 to 2 are added in getMessageParameters
554  for ( $i = 3; $i < $max; $i++ ) {
555  if ( !isset( $params[$i] ) ) {
556  $params[$i] = '';
557  }
558  }
559  }
560 
561  return $params;
562  }
563 
574  protected function getMessageParameters() {
575  if ( isset( $this->parsedParameters ) ) {
577  }
578 
580  $params = $this->extractParameters();
581  $params[0] = Message::rawParam( $this->getPerformerElement() );
582  $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformerIdentity()->getName() : '';
583  $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
584 
585  // Bad things happens if the numbers are not in correct order
586  ksort( $params );
587 
588  $this->parsedParameters = $params;
590  }
591 
618  protected function formatParameterValue( $type, $value ) {
619  $saveLinkFlood = $this->linkFlood;
620 
621  switch ( strtolower( trim( $type ) ) ) {
622  case 'raw':
623  $value = Message::rawParam( $value );
624  break;
625  case 'list':
626  $value = $this->context->getLanguage()->commaList( $value );
627  break;
628  case 'msg':
629  $value = $this->msg( $value )->text();
630  break;
631  case 'msg-content':
632  $value = $this->msg( $value )->inContentLanguage()->text();
633  break;
634  case 'number':
635  $value = Message::numParam( $value );
636  break;
637  case 'user':
638  $user = User::newFromName( $value );
639  $value = $user->getName();
640  break;
641  case 'user-link':
642  $this->setShowUserToolLinks( false );
643 
644  $user = User::newFromName( $value );
645 
646  if ( !$user ) {
647  $value = $this->msg( 'empty-username' )->text();
648  } else {
649  $value = Message::rawParam( $this->makeUserLink( $user ) );
650  $this->setShowUserToolLinks( $saveLinkFlood );
651  }
652  break;
653  case 'title':
654  $title = Title::newFromText( $value );
655  $value = $title->getPrefixedText();
656  break;
657  case 'title-link':
658  $title = Title::newFromText( $value );
659  $value = Message::rawParam( $this->makePageLink( $title ) );
660  break;
661  case 'plain':
662  // Plain text, nothing to do
663  default:
664  // Catch other types and use the old behavior (return as-is)
665  }
666 
667  return $value;
668  }
669 
680  protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
681  if ( !$title instanceof Title ) {
682  $msg = $this->msg( 'invalidtitle' )->text();
683  if ( $this->plaintext ) {
684  return $msg;
685  } else {
686  return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
687  }
688  }
689 
690  if ( $this->plaintext ) {
691  $link = '[[' . $title->getPrefixedText() . ']]';
692  } else {
693  $html = $html !== null ? new HtmlArmor( $html ) : $html;
694  $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
695  }
696 
697  return $link;
698  }
699 
706  public function getPerformerElement() {
707  if ( $this->canView( LogPage::DELETED_USER ) ) {
708  $performerIdentity = $this->entry->getPerformerIdentity();
709  $element = $this->makeUserLink( $performerIdentity );
710  if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
711  $element = $this->styleRestricedElement( $element );
712  }
713  } else {
714  $element = $this->getRestrictedElement( 'rev-deleted-user' );
715  }
716 
717  return $element;
718  }
719 
725  public function getComment() {
726  if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
727  $comment = Linker::commentBlock( $this->entry->getComment() );
728  // No hard coded spaces thanx
729  $element = ltrim( $comment );
730  if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
731  $element = $this->styleRestricedElement( $element );
732  }
733  } else {
734  $element = $this->getRestrictedElement( 'rev-deleted-comment' );
735  }
736 
737  return $element;
738  }
739 
746  protected function getRestrictedElement( $message ) {
747  if ( $this->plaintext ) {
748  return $this->msg( $message )->text();
749  }
750 
751  $content = $this->msg( $message )->escaped();
752  $attribs = [ 'class' => 'history-deleted' ];
753 
754  return Html::rawElement( 'span', $attribs, $content );
755  }
756 
762  protected function styleRestricedElement( $content ) {
763  if ( $this->plaintext ) {
764  return $content;
765  }
766  $attribs = [ 'class' => 'history-deleted' ];
767 
768  return Html::rawElement( 'span', $attribs, $content );
769  }
770 
777  protected function msg( $key, ...$params ) {
778  return $this->context->msg( $key, ...$params );
779  }
780 
787  protected function makeUserLink( UserIdentity $user, $toolFlags = 0 ) {
788  if ( $this->plaintext ) {
789  $element = $user->getName();
790  } else {
791  $element = Linker::userLink(
792  $user->getId(),
793  $user->getName()
794  );
795  if ( $this->linkFlood ) {
796  $editCount = $user->isRegistered()
797  ? MediaWikiServices::getInstance()->getUserEditTracker()->getUserEditCount( $user )
798  : null;
799 
800  $element .= Linker::userToolLinks(
801  $user->getId(),
802  $user->getName(),
803  true, // redContribsWhenNoEdits
804  $toolFlags,
805  $editCount,
806  // do not render parenthesises in the HTML markup (CSS will provide)
807  false
808  );
809  }
810  }
811 
812  return $element;
813  }
814 
819  public function getPreloadTitles() {
820  return [];
821  }
822 
826  public function getMessageParametersForTesting() {
827  // This function was added because getMessageParameters() is
828  // protected and a change from protected to public caused
829  // problems with extensions
830  return $this->getMessageParameters();
831  }
832 
839  protected function getParametersForApi() {
840  return $this->entry->getParameters();
841  }
842 
858  public function formatParametersForApi() {
859  $logParams = [];
860  foreach ( $this->getParametersForApi() as $key => $value ) {
861  $vals = explode( ':', $key, 3 );
862  if ( count( $vals ) !== 3 ) {
863  if ( $value instanceof __PHP_Incomplete_Class ) {
864  wfLogWarning( 'Log entry of type ' . $this->entry->getFullType() .
865  ' contains unrecoverable extra parameters.' );
866  continue;
867  }
868  $logParams[$key] = $value;
869  continue;
870  }
871  $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
872  }
873  ApiResult::setIndexedTagName( $logParams, 'param' );
874  ApiResult::setArrayType( $logParams, 'assoc' );
875 
876  return $logParams;
877  }
878 
888  protected function formatParameterValueForApi( $name, $type, $value ) {
889  $type = strtolower( trim( $type ) );
890  switch ( $type ) {
891  case 'bool':
892  $value = (bool)$value;
893  break;
894 
895  case 'number':
896  if ( ctype_digit( $value ) || is_int( $value ) ) {
897  $value = (int)$value;
898  } else {
899  $value = (float)$value;
900  }
901  break;
902 
903  case 'array':
904  case 'assoc':
905  case 'kvp':
906  if ( is_array( $value ) ) {
907  ApiResult::setArrayType( $value, $type );
908  }
909  break;
910 
911  case 'timestamp':
912  $value = wfTimestamp( TS_ISO_8601, $value );
913  break;
914 
915  case 'msg':
916  case 'msg-content':
917  $msg = $this->msg( $value );
918  if ( $type === 'msg-content' ) {
919  $msg->inContentLanguage();
920  }
921  $value = [];
922  $value["{$name}_key"] = $msg->getKey();
923  if ( $msg->getParams() ) {
924  $value["{$name}_params"] = $msg->getParams();
925  }
926  $value["{$name}_text"] = $msg->text();
927  return $value;
928 
929  case 'title':
930  case 'title-link':
931  $title = Title::newFromText( $value );
932  if ( !$title ) {
933  // Huh? Do something halfway sane.
934  $title = SpecialPage::getTitleFor( 'Badtitle', $value );
935  }
936  $value = [];
937  ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" );
938  return $value;
939 
940  case 'user':
941  case 'user-link':
942  $user = User::newFromName( $value );
943  if ( $user ) {
944  $value = $user->getName();
945  }
946  break;
947 
948  default:
949  // do nothing
950  break;
951  }
952 
953  return [ $name => $value ];
954  }
955 }
Message\numParam
static numParam( $num)
Definition: Message.php:1038
LogFormatter\FOR_THIS_USER
const FOR_THIS_USER
Definition: LogFormatter.php:45
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:363
LogFormatter\setAudience
setAudience( $audience)
Set the visibility restrictions for displaying content.
Definition: LogFormatter.php:159
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
LogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: LogFormatter.php:516
LogFormatter\getPlainActionText
getPlainActionText()
Ugly hack to produce plaintext version of the message.
Definition: LogFormatter.php:211
LogEntry\getTimestamp
getTimestamp()
Get the timestamp when the action was executed.
Linker\userLink
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:897
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:173
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
LogFormatter\FOR_PUBLIC
const FOR_PUBLIC
Definition: LogFormatter.php:44
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:41
LogFormatter\$entry
LogEntryBase $entry
Definition: LogFormatter.php:81
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1832
LogEntryBase\isLegacy
isLegacy()
Whether the parameters for this log are stored in new or old format.
Definition: LogEntryBase.php:47
Linker\userToolLinks
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition: Linker.php:942
LogEntry\getTarget
getTarget()
Get the target page of this action.
LogEventsList\userCanBitfield
static userCanBitfield( $bitfield, $field, Authority $performer)
Determine if the current user is allowed to view a particular field of this log row,...
Definition: LogEventsList.php:540
LogFormatter\getIRCActionComment
getIRCActionComment()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition: LogFormatter.php:225
LogFormatter\getParametersForApi
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
Definition: LogFormatter.php:839
LogFormatter\$audience
int $audience
Constant for handling log_deleted.
Definition: LogFormatter.php:84
LogFormatter\canView
canView( $field)
Check if a log item can be displayed.
Definition: LogFormatter.php:183
User\newFromName
static newFromName( $name, $validate='valid')
Definition: User.php:586
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1231
SpecialPage\getTitleFor
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,...
Definition: SpecialPage.php:107
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1094
MediaWiki\User\UserIdentity\getId
getId( $wikiId=self::LOCAL)
LogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Definition: LogFormatter.php:574
LogFormatter\$plaintext
string $plaintext
Set to true if we are constructing a message text that is going to be included in page history or sen...
Definition: LogFormatter.php:99
LogFormatter\setContext
setContext(IContextSource $context)
Replace the default context.
Definition: LogFormatter.php:129
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:39
LogEntry\getType
getType()
The main log type.
LogFormatter\getComment
getComment()
Gets the user provided comment.
Definition: LogFormatter.php:725
LogFormatter\getPerformerElement
getPerformerElement()
Provides the name of the user who performed the log action.
Definition: LogFormatter.php:706
LogFormatter\__construct
__construct(LogEntry $entry)
Definition: LogFormatter.php:120
ApiResult\setArrayType
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
Definition: ApiResult.php:719
DatabaseLogEntry\newFromRow
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition: DatabaseLogEntry.php:81
LogPage\DELETED_COMMENT
const DELETED_COMMENT
Definition: LogPage.php:39
LogEntry\getPerformerIdentity
getPerformerIdentity()
LogFormatter\newFromRow
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Definition: LogFormatter.php:74
MediaWiki\User\UserIdentity\isRegistered
isRegistered()
LogEntry
Interface for log entries.
Definition: LogEntry.php:34
LogPage\DELETED_USER
const DELETED_USER
Definition: LogPage.php:40
LogFormatter\getMessageParametersForTesting
getMessageParametersForTesting()
Definition: LogFormatter.php:826
MediaWiki\User\UserIdentity\getName
getName()
$title
$title
Definition: testCompression.php:38
LogFormatter\getIRCActionText
getIRCActionText()
Even uglier hack to maintain backwards compatibility with IRC bots (T36508).
Definition: LogFormatter.php:247
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:38
LogFormatter\styleRestricedElement
styleRestricedElement( $content)
Helper method for styling restricted element.
Definition: LogFormatter.php:762
LogEntryBase
Extends the LogEntry Interface with some basic functionality.
Definition: LogEntryBase.php:31
LogFormatter\formatParameterValue
formatParameterValue( $type, $value)
Formats parameters values dependent to their type.
Definition: LogFormatter.php:618
LogFormatter\formatParameterValueForApi
formatParameterValueForApi( $name, $type, $value)
Format a single parameter value for API output.
Definition: LogFormatter.php:888
ApiResult\setIndexedTagName
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:607
$content
$content
Definition: router.php:76
LogFormatter\formatParametersForApi
formatParametersForApi()
Format parameters for API output.
Definition: LogFormatter.php:858
Linker\commentBlock
static commentBlock( $comment, $title=null, $local=false, $wikiId=null, $useParentheses=true)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
Definition: Linker.php:1566
Message\rawParam
static rawParam( $raw)
Definition: Message.php:1027
LogFormatter\setShowUserToolLinks
setShowUserToolLinks( $value)
If set to true, will produce user tool links after the user name.
Definition: LogFormatter.php:199
LogFormatter\setLinkRenderer
setLinkRenderer(LinkRenderer $linkRenderer)
Definition: LogFormatter.php:137
LogFormatter\$parsedParameters
array $parsedParameters
Definition: LogFormatter.php:113
LogFormatter\canViewLogType
canViewLogType()
Check if a log item type can be displayed.
Definition: LogFormatter.php:169
LogEntryBase\getFullType
getFullType()
The full logtype in format maintype/subtype.
Definition: LogEntryBase.php:33
LogFormatter\getActionText
getActionText()
Gets the log action, including username.
Definition: LogFormatter.php:463
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:476
$wgLogActionsHandlers
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
Definition: DefaultSettings.php:8331
LogFormatter\getActionMessage
getActionMessage()
Returns a sentence describing the log action.
Definition: LogFormatter.php:488
LogEntry\getSubtype
getSubtype()
The log subtype.
LogFormatter
Implements the default log formatting.
Definition: LogFormatter.php:42
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:57
BlockLogFormatter\formatBlockFlags
static formatBlockFlags( $flags, Language $lang)
Convert a comma-delimited list of block log flags into a more readable (and translated) form.
Definition: BlockLogFormatter.php:182
LogFormatter\getPreloadTitles
getPreloadTitles()
Definition: LogFormatter.php:819
Title
Represents a title within MediaWiki.
Definition: Title.php:46
LogFormatter\$linkRenderer
LinkRenderer null $linkRenderer
Definition: LogFormatter.php:107
LogFormatter\$linkFlood
bool $linkFlood
Whether to output user tool links.
Definition: LogFormatter.php:90
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:212
Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:161
LogFormatter\msg
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
Definition: LogFormatter.php:777
LogFormatter\getRestrictedElement
getRestrictedElement( $message)
Helper method for displaying restricted element.
Definition: LogFormatter.php:746
LogFormatter\$irctext
string $irctext
Definition: LogFormatter.php:102
LegacyLogFormatter
This class formats all log entries for log types which have not been converted to the new system.
Definition: LegacyLogFormatter.php:35
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:234
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition: LogFormatter.php:145
LogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition: LogFormatter.php:503
LogFormatter\$context
IContextSource $context
Context for logging.
Definition: LogFormatter.php:87
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition: LogFormatter.php:526
ApiQueryBase\addTitleInfo
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
Definition: ApiQueryBase.php:466
LogFormatter\makePageLink
makePageLink(Title $title=null, $parameters=[], $html=null)
Helper to make a link to the page, taking the plaintext value in consideration.
Definition: LogFormatter.php:680
LogFormatter\makeUserLink
makeUserLink(UserIdentity $user, $toolFlags=0)
Definition: LogFormatter.php:787
LogFormatter\newFromEntry
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
Definition: LogFormatter.php:54
$type
$type
Definition: testCompression.php:52