74 return MediaWikiServices::getInstance()->getLogFormatterFactory()->newFromEntry( $entry );
87 return self::newFromEntry( DatabaseLogEntry::newFromRow( $row ) );
117 private $linkRenderer;
120 private $contentLanguage;
123 private $commentFormatter;
126 private $userEditTracker;
140 $this->entry = $entry;
141 $this->context = RequestContext::getMain();
149 $this->context = $context;
157 $this->linkRenderer = $linkRenderer;
165 if ( $this->linkRenderer !==
null ) {
166 return $this->linkRenderer;
168 wfDeprecated( static::class .
" without all required services",
'1.42' );
169 return MediaWikiServices::getInstance()->getLinkRenderer();
179 $this->contentLanguage = $contentLanguage;
187 if ( $this->contentLanguage === null ) {
188 wfDeprecated( static::class .
" without all required services",
'1.42' );
189 $this->contentLanguage = MediaWikiServices::getInstance()->getContentLanguage();
191 return $this->contentLanguage;
200 $this->commentFormatter = $commentFormatter;
208 if ( $this->commentFormatter === null ) {
209 wfDeprecated( static::class .
" without all required services",
'1.42' );
210 $this->commentFormatter = MediaWikiServices::getInstance()->getCommentFormatter();
212 return $this->commentFormatter;
221 $this->userEditTracker = $userEditTracker;
229 if ( $this->userEditTracker === null ) {
230 wfDeprecated( static::class .
" without all required services",
'1.42' );
231 $this->userEditTracker = MediaWikiServices::getInstance()->getUserEditTracker();
233 return $this->userEditTracker;
243 $this->audience = ( $audience == self::FOR_THIS_USER )
244 ? self::FOR_THIS_USER
255 $logRestrictions = $this->context->getConfig()->get( MainConfigNames::LogRestrictions );
256 $type = $this->entry->getType();
257 return !isset( $logRestrictions[$type] )
258 || $this->context->getAuthority()->isAllowed( $logRestrictions[$type] );
267 if ( $this->audience == self::FOR_THIS_USER ) {
268 return LogEventsList::userCanBitfield(
269 $this->entry->getDeleted(), $field, $this->context->getAuthority() ) &&
270 self::canViewLogType();
272 return !$this->entry->isDeleted( $field ) && self::canViewLogType();
283 $this->linkFlood = $value;
295 $this->plaintext =
true;
296 $text = $this->getActionText();
297 $this->plaintext =
false;
309 $actionComment = $this->getIRCActionText();
310 $comment = $this->entry->getComment();
312 if ( $comment !=
'' ) {
313 if ( $actionComment ==
'' ) {
314 $actionComment = $comment;
316 $actionComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() . $comment;
320 return $actionComment;
331 $this->plaintext =
true;
332 $this->irctext =
true;
334 $entry = $this->entry;
335 $parameters = $entry->getParameters();
338 $target = $entry->getTarget()->getPrefixedText();
340 $contLang = $this->getContentLanguage();
341 switch ( $entry->getType() ) {
343 switch ( $entry->getSubtype() ) {
345 $movesource = $parameters[
'4::target'];
347 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
350 $movesource = $parameters[
'4::target'];
352 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
354 case 'move-noredirect':
356 case 'move_redir-noredirect':
362 switch ( $entry->getSubtype() ) {
365 ->rawParams( $target )->inContentLanguage()->escaped();
369 ->rawParams( $target )->inContentLanguage()->escaped();
377 if ( $entry->getSubtype() ===
'patrol' ) {
378 $diffLink = htmlspecialchars(
379 wfMessage(
'patrol-log-diff', $parameters[
'4::curid'] )
380 ->inContentLanguage()->text() );
381 $text =
wfMessage(
'patrol-log-line', $diffLink,
"[[$target]]",
"" )
382 ->inContentLanguage()->text();
389 switch ( $entry->getSubtype() ) {
392 ->rawParams( $target .
' ' . $parameters[
'4::description'] )
393 ->inContentLanguage()
397 $text =
wfMessage(
'unprotectedarticle' )
398 ->rawParams( $target )->inContentLanguage()->escaped();
401 $text =
wfMessage(
'modifiedarticleprotection' )
402 ->rawParams( $target .
' ' . $parameters[
'4::description'] )
403 ->inContentLanguage()
407 $text =
wfMessage(
'movedarticleprotection' )
408 ->rawParams( $target, $parameters[
'4::oldtitle'] )->inContentLanguage()->escaped();
414 switch ( $entry->getSubtype() ) {
417 $text =
wfMessage(
'newuserlog-create-entry' )
418 ->inContentLanguage()->escaped();
422 $text =
wfMessage(
'newuserlog-create2-entry' )
423 ->rawParams( $target )->inContentLanguage()->escaped();
426 $text =
wfMessage(
'newuserlog-autocreate-entry' )
427 ->inContentLanguage()->escaped();
433 switch ( $entry->getSubtype() ) {
436 ->rawParams( $target )->inContentLanguage()->escaped();
441 ->rawParams( $target )->inContentLanguage()->escaped();
447 if ( count( $parameters[
'4::oldgroups'] ) ) {
448 $oldgroups = implode(
', ', $parameters[
'4::oldgroups'] );
450 $oldgroups =
wfMessage(
'rightsnone' )->inContentLanguage()->escaped();
452 if ( count( $parameters[
'5::newgroups'] ) ) {
453 $newgroups = implode(
', ', $parameters[
'5::newgroups'] );
455 $newgroups =
wfMessage(
'rightsnone' )->inContentLanguage()->escaped();
457 switch ( $entry->getSubtype() ) {
460 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
463 $text =
wfMessage(
'rightslogentry-autopromote' )
464 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
470 $text =
wfMessage(
'pagemerge-logentry' )
471 ->rawParams( $target, $parameters[
'4::dest'], $parameters[
'5::mergepoint'] )
472 ->inContentLanguage()->escaped();
476 switch ( $entry->getSubtype() ) {
480 if ( $entry->isLegacy() ) {
481 $rawDuration = $parameters[0];
482 $rawFlags = $parameters[1] ??
'';
484 $rawDuration = $parameters[
'5::duration'];
485 $rawFlags = $parameters[
'6::flags'];
487 $duration = $contLang->translateBlockExpiry(
490 (
int)
wfTimestamp( TS_UNIX, $entry->getTimestamp() )
492 $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
494 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
498 ->rawParams( $target )->inContentLanguage()->escaped();
501 $duration = $contLang->translateBlockExpiry(
502 $parameters[
'5::duration'],
504 (
int)
wfTimestamp( TS_UNIX, $entry->getTimestamp() )
506 $flags = BlockLogFormatter::formatBlockFlags( $parameters[
'6::flags'],
509 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
515 switch ( $entry->getSubtype() ) {
517 $text =
wfMessage(
'import-logentry-upload' )
518 ->rawParams( $target )->inContentLanguage()->escaped();
521 $text =
wfMessage(
'import-logentry-interwiki' )
522 ->rawParams( $target )->inContentLanguage()->escaped();
530 $this->plaintext =
false;
531 $this->irctext =
false;
533 return $text ?? $this->getPlainActionText();
544 if ( $this->canView( LogPage::DELETED_ACTION ) ) {
545 $element = $this->getActionMessage();
546 if ( $element instanceof
Message ) {
547 $element = $this->plaintext ? $element->text() : $element->escaped();
549 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
550 $element = $this->styleRestrictedElement( $element );
553 $sep = $this->msg(
'word-separator' );
554 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
555 $performer = $this->getPerformerElement();
556 $element = $performer . $sep . $this->getRestrictedElement(
'rev-deleted-event' );
569 $message = $this->msg( $this->getMessageKey() );
570 $message->params( $this->getMessageParameters() );
584 $type = $this->entry->getType();
585 $subtype = $this->entry->getSubtype();
587 return "logentry-$type-$subtype";
607 $entry = $this->entry;
610 if ( $entry->isLegacy() ) {
611 foreach ( $entry->getParameters() as $index => $value ) {
617 foreach ( $entry->getParameters() as $key => $value ) {
618 if ( strpos( $key,
':' ) ===
false ) {
621 [ $index, $type, ] = explode(
':', $key, 3 );
622 if ( ctype_digit( $index ) ) {
623 $params[(int)$index - 1] = $this->formatParameterValue( $type, $value );
632 $max = max( array_keys(
$params ) );
634 for ( $i = 3; $i < $max; $i++ ) {
662 if ( isset( $this->parsedParameters ) ) {
663 return $this->parsedParameters;
666 $entry = $this->entry;
667 $params = $this->extractParameters();
668 $params[0] = Message::rawParam( $this->getPerformerElement() );
669 $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformerIdentity()->getName() :
'';
670 $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
675 $this->parsedParameters =
$params;
676 return $this->parsedParameters;
706 $saveLinkFlood = $this->linkFlood;
708 switch ( strtolower( trim( $type ) ) ) {
710 $value = Message::rawParam( $value );
713 $value = $this->context->getLanguage()->commaList( $value );
716 $value = $this->msg( $value )->text();
719 $value = $this->msg( $value )->inContentLanguage()->text();
722 $value = Message::numParam( $value );
725 $user = User::newFromName( $value );
726 $value = $user->getName();
729 $this->setShowUserToolLinks(
false );
731 $user = User::newFromName( $value );
734 $value = $this->msg(
'empty-username' )->text();
736 $value = Message::rawParam( $this->makeUserLink( $user ) );
737 $this->setShowUserToolLinks( $saveLinkFlood );
741 $title = Title::newFromText( $value );
742 $value = $title->getPrefixedText();
745 $title = Title::newFromText( $value );
746 $value = Message::rawParam( $this->makePageLink( $title ) );
768 if ( !$title instanceof
Title ) {
769 $msg = $this->msg(
'invalidtitle' )->text();
770 if ( $this->plaintext ) {
773 return Html::element(
'span', [
'class' =>
'mw-invalidtitle' ], $msg );
777 if ( $this->plaintext ) {
778 $link =
'[[' . $title->getPrefixedText() .
']]';
780 $html = $html !==
null ?
new HtmlArmor( $html ) : $html;
781 $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
794 if ( $this->canView( LogPage::DELETED_USER ) ) {
795 $performerIdentity = $this->entry->getPerformerIdentity();
796 $element = $this->makeUserLink( $performerIdentity );
797 if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
798 $element = $this->styleRestrictedElement( $element );
801 $element = $this->getRestrictedElement(
'rev-deleted-user' );
813 if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
814 $comment = $this->getCommentFormatter()
815 ->formatBlock( $this->entry->getComment() );
817 $element = ltrim( $comment );
818 if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
819 $element = $this->styleRestrictedElement( $element );
822 $element = $this->getRestrictedElement(
'rev-deleted-comment' );
835 if ( $this->plaintext ) {
836 return $this->msg( $message )->text();
839 return $this->styleRestrictedElement( $this->msg( $message )->escaped() );
848 if ( $this->plaintext ) {
851 $attribs = [
'class' => [
'history-deleted' ] ];
852 if ( $this->entry->isDeleted( LogPage::DELETED_RESTRICTED ) ) {
853 $attribs[
'class'][] =
'mw-history-suppressed';
856 return Html::rawElement(
'span', $attribs, $content );
868 return $this->context->msg( $key, ...
$params );
878 if ( $this->plaintext ) {
881 $element = Linker::userLink(
885 if ( $this->linkFlood ) {
886 $editCount = $this->getUserEditTracker()->getUserEditCount( $user );
888 $element .= Linker::userToolLinks(
918 return $this->getMessageParameters();
928 return $this->entry->getParameters();
948 foreach ( $this->getParametersForApi() as $key => $value ) {
949 $vals = explode(
':', $key, 3 );
950 if ( count( $vals ) !== 3 ) {
951 if ( $value instanceof __PHP_Incomplete_Class ) {
952 wfLogWarning(
'Log entry of type ' . $this->entry->getFullType() .
953 ' contains unrecoverable extra parameters.' );
956 $logParams[$key] = $value;
959 $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
961 ApiResult::setIndexedTagName( $logParams,
'param' );
962 ApiResult::setArrayType( $logParams,
'assoc' );
977 $type = strtolower( trim( $type ) );
980 $value = (bool)$value;
984 if ( is_int( $value ) || ctype_digit( (
string)$value ) ) {
985 $value = (int)$value;
987 $value = (float)$value;
994 if ( is_array( $value ) ) {
995 ApiResult::setArrayType( $value, $type );
1005 $msg = $this->msg( $value );
1006 if ( $type ===
'msg-content' ) {
1007 $msg->inContentLanguage();
1010 $value[
"{$name}_key"] = $msg->getKey();
1011 if ( $msg->getParams() ) {
1012 $value[
"{$name}_params"] = $msg->getParams();
1014 $value[
"{$name}_text"] = $msg->text();
1019 $title = Title::newFromText( $value );
1021 $title = SpecialPage::getTitleFor(
'Badtitle', $value );
1024 ApiQueryBase::addTitleInfo( $value, $title,
"{$name}_" );
1029 $user = User::newFromName( $value );
1031 $value = $user->getName();
1040 return [ $name => $value ];
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
array $params
The job parameters.
if(!defined('MW_SETUP_CALLBACK'))
Marks HTML that shouldn't be escaped.
Extends the LogEntry Interface with some basic functionality.
Group all the pieces relevant to the context of a request into one instance.
A class containing constants representing the names of configuration variables.
Parent class for all special pages.
Interface for objects which can provide a MediaWiki context on request.