mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-12 00:38:23 +00:00
Merge "Only select needed columns in queries"
This commit is contained in:
commit
a3882d8c4a
|
@ -145,18 +145,31 @@ class AbuseFilterViewDiff extends AbuseFilterView {
|
|||
}
|
||||
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
// All but afh_filter, afh_deleted and afh_changed_fields
|
||||
$selectFields = [
|
||||
'afh_id',
|
||||
'afh_user',
|
||||
'afh_user_text',
|
||||
'afh_timestamp',
|
||||
'afh_pattern',
|
||||
'afh_comments',
|
||||
'afh_flags',
|
||||
'afh_public_comments',
|
||||
'afh_actions',
|
||||
'afh_group',
|
||||
];
|
||||
$row = null;
|
||||
if ( is_numeric( $spec ) ) {
|
||||
$row = $dbr->selectRow(
|
||||
'abuse_filter_history',
|
||||
'*',
|
||||
$selectFields,
|
||||
[ 'afh_id' => $spec, 'afh_filter' => $this->mFilter ],
|
||||
__METHOD__
|
||||
);
|
||||
} elseif ( $spec == 'cur' ) {
|
||||
$row = $dbr->selectRow(
|
||||
'abuse_filter_history',
|
||||
'*',
|
||||
$selectFields,
|
||||
[ 'afh_filter' => $this->mFilter ],
|
||||
__METHOD__,
|
||||
[ 'ORDER BY' => 'afh_timestamp desc' ]
|
||||
|
@ -167,7 +180,7 @@ class AbuseFilterViewDiff extends AbuseFilterView {
|
|||
|
||||
$row = $dbr->selectRow(
|
||||
'abuse_filter_history',
|
||||
'*',
|
||||
$selectFields,
|
||||
[
|
||||
'afh_filter' => $this->mFilter,
|
||||
'afh_id<' . $dbr->addQuotes( $other['meta']['history_id'] ),
|
||||
|
@ -187,7 +200,7 @@ class AbuseFilterViewDiff extends AbuseFilterView {
|
|||
|
||||
$row = $dbr->selectRow(
|
||||
'abuse_filter_history',
|
||||
'*',
|
||||
$selectFields,
|
||||
[
|
||||
'afh_filter' => $this->mFilter,
|
||||
'afh_id>' . $dbr->addQuotes( $other['meta']['history_id'] ),
|
||||
|
|
|
@ -1049,8 +1049,9 @@ class AbuseFilterViewEdit extends AbuseFilterView {
|
|||
|
||||
// Load the actions
|
||||
$actions = [];
|
||||
$res = $dbr->select( 'abuse_filter_action',
|
||||
'*',
|
||||
$res = $dbr->select(
|
||||
'abuse_filter_action',
|
||||
[ 'afa_consequence', 'afa_parameters' ],
|
||||
[ 'afa_filter' => $id ],
|
||||
__METHOD__
|
||||
);
|
||||
|
|
|
@ -164,8 +164,20 @@ class AbuseFilterViewRevert extends AbuseFilterView {
|
|||
$conds[] = 'afl_timestamp <= ' . $dbr->addQuotes( $dbr->timestamp( $periodEnd ) );
|
||||
}
|
||||
|
||||
// Database query.
|
||||
$res = $dbr->select( 'abuse_filter_log', '*', $conds, __METHOD__ );
|
||||
// All but afl_filter, afl_ip, afl_deleted, afl_patrolled_by, afl_rev_id and afl_log_id
|
||||
$selectFields = [
|
||||
'afl_id',
|
||||
'afl_user',
|
||||
'afl_user_text',
|
||||
'afl_action',
|
||||
'afl_actions',
|
||||
'afl_var_dump',
|
||||
'afl_timestamp',
|
||||
'afl_namespace',
|
||||
'afl_title',
|
||||
'afl_wiki',
|
||||
];
|
||||
$res = $dbr->select( 'abuse_filter_log', $selectFields, $conds, __METHOD__ );
|
||||
|
||||
$results = [];
|
||||
foreach ( $res as $row ) {
|
||||
|
|
Loading…
Reference in a new issue