Merge "jquery.makeCollapsible: events for collapsing/expanding, tests"
[lhc/web/wiklou.git] / includes / logging / LogEntry.php
index 2ca525e..0f20ed1 100644 (file)
@@ -175,6 +175,7 @@ class DatabaseLogEntry extends LogEntryBase {
 
        /// Database result row.
        protected $row;
+       protected $performer;
 
        protected function __construct( $row ) {
                $this->row = $row;
@@ -232,17 +233,20 @@ class DatabaseLogEntry extends LogEntryBase {
        }
 
        public function getPerformer() {
-               $userId = (int) $this->row->log_user;
-               if ( $userId !== 0 ) { // logged-in users
-                       if ( isset( $this->row->user_name ) ) {
-                               return User::newFromRow( $this->row );
-                       } else {
-                               return User::newFromId( $userId );
+               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 );
+                               } else {
+                                       $this->performer = User::newFromId( $userId );
+                               }
+                       } else { // IP users
+                               $userText = $this->row->log_user_text;
+                               $this->performer = User::newFromName( $userText, false );
                        }
-               } else { // IP users
-                       $userText = $this->row->log_user_text;
-                       return User::newFromName( $userText, false );
                }
+               return $this->performer;
        }
 
        public function getTarget() {
@@ -287,14 +291,17 @@ class RCDatabaseLogEntry extends DatabaseLogEntry {
        }
 
        public function getPerformer() {
-               $userId = (int) $this->row->rc_user;
-               if ( $userId !== 0 ) {
-                       return User::newFromId( $userId );
-               } else {
-                       $userText = $this->row->rc_user_text;
-                       // Might be an IP, don't validate the username
-                       return User::newFromName( $userText, false );
+               if( !$this->performer ) {
+                       $userId = (int) $this->row->rc_user;
+                       if ( $userId !== 0 ) {
+                               $this->performer = User::newFromId( $userId );
+                       } else {
+                               $userText = $this->row->rc_user_text;
+                               // Might be an IP, don't validate the username
+                               $this->performer = User::newFromName( $userText, false );
+                       }
                }
+               return $this->performer;
        }
 
        public function getTarget() {
@@ -360,7 +367,7 @@ class ManualLogEntry extends LogEntryBase {
         *
         * @since 1.19
         *
-        * @param $parameters array Associative array
+        * @param array $parameters Associative array
         */
        public function setParameters( $parameters ) {
                $this->parameters = $parameters;
@@ -435,8 +442,11 @@ class ManualLogEntry extends LogEntryBase {
                        $this->timestamp = wfTimestampNow();
                }
 
+               # Trim spaces on user supplied text
+               $comment = trim( $this->getComment() );
+
                # Truncate for whole multibyte characters.
-               $comment = $wgContLang->truncate( $this->getComment(), 255 );
+               $comment = $wgContLang->truncate( $comment, 255 );
 
                $data = array(
                        'log_id' => $id,
@@ -458,8 +468,8 @@ class ManualLogEntry extends LogEntryBase {
 
        /**
         * Publishes the log entry.
-        * @param $newId int id of the log entry.
-        * @param $to string: rcandudp (default), rc, udp
+        * @param int $newId id of the log entry.
+        * @param string $to rcandudp (default), rc, udp
         */
        public function publish( $newId, $to = 'rcandudp' ) {
                $log = new LogPage( $this->getType() );