Merge "Use CommentStore to access core comment fields when available"

This commit is contained in:
jenkins-bot 2017-09-05 19:02:26 +00:00 committed by Gerrit Code Review
commit f238148fec
5 changed files with 40 additions and 8 deletions

View file

@ -2149,7 +2149,14 @@ class AbuseFilter {
);
$vars->setVar( 'ACTION', 'delete' );
$vars->setVar( 'SUMMARY', $row->rc_comment );
if ( class_exists( CommentStore::class ) ) {
$vars->setVar( 'SUMMARY', CommentStore::newKey( 'rc_comment' )
// $row comes from RecentChange::selectFields()
->getCommentLegacy( wfGetDB( DB_REPLICA ), $row )->text
);
} else {
$vars->setVar( 'SUMMARY', $row->rc_comment );
}
return $vars;
}
@ -2175,7 +2182,14 @@ class AbuseFilter {
);
$vars->setVar( 'ACTION', 'edit' );
$vars->setVar( 'SUMMARY', $row->rc_comment );
if ( class_exists( CommentStore::class ) ) {
$vars->setVar( 'SUMMARY', CommentStore::newKey( 'rc_comment' )
// $row comes from RecentChange::selectFields()
->getCommentLegacy( wfGetDB( DB_REPLICA ), $row )->text
);
} else {
$vars->setVar( 'SUMMARY', $row->rc_comment );
}
$vars->setLazyLoadVar( 'new_wikitext', 'revision-text-by-id',
[ 'revid' => $row->rc_this_oldid ] );
@ -2215,7 +2229,14 @@ class AbuseFilter {
self::generateTitleVars( $newTitle, 'MOVED_TO' )
);
$vars->setVar( 'SUMMARY', $row->rc_comment );
if ( class_exists( CommentStore::class ) ) {
$vars->setVar( 'SUMMARY', CommentStore::newKey( 'rc_comment' )
// $row comes from RecentChange::selectFields()
->getCommentLegacy( wfGetDB( DB_REPLICA ), $row )->text
);
} else {
$vars->setVar( 'SUMMARY', $row->rc_comment );
}
$vars->setVar( 'ACTION', 'move' );
return $vars;

View file

@ -77,7 +77,12 @@ class AbuseFilterViewExamine extends AbuseFilterView {
function showExaminerForRC( $rcid ) {
// Get data
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow( 'recentchanges', '*', [ 'rc_id' => $rcid ], __METHOD__ );
$row = $dbr->selectRow(
'recentchanges',
RecentChange::selectFields(),
[ 'rc_id' => $rcid ],
__METHOD__
);
$out = $this->getOutput();
if ( !$row ) {
$out->addWikiMsg( 'abusefilter-examine-notfound' );

View file

@ -121,7 +121,7 @@ class AbuseFilterViewTestBatch extends AbuseFilterView {
$res = $dbr->select(
'recentchanges',
'*',
RecentChange::selectFields(),
array_filter( $conds ),
__METHOD__,
[ 'LIMIT' => self::$mChangeLimit, 'ORDER BY' => 'rc_timestamp desc' ]

View file

@ -21,7 +21,7 @@ class ApiAbuseFilterCheckMatch extends ApiBase {
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow(
'recentchanges',
'*',
RecentChange::selectFields(),
[ 'rc_id' => $params['rcid'] ],
__METHOD__
);

View file

@ -65,6 +65,13 @@ class AddMissingLoggingEntries extends Maintenance {
}
$dbw = wfGetDB( DB_MASTER );
if ( class_exists( CommentStore::class ) ) {
$commentFields = CommentStore::newKey( 'log_comment' )->insert( $dbw, '' );
} else {
$commentFields = [ 'log_comment' => '' ];
}
$count = 0;
foreach ( $afhRows as $row ) {
if ( $count % 100 == 0 ) {
@ -82,8 +89,7 @@ class AddMissingLoggingEntries extends Maintenance {
'log_params' => $row->afh_id . '\n' . $row->afh_filter,
'log_deleted' => $row->afh_deleted,
'log_user_text' => $row->afh_user_text,
'log_comment' => ''
],
] + $commentFields,
__METHOD__
);
$count++;