mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 13:46:48 +00:00
tests: Use multi-row insert in AbuseFilterConsequencesTest
Small performance benefit by just one db call instead of multiple Most test cases only use one filter, but some 2 to 4 Change-Id: I498c447e3873d2138e21541467115c9a67bb909e
This commit is contained in:
parent
db83369b76
commit
b2df776f8d
|
@ -365,6 +365,8 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
|
|||
'af_global' => 0
|
||||
];
|
||||
|
||||
$filterRows = [];
|
||||
$actionsRows = [];
|
||||
foreach ( $ids as $id ) {
|
||||
$filter = self::FILTERS[$id] + $defaultRowSection;
|
||||
$actions = $filter['actions'];
|
||||
|
@ -372,13 +374,9 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
|
|||
$filter[ 'af_actions' ] = implode( ',', array_keys( $actions ) );
|
||||
$filter[ 'af_id' ] = $id;
|
||||
|
||||
$dbw->newInsertQueryBuilder()
|
||||
->insertInto( 'abuse_filter' )
|
||||
->row( $filter )
|
||||
->caller( __METHOD__ )
|
||||
->execute();
|
||||
ksort( $filter );
|
||||
$filterRows[] = $filter;
|
||||
|
||||
$actionsRows = [];
|
||||
foreach ( array_filter( $wgAbuseFilterActions ) as $action => $_ ) {
|
||||
if ( isset( $actions[$action] ) ) {
|
||||
$parameters = $actions[$action];
|
||||
|
@ -391,14 +389,19 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
|
|||
$actionsRows[] = $thisRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $actionsRows ) {
|
||||
$dbw->newInsertQueryBuilder()
|
||||
->insertInto( 'abuse_filter_action' )
|
||||
->rows( $actionsRows )
|
||||
->caller( __METHOD__ )
|
||||
->execute();
|
||||
}
|
||||
$dbw->newInsertQueryBuilder()
|
||||
->insertInto( 'abuse_filter' )
|
||||
->rows( $filterRows )
|
||||
->caller( __METHOD__ )
|
||||
->execute();
|
||||
if ( $actionsRows ) {
|
||||
$dbw->newInsertQueryBuilder()
|
||||
->insertInto( 'abuse_filter_action' )
|
||||
->rows( $actionsRows )
|
||||
->caller( __METHOD__ )
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue