From: Aaron Schulz Date: Sat, 6 Jul 2013 06:33:59 +0000 (-0700) Subject: Added log_search tag support to ManualLogEntry X-Git-Tag: 1.31.0-rc.0~19223^2 X-Git-Url: http://git.cyclocoop.org/wiki/Target_page?a=commitdiff_plain;h=8c04cd7647156eaa45769797fa4bd30bfac94371;p=lhc%2Fweb%2Fwiklou.git Added log_search tag support to ManualLogEntry Change-Id: I7e57cd3f2b8790aecd1c1831325c59a2be600780 --- diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index 92a0abe4b5..fee4fab6e0 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -334,6 +334,7 @@ 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 @@ -373,6 +374,17 @@ class ManualLogEntry extends LogEntryBase { $this->parameters = $parameters; } + /** + * 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)) + * @since 1.22 + */ + public function setRelations( array $relations ) { + $this->relations = $relations; + } + /** * Set the user that performed the action being logged. * @@ -464,6 +476,24 @@ class ManualLogEntry extends LogEntryBase { ); $dbw->insert( 'logging', $data, __METHOD__ ); $this->id = !is_null( $id ) ? $id : $dbw->insertId(); + + $rows = array(); + foreach ( $this->relations as $tag => $values ) { + if ( !strlen( $tag ) ) { + throw new MWException( "Got empty log search tag." ); + } + foreach ( $values as $value ) { + $rows[] = array( + 'ls_field' => $tag, + 'ls_value' => $value, + 'ls_log_id' => $this->id + ); + } + } + if ( count( $rows ) ) { + $dbw->insert( 'log_search', $rows, __METHOD__, 'IGNORE' ); + } + return $this->id; }