summaryrefslogtreecommitdiff
path: root/includes/logging/LogEntry.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/logging/LogEntry.php')
-rw-r--r--includes/logging/LogEntry.php55
1 files changed, 43 insertions, 12 deletions
diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php
index 0f20ed16..b2a8e50d 100644
--- a/includes/logging/LogEntry.php
+++ b/includes/logging/LogEntry.php
@@ -151,7 +151,7 @@ class DatabaseLogEntry extends LogEntryBase {
return array(
'tables' => $tables,
'fields' => $fields,
- 'conds' => array(),
+ 'conds' => array(),
'options' => array(),
'join_conds' => $joins,
);
@@ -165,7 +165,7 @@ class DatabaseLogEntry extends LogEntryBase {
*/
public static function newFromRow( $row ) {
if ( is_array( $row ) && isset( $row['rc_logid'] ) ) {
- return new RCDatabaseLogEntry( (object) $row );
+ return new RCDatabaseLogEntry( (object)$row );
} else {
return new self( $row );
}
@@ -233,8 +233,8 @@ class DatabaseLogEntry extends LogEntryBase {
}
public function getPerformer() {
- if( !$this->performer ) {
- $userId = (int) $this->row->log_user;
+ if ( !$this->performer ) {
+ $userId = (int)$this->row->log_user;
if ( $userId !== 0 ) { // logged-in users
if ( isset( $this->row->user_name ) ) {
$this->performer = User::newFromRow( $this->row );
@@ -291,8 +291,8 @@ class RCDatabaseLogEntry extends DatabaseLogEntry {
}
public function getPerformer() {
- if( !$this->performer ) {
- $userId = (int) $this->row->rc_user;
+ if ( !$this->performer ) {
+ $userId = (int)$this->row->rc_user;
if ( $userId !== 0 ) {
$this->performer = User::newFromId( $userId );
} else {
@@ -334,6 +334,7 @@ class ManualLogEntry extends LogEntryBase {
protected $type; ///!< @var string
protected $subtype; ///!< @var string
protected $parameters = array(); ///!< @var array
+ protected $relations = array(); ///!< @var array
protected $performer; ///!< @var User
protected $target; ///!< @var Title
protected $timestamp; ///!< @var string
@@ -374,6 +375,17 @@ class ManualLogEntry extends LogEntryBase {
}
/**
+ * Declare arbitrary tag/value relations to this log entry.
+ * These can be used to filter log entries later on.
+ *
+ * @param array Map of (tag => (list of values))
+ * @since 1.22
+ */
+ public function setRelations( array $relations ) {
+ $this->relations = $relations;
+ }
+
+ /**
* Set the user that performed the action being logged.
*
* @since 1.19
@@ -430,12 +442,13 @@ class ManualLogEntry extends LogEntryBase {
/**
* Inserts the entry into the logging table.
+ * @param IDatabase $dbw
* @return int If of the log entry
*/
- public function insert() {
+ public function insert( IDatabase $dbw = null ) {
global $wgContLang;
- $dbw = wfGetDB( DB_MASTER );
+ $dbw = $dbw ?: wfGetDB( DB_MASTER );
$id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
if ( $this->timestamp === null ) {
@@ -459,10 +472,28 @@ class ManualLogEntry extends LogEntryBase {
'log_title' => $this->getTarget()->getDBkey(),
'log_page' => $this->getTarget()->getArticleID(),
'log_comment' => $comment,
- 'log_params' => serialize( (array) $this->getParameters() ),
+ 'log_params' => serialize( (array)$this->getParameters() ),
);
$dbw->insert( 'logging', $data, __METHOD__ );
$this->id = !is_null( $id ) ? $id : $dbw->insertId();
+
+ $rows = array();
+ foreach ( $this->relations as $tag => $values ) {
+ if ( !strlen( $tag ) ) {
+ throw new MWException( "Got empty log search tag." );
+ }
+ foreach ( $values as $value ) {
+ $rows[] = array(
+ 'ls_field' => $tag,
+ 'ls_value' => $value,
+ 'ls_log_id' => $this->id
+ );
+ }
+ }
+ if ( count( $rows ) ) {
+ $dbw->insert( 'log_search', $rows, __METHOD__, 'IGNORE' );
+ }
+
return $this->id;
}
@@ -503,7 +534,7 @@ class ManualLogEntry extends LogEntryBase {
$this->getSubtype(),
$this->getTarget(),
$this->getComment(),
- serialize( (array) $this->getParameters() ),
+ serialize( (array)$this->getParameters() ),
$newId,
$formatter->getIRCActionComment() // Used for IRC feeds
);
@@ -513,7 +544,7 @@ class ManualLogEntry extends LogEntryBase {
}
if ( $to === 'udp' || $to === 'rcandudp' ) {
- $rc->notifyRC2UDP();
+ $rc->notifyRCFeeds();
}
}
@@ -555,7 +586,7 @@ class ManualLogEntry extends LogEntryBase {
}
public function getDeleted() {
- return (int) $this->deleted;
+ return (int)$this->deleted;
}
}