From a1aa09d31cdb1ff908caea96ae0e3844b0ccf88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Such=C3=A1nek?= Date: Mon, 26 Dec 2016 10:09:37 +0000 Subject: [PATCH] Cache global filter names AbuseLog fetches the names in an additional query for each line but the result is always same. Change-Id: Ie12f909727ae82ab60781ccedfdf1b241c105388 --- includes/AbuseFilter.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/AbuseFilter.class.php b/includes/AbuseFilter.class.php index fd0d8bba8..7a74a8fb0 100644 --- a/includes/AbuseFilter.class.php +++ b/includes/AbuseFilter.class.php @@ -2408,14 +2408,21 @@ class AbuseFilter { return ''; } + static $cache = []; + if ( isset( $cache[$filterID] ) ) { + return $cache[$filterID]; + } + $fdb = wfGetDB( DB_SLAVE, [], $wgAbuseFilterCentralDB ); - return $fdb->selectField( + $cache[$filterID] = $fdb->selectField( 'abuse_filter', 'af_public_comments', [ 'af_id' => $filterID ], __METHOD__ ); + + return $cache[$filterID]; } /**