From ba5bea7a713c38f62bfb7c7ca2050648e26732e8 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Fri, 25 Sep 2015 14:01:00 -0700 Subject: [PATCH] Turn $wgSearchRunSuggestedQueryPercent into $wgSearchRunSuggestedQuery Deciding how to behave randomly is useful for testing, yet misleading for general usage. Now that testing is over, make it a boolean switch. Change-Id: I3e4d02aa57c853c20152c9071c444e09da57fb35 --- RELEASE-NOTES-1.26 | 3 +++ includes/DefaultSettings.php | 9 ++++----- includes/specials/SpecialSearch.php | 5 +---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26 index a13fc2e145..aab1b4254c 100644 --- a/RELEASE-NOTES-1.26 +++ b/RELEASE-NOTES-1.26 @@ -91,6 +91,9 @@ production. page. During the deprecation period, the styles will only be loaded on pages which contain 'mw-ui-button' in their HTML. Starting in 1.28, the styles will only be loaded if explicitly required. +* If search returns zero results and current search engine has a "did you mean" + suggestion, results for suggestion will be shown. Can be disabled by setting + $wgSearchRunSuggestedQuery to false. ==== External libraries ==== * Update es5-shim from v4.0.0 to v4.1.5. diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 8b220f33de..f58b339bb4 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -7706,14 +7706,13 @@ $wgVirtualRestConfig = array( ); /** - * Controls the percentage of zero-result search queries with suggestions that - * run the suggestion automatically. Must be a number between 0 and 1. This - * can be lowered to reduce query volume at the expense of result quality. + * Controls whether zero-result search queries with suggestions should display results for + * these suggestions. * - * @var float + * @var bool * @since 1.26 */ -$wgSearchRunSuggestedQueryPercent = 1; +$wgSearchRunSuggestedQuery = true; /** * For really cool vim folding this needs to be at the end: diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index d806be3ac6..3f67e93d1d 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -415,10 +415,7 @@ class SpecialSearch extends SpecialPage { return false; } - // Generate a random number between 0 and 1. If the - // number is less than the desired percentages run it. - $rand = rand( 0, getrandmax() ) / getrandmax(); - return $this->getConfig()->get( 'SearchRunSuggestedQueryPercent' ) > $rand; + return $this->getConfig()->get( 'SearchRunSuggestedQuery' ); } /** -- 2.20.1