Anomie has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/374856 )
Change subject: Use CommentStore to access core comment fields when available
......................................................................
Use CommentStore to access core comment fields when available
See core change Ic3a434c0.
Bug: T166732
Change-Id: I130510381ef97d8a2d29686843e2710cb5f72195
---
M includes/AbuseFilter.class.php
M includes/Views/AbuseFilterViewExamine.php
M includes/Views/AbuseFilterViewTestBatch.php
M includes/api/ApiAbuseFilterCheckMatch.php
M maintenance/addMissingLoggingEntries.php
5 files changed, 40 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter
refs/changes/56/374856/1
diff --git a/includes/AbuseFilter.class.php b/includes/AbuseFilter.class.php
index ff2822b..3ce5cdb 100644
--- a/includes/AbuseFilter.class.php
+++ b/includes/AbuseFilter.class.php
@@ -2149,7 +2149,14 @@
);
$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 @@
);
$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 @@
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;
diff --git a/includes/Views/AbuseFilterViewExamine.php
b/includes/Views/AbuseFilterViewExamine.php
index ef7b439..6c0e77a 100644
--- a/includes/Views/AbuseFilterViewExamine.php
+++ b/includes/Views/AbuseFilterViewExamine.php
@@ -77,7 +77,12 @@
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' );
diff --git a/includes/Views/AbuseFilterViewTestBatch.php
b/includes/Views/AbuseFilterViewTestBatch.php
index 790194d..abc33fc 100644
--- a/includes/Views/AbuseFilterViewTestBatch.php
+++ b/includes/Views/AbuseFilterViewTestBatch.php
@@ -121,7 +121,7 @@
$res = $dbr->select(
'recentchanges',
- '*',
+ RecentChange::selectFields(),
array_filter( $conds ),
__METHOD__,
[ 'LIMIT' => self::$mChangeLimit, 'ORDER BY' =>
'rc_timestamp desc' ]
diff --git a/includes/api/ApiAbuseFilterCheckMatch.php
b/includes/api/ApiAbuseFilterCheckMatch.php
index aa5e969..bcea726 100644
--- a/includes/api/ApiAbuseFilterCheckMatch.php
+++ b/includes/api/ApiAbuseFilterCheckMatch.php
@@ -21,7 +21,7 @@
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow(
'recentchanges',
- '*',
+ RecentChange::selectFields(),
[ 'rc_id' => $params['rcid'] ],
__METHOD__
);
diff --git a/maintenance/addMissingLoggingEntries.php
b/maintenance/addMissingLoggingEntries.php
index 39c4a17..70ab03f 100644
--- a/maintenance/addMissingLoggingEntries.php
+++ b/maintenance/addMissingLoggingEntries.php
@@ -65,6 +65,13 @@
}
$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 @@
'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++;
--
To view, visit https://gerrit.wikimedia.org/r/374856
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I130510381ef97d8a2d29686843e2710cb5f72195
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits