Merge "Add SPARQL client to core"
[lhc/web/wiklou.git] / includes / logging / LogEntry.php
index fa94fe5..35502c7 100644 (file)
@@ -170,19 +170,21 @@ class DatabaseLogEntry extends LogEntryBase {
         * @return array
         */
        public static function getSelectQueryData() {
-               $tables = [ 'logging', 'user' ];
+               $commentQuery = CommentStore::getStore()->getJoin( 'log_comment' );
+
+               $tables = [ 'logging', 'user' ] + $commentQuery['tables'];
                $fields = [
                        'log_id', 'log_type', 'log_action', 'log_timestamp',
                        'log_user', 'log_user_text',
                        'log_namespace', 'log_title', // unused log_page
-                       'log_comment', 'log_params', 'log_deleted',
+                       'log_params', 'log_deleted',
                        'user_id', 'user_name', 'user_editcount',
-               ];
+               ] + $commentQuery['fields'];
 
                $joins = [
                        // IPs don't have an entry in user table
                        'user' => [ 'LEFT JOIN', 'log_user=user_id' ],
-               ];
+               ] + $commentQuery['joins'];
 
                return [
                        'tables' => $tables,
@@ -263,9 +265,9 @@ class DatabaseLogEntry extends LogEntryBase {
        public function getParameters() {
                if ( !isset( $this->params ) ) {
                        $blob = $this->getRawParameters();
-                       MediaWiki\suppressWarnings();
+                       Wikimedia\suppressWarnings();
                        $params = LogEntryBase::extractParams( $blob );
-                       MediaWiki\restoreWarnings();
+                       Wikimedia\restoreWarnings();
                        if ( $params !== false ) {
                                $this->params = $params;
                                $this->legacy = false;
@@ -322,7 +324,7 @@ class DatabaseLogEntry extends LogEntryBase {
        }
 
        public function getComment() {
-               return $this->row->log_comment;
+               return CommentStore::getStore()->getComment( 'log_comment', $this->row )->text;
        }
 
        public function getDeleted() {
@@ -380,7 +382,9 @@ class RCDatabaseLogEntry extends DatabaseLogEntry {
        }
 
        public function getComment() {
-               return $this->row->rc_comment;
+               return CommentStore::getStore()
+                       // Legacy because the row may have used RecentChange::selectFields()
+                       ->getCommentLegacy( wfGetDB( DB_REPLICA ), 'rc_comment', $this->row )->text;
        }
 
        public function getDeleted() {
@@ -589,10 +593,7 @@ class ManualLogEntry extends LogEntryBase {
         * @throws MWException
         */
        public function insert( IDatabase $dbw = null ) {
-               global $wgContLang;
-
                $dbw = $dbw ?: wfGetDB( DB_MASTER );
-               $id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
 
                if ( $this->timestamp === null ) {
                        $this->timestamp = wfTimestampNow();
@@ -601,9 +602,6 @@ class ManualLogEntry extends LogEntryBase {
                // Trim spaces on user supplied text
                $comment = trim( $this->getComment() );
 
-               // Truncate for whole multibyte characters.
-               $comment = $wgContLang->truncate( $comment, 255 );
-
                $params = $this->getParameters();
                $relations = $this->relations;
 
@@ -615,7 +613,6 @@ class ManualLogEntry extends LogEntryBase {
                }
 
                $data = [
-                       'log_id' => $id,
                        'log_type' => $this->getType(),
                        'log_action' => $this->getSubtype(),
                        'log_timestamp' => $dbw->timestamp( $this->getTimestamp() ),
@@ -624,12 +621,12 @@ class ManualLogEntry extends LogEntryBase {
                        'log_namespace' => $this->getTarget()->getNamespace(),
                        'log_title' => $this->getTarget()->getDBkey(),
                        'log_page' => $this->getTarget()->getArticleID(),
-                       'log_comment' => $comment,
                        'log_params' => LogEntryBase::makeParamBlob( $params ),
                ];
                if ( isset( $this->deleted ) ) {
                        $data['log_deleted'] = $this->deleted;
                }
+               $data += CommentStore::getStore()->insert( $dbw, 'log_comment', $comment );
 
                $dbw->insert( 'logging', $data, __METHOD__ );
                $this->id = $dbw->insertId();