* @since 1.19
*/
+use Wikimedia\Rdbms\IDatabase;
+
/**
* Interface for log entries. Every log entry has these methods.
*
* @return array
*/
public static function getSelectQueryData() {
- $tables = [ 'logging', 'user' ];
+ $commentQuery = CommentStore::newKey( 'log_comment' )->getJoin();
+
+ $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,
}
public function getComment() {
- return $this->row->log_comment;
+ return CommentStore::newKey( 'log_comment' )->getComment( $this->row )->text;
}
public function getDeleted() {
}
public function getComment() {
- return $this->row->rc_comment;
+ return CommentStore::newKey( 'rc_comment' )
+ // Legacy because the row probably used RecentChange::selectFields()
+ ->getCommentLegacy( wfGetDB( DB_REPLICA ), $this->row )->text;
}
public function getDeleted() {
/** @var int ID of the log entry */
protected $id;
- /** @var Can this log entry be patrolled? */
+ /** @var bool Can this log entry be patrolled? */
protected $isPatrollable = false;
/** @var bool Whether this is a legacy log entry */
protected $legacy = false;
/**
- * Constructor.
- *
* @since 1.19
* @param string $type
* @param string $subtype
* @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();
// 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;
}
$data = [
- 'log_id' => $id,
'log_type' => $this->getType(),
'log_action' => $this->getSubtype(),
'log_timestamp' => $dbw->timestamp( $this->getTimestamp() ),
'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::newKey( 'log_comment' )->insert( $dbw, $comment );
$dbw->insert( 'logging', $data, __METHOD__ );
- $this->id = !is_null( $id ) ? $id : $dbw->insertId();
+ $this->id = $dbw->insertId();
$rows = [];
foreach ( $relations as $tag => $values ) {
$rc = $this->getRecentChange( $newId );
if ( $to === 'rc' || $to === 'rcandudp' ) {
+ // save RC, passing tags so they are applied there
+ $tags = $this->getTags();
+ if ( is_null( $tags ) ) {
+ $tags = [];
+ }
+ $rc->addTags( $tags );
$rc->save( 'pleasedontudp' );
}
) {
PatrolLog::record( $rc, true, $this->getPerformer() );
}
-
- // Add change tags to the log entry and (if applicable) the associated revision
- $tags = $this->getTags();
- if ( !is_null( $tags ) ) {
- $rcId = $rc->getAttribute( 'rc_id' );
- $revId = $this->getAssociatedRevId(); // Use null if $revId is 0
- ChangeTags::addTags( $tags, $rcId, $revId > 0 ? $revId : null, $newId );
- }
}
},
DeferredUpdates::POSTSEND,