Merge "Shorten ternary expressions in RawAction.php"
[lhc/web/wiklou.git] / includes / logging / LogEntry.php
index 40846a2..bebe3a9 100644 (file)
@@ -88,8 +88,8 @@ interface LogEntry {
        public function getDeleted();
 
        /**
-        * @param $field Integer: one of LogPage::DELETED_* bitfield constants
-        * @return Boolean
+        * @param int $field One of LogPage::DELETED_* bitfield constants
+        * @return bool
         */
        public function isDeleted( $field );
 }
@@ -99,7 +99,6 @@ interface LogEntry {
  * @since 1.19
  */
 abstract class LogEntryBase implements LogEntry {
-
        public function getFullType() {
                return $this->getType() . '/' . $this->getSubtype();
        }
@@ -158,12 +157,13 @@ class DatabaseLogEntry extends LogEntryBase {
        /**
         * Constructs new LogEntry from database result row.
         * Supports rows from both logging and recentchanges table.
-        * @param $row
+        * @param stdClass|array $row
         * @return DatabaseLogEntry
         */
        public static function newFromRow( $row ) {
-               if ( is_array( $row ) && isset( $row['rc_logid'] ) ) {
-                       return new RCDatabaseLogEntry( (object)$row );
+               $row = (object)$row;
+               if ( isset( $row->rc_logid ) ) {
+                       return new RCDatabaseLogEntry( $row );
                } else {
                        return new self( $row );
                }
@@ -171,10 +171,17 @@ class DatabaseLogEntry extends LogEntryBase {
 
        // Non-static->
 
-       /// Database result row.
+       /** @var stdClass Database result row. */
        protected $row;
+
+       /** @var User */
        protected $performer;
 
+       /** @var bool Whether the parameters for this log entry are stored in new
+        *    or old format.
+        */
+       protected $legacy;
+
        protected function __construct( $row ) {
                $this->row = $row;
        }
@@ -333,15 +340,35 @@ class RCDatabaseLogEntry extends DatabaseLogEntry {
  * @since 1.19
  */
 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
-       protected $comment = ''; ///!< @var string
-       protected $deleted; ///!< @var int
+       /** @var string Type of log entry */
+       protected $type;
+
+       /** @var string Sub type of log entry */
+       protected $subtype;
+
+       /** @var array Parameters for log entry */
+       protected $parameters = array();
+
+       /** @var array */
+       protected $relations = array();
+
+       /** @var User Performer of the action for the log entry */
+       protected $performer;
+
+       /** @var Title Target title for the log entry */
+       protected $target;
+
+       /** @var string Timestamp of creation of the log entry */
+       protected $timestamp;
+
+       /** @var string Comment for the log entry */
+       protected $comment = '';
+
+       /** @var int Deletion state of the log entry */
+       protected $deleted;
+
+       /** @var int ID of the log entry */
+       protected $id;
 
        /**
         * Constructor.
@@ -380,7 +407,7 @@ 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))
+        * @param array $relations Map of (tag => (list of values|value))
         * @since 1.22
         */
        public function setRelations( array $relations ) {
@@ -436,7 +463,7 @@ class ManualLogEntry extends LogEntryBase {
         *
         * @since 1.19
         *
-        * @param integer $deleted
+        * @param int $deleted
         */
        public function setDeleted( $deleted ) {
                $this->deleted = $deleted;
@@ -445,7 +472,8 @@ class ManualLogEntry extends LogEntryBase {
        /**
         * Inserts the entry into the logging table.
         * @param IDatabase $dbw
-        * @return int If of the log entry
+        * @return int ID of the log entry
+        * @throws MWException
         */
        public function insert( IDatabase $dbw = null ) {
                global $wgContLang;
@@ -476,6 +504,10 @@ class ManualLogEntry extends LogEntryBase {
                        'log_comment' => $comment,
                        'log_params' => serialize( (array)$this->getParameters() ),
                );
+               if ( isset( $this->deleted ) ) {
+                       $data['log_deleted'] = $this->deleted;
+               }
+
                $dbw->insert( 'logging', $data, __METHOD__ );
                $this->id = !is_null( $id ) ? $id : $dbw->insertId();
 
@@ -484,6 +516,11 @@ class ManualLogEntry extends LogEntryBase {
                        if ( !strlen( $tag ) ) {
                                throw new MWException( "Got empty log search tag." );
                        }
+
+                       if ( !is_array( $values ) ) {
+                               $values = array( $values );
+                       }
+
                        foreach ( $values as $value ) {
                                $rows[] = array(
                                        'ls_field' => $tag,
@@ -541,8 +578,8 @@ class ManualLogEntry extends LogEntryBase {
 
        /**
         * Publishes the log entry.
-        * @param int $newId id of the log entry.
-        * @param string $to rcandudp (default), rc, udp
+        * @param int $newId Id of the log entry.
+        * @param string $to One of: rcandudp (default), rc, udp
         */
        public function publish( $newId, $to = 'rcandudp' ) {
                $log = new LogPage( $this->getType() );