From b7cf9f4b09e79c2c0442736b6c9a46adc2330a8b Mon Sep 17 00:00:00 2001 From: Edward Chernenko Date: Fri, 16 Nov 2018 00:24:38 +0300 Subject: [PATCH] Unhardcode the limit "find no more than 250 results" in doSearchQuery() Here we add $wgReplaceTextResultsLimit variable (default: 250) to allow administrator to change this limit. Change-Id: Iee9d958db8ddd245a98ec6a3d5b5cf8ef1d80370 --- extension.json | 1 + src/ReplaceTextSearch.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/extension.json b/extension.json index 942571d7..7f9347c3 100644 --- a/extension.json +++ b/extension.json @@ -78,6 +78,7 @@ ] }, "config": { + "ReplaceTextResultsLimit": 250, "ReplaceTextUser": null }, "manifest_version": 1 diff --git a/src/ReplaceTextSearch.php b/src/ReplaceTextSearch.php index 9c9acae5..60c10455 100644 --- a/src/ReplaceTextSearch.php +++ b/src/ReplaceTextSearch.php @@ -34,6 +34,8 @@ class ReplaceTextSearch { public static function doSearchQuery( $search, $namespaces, $category, $prefix, $use_regex = false ) { + global $wgReplaceTextResultsLimit; + $dbr = wfGetDB( DB_REPLICA ); $tables = [ 'page', 'revision', 'text', 'slots', 'content' ]; $vars = [ 'page_id', 'page_namespace', 'page_title', 'old_text' ]; @@ -56,9 +58,7 @@ class ReplaceTextSearch { self::prefixCondition( $prefix, $conds ); $options = [ 'ORDER BY' => 'page_namespace, page_title', - // 250 seems like a reasonable limit for one screen. - // @TODO - should probably be a setting. - 'LIMIT' => 250 + 'LIMIT' => $wgReplaceTextResultsLimit ]; return $dbr->select( $tables, $vars, $conds, __METHOD__, $options );