Normalise casing of getArticleID used in core
[lhc/web/wiklou.git] / includes / logging / LogEntry.php
index 0373d75..5a01c52 100644 (file)
@@ -97,6 +97,7 @@ abstract class LogEntryBase implements LogEntry {
        /**
         * Whether the parameters for this log are stored in new or
         * old format.
+        * @return bool
         */
        public function isLegacy() {
                return false;
@@ -217,9 +218,13 @@ class DatabaseLogEntry extends LogEntryBase {
 
        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 );
                }
@@ -313,6 +318,14 @@ class ManualLogEntry extends LogEntryBase {
        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;
@@ -329,28 +342,66 @@ class ManualLogEntry extends LogEntryBase {
         *   '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;
        }
@@ -360,6 +411,8 @@ class ManualLogEntry extends LogEntryBase {
         * @return int If of the log entry
         */
        public function insert() {
+               global $wgContLang;
+
                $dbw = wfGetDB( DB_MASTER );
                $id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
 
@@ -367,6 +420,9 @@ class ManualLogEntry extends LogEntryBase {
                        $this->timestamp = wfTimestampNow();
                }
 
+               # Truncate for whole multibyte characters.
+               $comment = $wgContLang->truncate( $this->getComment(), 255 );
+
                $data = array(
                        'log_id' => $id,
                        'log_type' => $this->getType(),
@@ -376,8 +432,8 @@ class ManualLogEntry extends LogEntryBase {
                        '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__ );
@@ -406,18 +462,19 @@ class ManualLogEntry extends LogEntryBase {
                        $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' ) {
@@ -439,10 +496,16 @@ class ManualLogEntry extends LogEntryBase {
                return $this->parameters;
        }
 
+       /**
+        * @return User
+        */
        public function getPerformer() {
                return $this->performer;
        }
 
+       /**
+        * @return Title
+        */
        public function getTarget() {
                return $this->target;
        }