69 return MediaWikiServices::getInstance()->getLogFormatterFactory()->newFromEntry( $entry );
82 return self::newFromEntry( DatabaseLogEntry::newFromRow( $row ) );
112 private $linkRenderer;
115 private $contentLanguage;
118 private $commentFormatter;
121 private $userEditTracker;
135 $this->entry = $entry;
136 $this->context = RequestContext::getMain();
144 $this->context = $context;
152 $this->linkRenderer = $linkRenderer;
160 if ( $this->linkRenderer !==
null ) {
161 return $this->linkRenderer;
163 wfDeprecated( static::class .
" without all required services",
'1.42' );
164 return MediaWikiServices::getInstance()->getLinkRenderer();
174 $this->contentLanguage = $contentLanguage;
182 if ( $this->contentLanguage === null ) {
183 wfDeprecated( static::class .
" without all required services",
'1.42' );
184 $this->contentLanguage = MediaWikiServices::getInstance()->getContentLanguage();
186 return $this->contentLanguage;
195 $this->commentFormatter = $commentFormatter;
203 if ( $this->commentFormatter === null ) {
204 wfDeprecated( static::class .
" without all required services",
'1.42' );
205 $this->commentFormatter = MediaWikiServices::getInstance()->getCommentFormatter();
207 return $this->commentFormatter;
216 $this->userEditTracker = $userEditTracker;
224 if ( $this->userEditTracker === null ) {
225 wfDeprecated( static::class .
" without all required services",
'1.42' );
226 $this->userEditTracker = MediaWikiServices::getInstance()->getUserEditTracker();
228 return $this->userEditTracker;
238 $this->audience = ( $audience == self::FOR_THIS_USER )
239 ? self::FOR_THIS_USER
250 $logRestrictions = $this->context->getConfig()->get( MainConfigNames::LogRestrictions );
251 $type = $this->entry->getType();
252 return !isset( $logRestrictions[$type] )
253 || $this->context->getAuthority()->isAllowed( $logRestrictions[$type] );
262 if ( $this->audience == self::FOR_THIS_USER ) {
263 return LogEventsList::userCanBitfield(
264 $this->entry->getDeleted(), $field, $this->context->getAuthority() ) &&
265 self::canViewLogType();
267 return !$this->entry->isDeleted( $field ) && self::canViewLogType();
278 $this->linkFlood = $value;
290 $this->plaintext =
true;
291 $text = $this->getActionText();
292 $this->plaintext =
false;
304 $actionComment = $this->getIRCActionText();
305 $comment = $this->entry->getComment();
307 if ( $comment !=
'' ) {
308 if ( $actionComment ==
'' ) {
309 $actionComment = $comment;
311 $actionComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() . $comment;
315 return $actionComment;
326 $this->plaintext =
true;
327 $this->irctext =
true;
329 $entry = $this->entry;
330 $parameters = $entry->getParameters();
333 $target = $entry->getTarget()->getPrefixedText();
335 $contLang = $this->getContentLanguage();
336 switch ( $entry->getType() ) {
338 switch ( $entry->getSubtype() ) {
340 $movesource = $parameters[
'4::target'];
342 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
345 $movesource = $parameters[
'4::target'];
347 ->rawParams( $target, $movesource )->inContentLanguage()->escaped();
349 case 'move-noredirect':
351 case 'move_redir-noredirect':
357 switch ( $entry->getSubtype() ) {
360 ->rawParams( $target )->inContentLanguage()->escaped();
364 ->rawParams( $target )->inContentLanguage()->escaped();
372 if ( $entry->getSubtype() ===
'patrol' ) {
373 $diffLink = htmlspecialchars(
374 wfMessage(
'patrol-log-diff', $parameters[
'4::curid'] )
375 ->inContentLanguage()->text() );
376 $text =
wfMessage(
'patrol-log-line', $diffLink,
"[[$target]]",
"" )
377 ->inContentLanguage()->text();
384 switch ( $entry->getSubtype() ) {
387 ->rawParams( $target .
' ' . $parameters[
'4::description'] )
388 ->inContentLanguage()
392 $text =
wfMessage(
'unprotectedarticle' )
393 ->rawParams( $target )->inContentLanguage()->escaped();
396 $text =
wfMessage(
'modifiedarticleprotection' )
397 ->rawParams( $target .
' ' . $parameters[
'4::description'] )
398 ->inContentLanguage()
402 $text =
wfMessage(
'movedarticleprotection' )
403 ->rawParams( $target, $parameters[
'4::oldtitle'] )->inContentLanguage()->escaped();
409 switch ( $entry->getSubtype() ) {
412 $text =
wfMessage(
'newuserlog-create-entry' )
413 ->inContentLanguage()->escaped();
417 $text =
wfMessage(
'newuserlog-create2-entry' )
418 ->rawParams( $target )->inContentLanguage()->escaped();
421 $text =
wfMessage(
'newuserlog-autocreate-entry' )
422 ->inContentLanguage()->escaped();
428 switch ( $entry->getSubtype() ) {
431 ->rawParams( $target )->inContentLanguage()->escaped();
436 ->rawParams( $target )->inContentLanguage()->escaped();
442 if ( count( $parameters[
'4::oldgroups'] ) ) {
443 $oldgroups = implode(
', ', $parameters[
'4::oldgroups'] );
445 $oldgroups =
wfMessage(
'rightsnone' )->inContentLanguage()->escaped();
447 if ( count( $parameters[
'5::newgroups'] ) ) {
448 $newgroups = implode(
', ', $parameters[
'5::newgroups'] );
450 $newgroups =
wfMessage(
'rightsnone' )->inContentLanguage()->escaped();
452 switch ( $entry->getSubtype() ) {
455 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
458 $text =
wfMessage(
'rightslogentry-autopromote' )
459 ->rawParams( $target, $oldgroups, $newgroups )->inContentLanguage()->escaped();
465 $text =
wfMessage(
'pagemerge-logentry' )
466 ->rawParams( $target, $parameters[
'4::dest'], $parameters[
'5::mergepoint'] )
467 ->inContentLanguage()->escaped();
471 switch ( $entry->getSubtype() ) {
475 if ( $entry->isLegacy() ) {
476 $rawDuration = $parameters[0];
477 $rawFlags = $parameters[1] ??
'';
479 $rawDuration = $parameters[
'5::duration'];
480 $rawFlags = $parameters[
'6::flags'];
482 $duration = $contLang->translateBlockExpiry(
485 (
int)
wfTimestamp( TS_UNIX, $entry->getTimestamp() )
487 $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
489 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
493 ->rawParams( $target )->inContentLanguage()->escaped();
496 $duration = $contLang->translateBlockExpiry(
497 $parameters[
'5::duration'],
499 (
int)
wfTimestamp( TS_UNIX, $entry->getTimestamp() )
501 $flags = BlockLogFormatter::formatBlockFlags( $parameters[
'6::flags'],
504 ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
510 switch ( $entry->getSubtype() ) {
512 $text =
wfMessage(
'import-logentry-upload' )
513 ->rawParams( $target )->inContentLanguage()->escaped();
516 $text =
wfMessage(
'import-logentry-interwiki' )
517 ->rawParams( $target )->inContentLanguage()->escaped();
525 $this->plaintext =
false;
526 $this->irctext =
false;
528 return $text ?? $this->getPlainActionText();
539 if ( $this->canView( LogPage::DELETED_ACTION ) ) {
540 $element = $this->getActionMessage();
541 if ( $element instanceof
Message ) {
542 $element = $this->plaintext ? $element->text() : $element->escaped();
544 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) ) {
545 $element = $this->styleRestrictedElement( $element );
548 $sep = $this->msg(
'word-separator' );
549 $sep = $this->plaintext ? $sep->text() : $sep->escaped();
550 $performer = $this->getPerformerElement();
551 $element = $performer . $sep . $this->getRestrictedElement(
'rev-deleted-event' );
564 $message = $this->msg( $this->getMessageKey() );
565 $message->params( $this->getMessageParameters() );
579 $type = $this->entry->getType();
580 $subtype = $this->entry->getSubtype();
582 return "logentry-$type-$subtype";
602 $entry = $this->entry;
605 if ( $entry->isLegacy() ) {
606 foreach ( $entry->getParameters() as $index => $value ) {
612 foreach ( $entry->getParameters() as $key => $value ) {
613 if ( strpos( $key,
':' ) ===
false ) {
616 [ $index, $type, ] = explode(
':', $key, 3 );
617 if ( ctype_digit( $index ) ) {
618 $params[(int)$index - 1] = $this->formatParameterValue( $type, $value );
627 $max = max( array_keys(
$params ) );
629 for ( $i = 3; $i < $max; $i++ ) {
657 if ( isset( $this->parsedParameters ) ) {
658 return $this->parsedParameters;
661 $entry = $this->entry;
662 $params = $this->extractParameters();
663 $params[0] = Message::rawParam( $this->getPerformerElement() );
664 $params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformerIdentity()->getName() :
'';
665 $params[2] = Message::rawParam( $this->makePageLink( $entry->getTarget() ) );
670 $this->parsedParameters =
$params;
671 return $this->parsedParameters;
701 $saveLinkFlood = $this->linkFlood;
703 switch ( strtolower( trim( $type ) ) ) {
705 $value = Message::rawParam( $value );
708 $value = $this->context->getLanguage()->commaList( $value );
711 $value = $this->msg( $value )->text();
714 $value = $this->msg( $value )->inContentLanguage()->text();
717 $value = Message::numParam( $value );
720 $user = User::newFromName( $value );
721 $value = $user->getName();
724 $this->setShowUserToolLinks(
false );
726 $user = User::newFromName( $value );
729 $value = $this->msg(
'empty-username' )->text();
731 $value = Message::rawParam( $this->makeUserLink( $user ) );
732 $this->setShowUserToolLinks( $saveLinkFlood );
736 $title = Title::newFromText( $value );
737 $value = $title->getPrefixedText();
740 $title = Title::newFromText( $value );
741 $value = Message::rawParam( $this->makePageLink( $title ) );
763 if ( !$title instanceof
Title ) {
764 $msg = $this->msg(
'invalidtitle' )->text();
765 if ( $this->plaintext ) {
768 return Html::element(
'span', [
'class' =>
'mw-invalidtitle' ], $msg );
772 if ( $this->plaintext ) {
773 $link =
'[[' . $title->getPrefixedText() .
']]';
775 $html = $html !==
null ?
new HtmlArmor( $html ) : $html;
776 $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
789 if ( $this->canView( LogPage::DELETED_USER ) ) {
790 $performerIdentity = $this->entry->getPerformerIdentity();
791 $element = $this->makeUserLink( $performerIdentity );
792 if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
793 $element = $this->styleRestrictedElement( $element );
796 $element = $this->getRestrictedElement(
'rev-deleted-user' );
808 if ( $this->canView( LogPage::DELETED_COMMENT ) ) {
809 $comment = $this->getCommentFormatter()
810 ->formatBlock( $this->entry->getComment() );
812 $element = ltrim( $comment );
813 if ( $this->entry->isDeleted( LogPage::DELETED_COMMENT ) ) {
814 $element = $this->styleRestrictedElement( $element );
817 $element = $this->getRestrictedElement(
'rev-deleted-comment' );
830 if ( $this->plaintext ) {
831 return $this->msg( $message )->text();
834 return $this->styleRestrictedElement( $this->msg( $message )->escaped() );
843 if ( $this->plaintext ) {
846 $attribs = [
'class' => [
'history-deleted' ] ];
847 if ( $this->entry->isDeleted( LogPage::DELETED_RESTRICTED ) ) {
848 $attribs[
'class'][] =
'mw-history-suppressed';
851 return Html::rawElement(
'span', $attribs, $content );
861 return $this->context->msg( $key, ...
$params );
871 if ( $this->plaintext ) {
874 $element = Linker::userLink(
878 if ( $this->linkFlood ) {
879 $editCount = $this->getUserEditTracker()->getUserEditCount( $user );
881 $element .= Linker::userToolLinks(
911 return $this->getMessageParameters();
921 return $this->entry->getParameters();
941 foreach ( $this->getParametersForApi() as $key => $value ) {
942 $vals = explode(
':', $key, 3 );
943 if ( count( $vals ) !== 3 ) {
944 if ( $value instanceof __PHP_Incomplete_Class ) {
945 wfLogWarning(
'Log entry of type ' . $this->entry->getFullType() .
946 ' contains unrecoverable extra parameters.' );
949 $logParams[$key] = $value;
952 $logParams += $this->formatParameterValueForApi( $vals[2], $vals[1], $value );
954 ApiResult::setIndexedTagName( $logParams,
'param' );
955 ApiResult::setArrayType( $logParams,
'assoc' );
970 $type = strtolower( trim( $type ) );
973 $value = (bool)$value;
977 if ( is_int( $value ) || ctype_digit( (
string)$value ) ) {
978 $value = (int)$value;
980 $value = (float)$value;
987 if ( is_array( $value ) ) {
988 ApiResult::setArrayType( $value, $type );
998 $msg = $this->msg( $value );
999 if ( $type ===
'msg-content' ) {
1000 $msg->inContentLanguage();
1003 $value[
"{$name}_key"] = $msg->getKey();
1004 if ( $msg->getParams() ) {
1005 $value[
"{$name}_params"] = $msg->getParams();
1007 $value[
"{$name}_text"] = $msg->text();
1012 $title = Title::newFromText( $value );
1014 $title = SpecialPage::getTitleFor(
'Badtitle', $value );
1017 ApiQueryBase::addTitleInfo( $value, $title,
"{$name}_" );
1022 $user = User::newFromName( $value );
1024 $value = $user->getName();
1033 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.