91 $this->updateRecentChanges = $rc;
92 $this->sendToUDP = ( $udp ==
'UDP' );
104 $actorId = MediaWikiServices::getInstance()->getActorNormalization()
105 ->acquireActorId( $this->performer, $dbw );
109 'log_timestamp' => $dbw->timestamp( $now ),
110 'log_actor' => $actorId,
111 'log_namespace' => $this->target->getNamespace(),
112 'log_title' => $this->target->getDBkey(),
113 'log_page' => $this->target->getArticleID(),
116 $data += MediaWikiServices::getInstance()->getCommentStore()->insert(
121 $dbw->insert(
'logging', $data, __METHOD__ );
122 $newId = $dbw->insertId();
124 # And update recentchanges
125 if ( $this->updateRecentChanges ) {
128 RecentChange::notifyLog(
129 $now, $titleObj, $this->performer, $this->
getRcComment(),
'',
130 $this->type, $this->action, $this->target, $this->comment,
133 } elseif ( $this->sendToUDP ) {
134 # Don't send private logs to UDP
139 # Notify external application via UDP.
140 # We send this to IRC but do not want to add it the RC table.
142 $rc = RecentChange::newLogEntry(
143 $now, $titleObj, $this->performer, $this->
getRcComment(),
'',
144 $this->type, $this->action, $this->target, $this->comment,
147 $rc->notifyRCFeeds();
161 if ( $this->comment !=
'' ) {
162 if ( $rcComment ==
'' ) {
165 $rcComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() .
181 if ( $this->comment !=
'' ) {
182 if ( $rcComment ==
'' ) {
185 $rcComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() .
219 return in_array(
$type, self::validTypes() );
236 $params = [], $filterWikilinks =
false
240 $key =
"$type/$action";
243 if ( $skin ===
null ) {
244 $langObj = MediaWikiServices::getInstance()->getContentLanguage();
245 $langObjOrNull =
null;
259 ->inLanguage( $langObj )->escaped();
261 array_unshift(
$params, $titleLink );
264 ->inLanguage( $langObj )->escaped();
271 $args = func_get_args();
275 wfDebug(
"LogPage::actionText - unknown action $key" );
290 if ( $filterWikilinks ) {
291 $rv = str_replace(
'[[',
'', $rv );
292 $rv = str_replace(
']]',
'', $rv );
305 return $title->getPrefixedText();
308 $services = MediaWikiServices::getInstance();
309 $linkRenderer = $services->getLinkRenderer();
311 if (
$title->isSpecialPage() ) {
312 [ $name, $par ] = $services->getSpecialPageFactory()->resolveAlias(
$title->getDBkey() );
314 if ( $name ===
'Log' ) {
315 $logPage =
new LogPage( $par );
317 ->rawParams( $linkRenderer->makeLink(
$title, $logPage->getName()->text() ) )
318 ->inLanguage(
$lang )
323 return $linkRenderer->makeLink(
$title );
339 public function addEntry( $action, $target, $comment, $params, $performer ) {
341 if ( !is_array( $params ) ) {
342 $params = [ $params ];
345 if ( $comment ===
null ) {
349 # Trim spaces on user supplied text
350 $comment = trim( $comment );
352 $this->action = $action;
353 $this->target = $target;
354 $this->comment = $comment;
355 $this->params = self::makeParamBlob( $params );
357 if ( !is_object( $performer ) ) {
361 $this->performer = $performer;
364 $logEntry->setTarget( $target );
365 $logEntry->setPerformer( $performer );
366 $logEntry->setParameters( $params );
370 $logEntry->setLegacy(
true );
373 $context = RequestContext::newExtraneousContext( $target );
374 $formatter->setContext( $context );
376 $this->actionText = $formatter->getPlainActionText();
377 $this->ircActionText = $formatter->getIRCActionText();
379 return $this->saveContent();
391 if ( !strlen( $field ) || empty( $values ) ) {
397 foreach ( $values as $value ) {
399 'ls_field' => $field,
400 'ls_value' => $value,
401 'ls_log_id' => $logid
406 $dbw->insert(
'log_search', $data, __METHOD__, [
'IGNORE' ] );
418 return implode(
"\n", $params );
428 if (
$blob ===
'' ) {
431 return explode(
"\n",
$blob );
480 $restriction = $this->getRestriction();
482 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.
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')
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.
UserIdentity $performer
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.
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.
addEntry( $action, $target, $comment, $params, $performer)
Add a log entry.
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.
static newFromId( $id)
Static factory method for creation from a given user ID.
if(!isset( $args[0])) $lang