90 $this->updateRecentChanges = $rc;
91 $this->sendToUDP = ( $udp ==
'UDP' );
106 'log_timestamp' => $dbw->timestamp( $now ),
107 'log_namespace' => $this->target->getNamespace(),
108 'log_title' => $this->target->getDBkey(),
109 'log_page' => $this->target->getArticleID(),
112 $data += MediaWikiServices::getInstance()->getCommentStore()->insert(
117 $data += ActorMigration::newMigration()->getInsertValues( $dbw,
'log_user', $this->doer );
118 $dbw->insert(
'logging', $data, __METHOD__ );
119 $newId = $dbw->insertId();
121 # And update recentchanges
122 if ( $this->updateRecentChanges ) {
125 RecentChange::notifyLog(
126 $now, $titleObj, $this->doer, $this->
getRcComment(),
'',
127 $this->type, $this->action, $this->target, $this->comment,
130 } elseif ( $this->sendToUDP ) {
131 # Don't send private logs to UDP
136 # Notify external application via UDP.
137 # We send this to IRC but do not want to add it the RC table.
139 $rc = RecentChange::newLogEntry(
140 $now, $titleObj, $this->doer, $this->
getRcComment(),
'',
141 $this->type, $this->action, $this->target, $this->comment,
144 $rc->notifyRCFeeds();
158 if ( $this->comment !=
'' ) {
159 if ( $rcComment ==
'' ) {
162 $rcComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() .
178 if ( $this->comment !=
'' ) {
179 if ( $rcComment ==
'' ) {
182 $rcComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() .
216 return in_array(
$type, self::validTypes() );
233 $params = [], $filterWikilinks =
false
237 $key =
"$type/$action";
240 if ( $skin ===
null ) {
241 $langObj = MediaWikiServices::getInstance()->getContentLanguage();
242 $langObjOrNull =
null;
256 ->inLanguage( $langObj )->escaped();
258 array_unshift(
$params, $titleLink );
261 ->inLanguage( $langObj )->escaped();
268 $args = func_get_args();
271 wfDebug(
"LogPage::actionText - unknown action $key" );
286 if ( $filterWikilinks ) {
287 $rv = str_replace(
'[[',
'', $rv );
288 $rv = str_replace(
']]',
'', $rv );
301 return $title->getPrefixedText();
304 $services = MediaWikiServices::getInstance();
305 $linkRenderer = $services->getLinkRenderer();
307 if (
$title->isSpecialPage() ) {
308 [ $name, $par ] = $services->getSpecialPageFactory()->resolveAlias(
$title->getDBkey() );
310 if ( $name ===
'Log' ) {
311 $logPage =
new LogPage( $par );
313 ->rawParams( $linkRenderer->makeLink(
$title, $logPage->getName()->text() ) )
314 ->inLanguage(
$lang )
319 return $linkRenderer->makeLink(
$title );
335 public function addEntry( $action, $target, $comment, $params = [], $doer =
null ) {
336 if ( !is_array( $params ) ) {
337 $params = [ $params ];
340 if ( $comment ===
null ) {
344 # Trim spaces on user supplied text
345 $comment = trim( $comment );
347 $this->action = $action;
348 $this->target = $target;
349 $this->comment = $comment;
350 $this->params = self::makeParamBlob( $params );
352 if ( $doer ===
null ) {
353 wfDeprecated( __METHOD__ .
' without passing a $user parameter',
'1.35' );
356 } elseif ( !is_object( $doer ) ) {
363 $logEntry->setTarget( $target );
364 $logEntry->setPerformer( $doer );
365 $logEntry->setParameters( $params );
369 $logEntry->setLegacy(
true );
372 $context = RequestContext::newExtraneousContext( $target );
373 $formatter->setContext( $context );
375 $this->actionText = $formatter->getPlainActionText();
376 $this->ircActionText = $formatter->getIRCActionText();
378 return $this->saveContent();
390 if ( !strlen( $field ) || empty( $values ) ) {
396 foreach ( $values as $value ) {
398 'ls_field' => $field,
399 'ls_value' => $value,
400 'ls_log_id' => $logid
405 $dbw->insert(
'log_search', $data, __METHOD__, [
'IGNORE' ] );
417 return implode(
"\n", $params );
427 if (
$blob ===
'' ) {
430 return explode(
"\n",
$blob );
478 $restriction = $this->getRestriction();
480 return $restriction !==
'' && $restriction !==
'*';
$wgLogActions
Lists the message key string for formatting individual events of each type and action when listed in ...
$wgLogNames
Lists the message key string for each log type.
$wgLogTypes
The logging system has two levels: an event type, which describes the general category and can be vie...
$wgLogRestrictions
This restricts log access to those who have a certain right Users without this will not see it in the...
$wgLogHeaders
Lists the message key string for descriptive text to be shown at the top of each log type.
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Class to simplify the use of log pages.
static getTitleLink(Title $title, ?Language $lang)
static actionText( $type, $action, $title=null, $skin=null, $params=[], $filterWikilinks=false)
Generate text for a log entry.
getRestriction()
Returns the right needed to read this log type.
__construct( $type, $rc=true, $udp='skipUDP')
Stable to call.
static makeParamBlob( $params)
Create a blob from a parameter array.
string $comment
Comment associated with action.
string $ircActionText
Plaintext version of the message for IRC.
User $doer
The user doing the action.
string $action
One of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir'.
isRestricted()
Tells if this log is not viewable by all.
static extractParams( $blob)
Extract a parameter array from a blob.
static isLogType( $type)
Is $type a valid log type.
getName()
Name of the log.
string $actionText
Plaintext version of the message.
addEntry( $action, $target, $comment, $params=[], $doer=null)
Add a log entry.
getComment()
Get the comment from the last addEntry() call.
bool $updateRecentChanges
getRcComment()
Get the RC comment from the last addEntry() call.
string $type
One of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move'.
addRelations( $field, $values, $logid)
Add relations to log_search table.
static validTypes()
Get the list of valid log types.
getRcCommentIRC()
Get the RC comment from the last addEntry() call for IRC.
string $params
Blob made of a parameters array.
getDescription()
Description of this log type.
Class for creating new log entries and inserting them into the database.
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,...
static unstub(&$obj)
Unstubs an object, if it is a stub object.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromId( $id)
Static factory method for creation from a given user ID.
if(!isset( $args[0])) $lang