/**
* Whether the parameters for this log are stored in new or
* old format.
+ * @return bool
*/
public function isLegacy() {
return false;
public function getPerformer() {
$userId = (int) $this->row->log_user;
- if ( $userId !== 0 ) {
- return User::newFromRow( $this->row );
- } else {
+ if ( $userId !== 0 ) { // logged-in users
+ if ( isset( $this->row->user_name ) ) {
+ return User::newFromRow( $this->row );
+ } else {
+ return User::newFromId( $userId );
+ }
+ } else { // IP users
$userText = $this->row->log_user_text;
return User::newFromName( $userText, false );
}
protected $comment = ''; ///!< @var string
protected $deleted; ///!< @var int
+ /**
+ * Constructor.
+ *
+ * @since 1.19
+ *
+ * @param string $type
+ * @param string $subtype
+ */
public function __construct( $type, $subtype ) {
$this->type = $type;
$this->subtype = $subtype;
* '4:color' => 'blue',
* 'animal' => 'dog'
* );
- * @param $parameters Associative array
+ *
+ * @since 1.19
+ *
+ * @param $parameters array Associative array
*/
public function setParameters( $parameters ) {
$this->parameters = $parameters;
}
+ /**
+ * Set the user that performed the action being logged.
+ *
+ * @since 1.19
+ *
+ * @param User $performer
+ */
public function setPerformer( User $performer ) {
$this->performer = $performer;
}
+ /**
+ * Set the title of the object changed.
+ *
+ * @since 1.19
+ *
+ * @param Title $target
+ */
public function setTarget( Title $target ) {
$this->target = $target;
}
+ /**
+ * Set the timestamp of when the logged action took place.
+ *
+ * @since 1.19
+ *
+ * @param string $timestamp
+ */
public function setTimestamp( $timestamp ) {
$this->timestamp = $timestamp;
}
+ /**
+ * Set a comment associated with the action being logged.
+ *
+ * @since 1.19
+ *
+ * @param string $comment
+ */
public function setComment( $comment ) {
$this->comment = $comment;
}
+ /**
+ * TODO: document
+ *
+ * @since 1.19
+ *
+ * @param integer $deleted
+ */
public function setDeleted( $deleted ) {
$this->deleted = $deleted;
}
* @return int If of the log entry
*/
public function insert() {
+ global $wgContLang;
+
$dbw = wfGetDB( DB_MASTER );
$id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
$this->timestamp = wfTimestampNow();
}
+ # Truncate for whole multibyte characters.
+ $comment = $wgContLang->truncate( $this->getComment(), 255 );
+
$data = array(
'log_id' => $id,
'log_type' => $this->getType(),
'log_user_text' => $this->getPerformer()->getName(),
'log_namespace' => $this->getTarget()->getNamespace(),
'log_title' => $this->getTarget()->getDBkey(),
- 'log_page' => $this->getTarget()->getArticleId(),
- 'log_comment' => $this->getComment(),
+ 'log_page' => $this->getTarget()->getArticleID(),
+ 'log_comment' => $comment,
'log_params' => serialize( (array) $this->getParameters() ),
);
$dbw->insert( 'logging', $data, __METHOD__ );
$this->getTimestamp(),
$logpage,
$user,
- $formatter->getPlainActionText(), // Used for IRC feeds
+ $formatter->getPlainActionText(),
$user->isAnon() ? $user->getName() : '',
$this->getType(),
$this->getSubtype(),
$this->getTarget(),
$this->getComment(),
serialize( (array) $this->getParameters() ),
- $newId
+ $newId,
+ $formatter->getIRCActionComment() // Used for IRC feeds
);
if ( $to === 'rc' || $to === 'rcandudp' ) {
- $rc->save();
+ $rc->save( 'pleasedontudp' );
}
if ( $to === 'udp' || $to === 'rcandudp' ) {
return $this->parameters;
}
+ /**
+ * @return User
+ */
public function getPerformer() {
return $this->performer;
}
+ /**
+ * @return Title
+ */
public function getTarget() {
return $this->target;
}