Merge "Shorten ternary expressions in RawAction.php"
[lhc/web/wiklou.git] / includes / logging / LogEntry.php
index 7803bca..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 );
 }
@@ -157,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 );
                }
@@ -176,6 +177,11 @@ class DatabaseLogEntry extends LogEntryBase {
        /** @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;
        }
@@ -361,6 +367,9 @@ class ManualLogEntry extends LogEntryBase {
        /** @var int Deletion state of the log entry */
        protected $deleted;
 
+       /** @var int ID of the log entry */
+       protected $id;
+
        /**
         * Constructor.
         *
@@ -398,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 $relations Map of (tag => (list of values))
+        * @param array $relations Map of (tag => (list of values|value))
         * @since 1.22
         */
        public function setRelations( array $relations ) {
@@ -454,7 +463,7 @@ class ManualLogEntry extends LogEntryBase {
         *
         * @since 1.19
         *
-        * @param integer $deleted
+        * @param int $deleted
         */
        public function setDeleted( $deleted ) {
                $this->deleted = $deleted;
@@ -495,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();
 
@@ -503,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,
@@ -560,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() );