Drop search related feature flags
Given Wikidata is the only project using modern Vector, and the only project where the search API is not applicable, this will result in a loss of autocomplete on Wikidata.org which will fall back to the non-JS mode. Bug: T290688 Change-Id: Iece5a4efd43e09cd90c842c9c134ca115b35f2b2
This commit is contained in:
parent
44e6289f8d
commit
d8382ec96b
|
@ -168,21 +168,6 @@ final class Constants {
|
|||
*/
|
||||
public const QUERY_PARAM_SKIN = 'useskin';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const FEATURE_USE_WVUI_SEARCH = 'UseWvuiSearch';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const CONFIG_KEY_USE_WVUI_SEARCH = 'VectorUseWvuiSearch';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const REQUIREMENT_USE_WVUI_SEARCH = 'VectorUseWvuiSearch';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -256,18 +241,6 @@ final class Constants {
|
|||
*/
|
||||
public const SEARCH_BOX_INPUT_LOCATION_DEFAULT = 'header-navigation';
|
||||
|
||||
/**
|
||||
* Defines whether or not the Core/Vue.js Search Widget A/B test is running. See
|
||||
* https://phabricator.wikimedia.org/T261647 for additional detail about the test.
|
||||
*
|
||||
* Note well that if the associated config value is falsy, then we fall back to choosing the
|
||||
* search widget treatment based on the `VectorUseWvuiSearch` config variable (see
|
||||
* `resources/skins.vector.js/searchLoader.js`).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const CONFIG_SEARCH_TREATMENT_AB_TEST = 'VectorSearchTreatmentABTest';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* @file
|
||||
* @since 1.36
|
||||
*/
|
||||
|
||||
namespace Vector\FeatureManagement\Requirements;
|
||||
|
||||
use Config;
|
||||
use Vector\Constants;
|
||||
use Vector\FeatureManagement\Requirement;
|
||||
|
||||
/**
|
||||
* Checks whether or not WVUI search should be used.
|
||||
*
|
||||
* @unstable
|
||||
*
|
||||
* @package Vector\FeatureManagement\Requirements
|
||||
* @internal
|
||||
*/
|
||||
final class WvuiSearchTreatmentRequirement implements Requirement {
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var \User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* This constructor accepts all dependencies needed to determine
|
||||
* whether wvui search is enabled for current user and config.
|
||||
*
|
||||
* @param \Config $config
|
||||
* @param \User $user
|
||||
*/
|
||||
public function __construct( \Config $config, \User $user ) {
|
||||
$this->config = $config;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName(): string {
|
||||
return Constants::REQUIREMENT_USE_WVUI_SEARCH;
|
||||
}
|
||||
|
||||
/**
|
||||
* If A/B test is enabled check whether the user is logged in and bucketed.
|
||||
* Fallback to `VectorUseWvuiSearch` config value.
|
||||
*
|
||||
* @inheritDoc
|
||||
* @throws \ConfigException
|
||||
*/
|
||||
public function isMet(): bool {
|
||||
// Determine the search widget treatment to send to the user
|
||||
$shouldUseWvuiSearch = (bool)$this->config->get( Constants::CONFIG_KEY_USE_WVUI_SEARCH );
|
||||
|
||||
if ( (bool)$this->config->get( Constants::CONFIG_SEARCH_TREATMENT_AB_TEST ) && $this->user->isRegistered() ) {
|
||||
$shouldUseWvuiSearch = $this->user->getID() % 2 === 0;
|
||||
}
|
||||
|
||||
return $shouldUseWvuiSearch;
|
||||
}
|
||||
}
|
|
@ -608,12 +608,7 @@ class Hooks {
|
|||
} else {
|
||||
// The modern Vector skin must also carry skin-vector for compatibility with older
|
||||
// skins.
|
||||
$bodyAttrs['class'] .= ' skin-vector';
|
||||
}
|
||||
|
||||
// Determine the search widget treatment to send to the user
|
||||
if ( VectorServices::getFeatureManager()->isFeatureEnabled( Constants::FEATURE_USE_WVUI_SEARCH ) ) {
|
||||
$bodyAttrs['class'] .= ' skin-vector-search-vue';
|
||||
$bodyAttrs['class'] .= ' skin-vector skin-vector-search-vue';
|
||||
}
|
||||
|
||||
$config = $sk->getConfig();
|
||||
|
|
|
@ -28,7 +28,6 @@ use Vector\FeatureManagement\FeatureManager;
|
|||
use Vector\FeatureManagement\Requirements\DynamicConfigRequirement;
|
||||
use Vector\FeatureManagement\Requirements\LatestSkinVersionRequirement;
|
||||
use Vector\FeatureManagement\Requirements\OverridableConfigRequirement;
|
||||
use Vector\FeatureManagement\Requirements\WvuiSearchTreatmentRequirement;
|
||||
use Vector\SkinVersionLookup;
|
||||
|
||||
return [
|
||||
|
@ -202,24 +201,6 @@ return [
|
|||
]
|
||||
);
|
||||
|
||||
// Feature: Use Wvui Search
|
||||
// ================================
|
||||
$featureManager->registerRequirement(
|
||||
new WvuiSearchTreatmentRequirement(
|
||||
$services->getMainConfig(),
|
||||
$context->getUser()
|
||||
)
|
||||
);
|
||||
|
||||
$featureManager->registerFeature(
|
||||
Constants::FEATURE_USE_WVUI_SEARCH,
|
||||
[
|
||||
Constants::REQUIREMENT_FULLY_INITIALISED,
|
||||
Constants::REQUIREMENT_LATEST_SKIN_VERSION,
|
||||
Constants::REQUIREMENT_USE_WVUI_SEARCH
|
||||
]
|
||||
);
|
||||
|
||||
// Feature: Sticky header
|
||||
// ================================
|
||||
$featureManager->registerRequirement(
|
||||
|
|
|
@ -713,12 +713,7 @@ class SkinVector extends SkinMustache {
|
|||
string $formId,
|
||||
bool $autoExpandWidth
|
||||
) {
|
||||
$searchClass = '';
|
||||
|
||||
// Determine the search widget treatment to send to the user
|
||||
if ( VectorServices::getFeatureManager()->isFeatureEnabled( Constants::FEATURE_USE_WVUI_SEARCH ) ) {
|
||||
$searchClass .= 'vector-search-box-vue ';
|
||||
}
|
||||
$searchClass = 'vector-search-box-vue ';
|
||||
|
||||
if ( $isCollapsible ) {
|
||||
$searchClass .= ' vector-search-box-collapses ';
|
||||
|
@ -790,8 +785,7 @@ class SkinVector extends SkinMustache {
|
|||
private function doesSearchHaveThumbnails(): bool {
|
||||
$featureManager = VectorServices::getFeatureManager();
|
||||
|
||||
return $featureManager->isFeatureEnabled( Constants::FEATURE_USE_WVUI_SEARCH ) &&
|
||||
$this->getConfig()->get( 'VectorWvuiSearchOptions' )['showThumbnail'];
|
||||
return $this->getConfig()->get( 'VectorWvuiSearchOptions' )['showThumbnail'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -140,7 +140,7 @@ function markLoadEnd( startMarker, endMarker, measureMarker ) {
|
|||
*/
|
||||
function initSearchLoader( document ) {
|
||||
var searchBoxes = document.querySelectorAll( '.vector-search-box' ),
|
||||
shouldUseCoreSearch;
|
||||
isWikidata = mw.config.get( 'wgWikiID' ) === 'wikidatawiki';
|
||||
|
||||
// Allow developers to defined $wgVectorSearchHost in LocalSettings to target different APIs
|
||||
if ( config.wgVectorSearchHost ) {
|
||||
|
@ -151,28 +151,16 @@ function initSearchLoader( document ) {
|
|||
return;
|
||||
}
|
||||
|
||||
shouldUseCoreSearch = !document.body.classList.contains( 'skin-vector-search-vue' );
|
||||
|
||||
/**
|
||||
* 1. If $wgVectorUseWvuiSearch is false,
|
||||
* or we are in a browser that doesn't support fetch
|
||||
* load the legacy searchSuggest module. The check for window.fetch
|
||||
* 1. If we are in a browser that doesn't support fetch fall back to non-JS version.
|
||||
* The check for window.fetch
|
||||
* can be removed when IE11 support is finally officially dropped.
|
||||
* 2. If we're using a different search module, enable the loading indicator
|
||||
* before the search module loads.
|
||||
* 2. Disable on Wikidata per T281318 until the REST API is ready.
|
||||
**/
|
||||
if ( shouldUseCoreSearch || !window.fetch ) {
|
||||
Array.prototype.forEach.call( searchBoxes, function ( searchBox ) {
|
||||
var input = searchBox.querySelector( 'input[name="search"]' );
|
||||
if ( input ) {
|
||||
loadSearchModule(
|
||||
input,
|
||||
'mediawiki.searchSuggest',
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
} );
|
||||
if ( isWikidata || !window.fetch ) {
|
||||
document.body.classList.remove(
|
||||
'skin-vector-search-vue'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -403,17 +403,10 @@
|
|||
"value": "1",
|
||||
"description": "@var string:['2'|'1'] The version ('2' for latest, '1' for legacy) of the Vector skin to **set** for newly created user accounts. **The value is persisted as a user preference.** This configuration is not used for preexisting accounts (see VectorDefaultSkinVersionForExistingAccounts) and only ever executed once at new account creation time."
|
||||
},
|
||||
"VectorUseWvuiSearch": {
|
||||
"value": true
|
||||
},
|
||||
"VectorSkinMigrationMode": {
|
||||
"value": false,
|
||||
"description": "@internal. For usage to fulfil [[phab:T291098]]"
|
||||
},
|
||||
"VectorSearchTreatmentABTest": {
|
||||
"value": false,
|
||||
"description": "@var boolean Enables or disables the search treatment A/B test. See https://phabricator.wikimedia.org/T261647 and associated tasks for additional detail."
|
||||
},
|
||||
"VectorWvuiSearchOptions": {
|
||||
"value": {
|
||||
"showThumbnail": true,
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
namespace Vector\FeatureManagement\Tests;
|
||||
|
||||
use HashConfig;
|
||||
use User;
|
||||
use Vector\Constants;
|
||||
use Vector\FeatureManagement\Requirements\WvuiSearchTreatmentRequirement;
|
||||
|
||||
/**
|
||||
* @group Vector
|
||||
* @group FeatureManagement
|
||||
* @coversDefaultClass \Vector\FeatureManagement\Requirements\WvuiSearchTreatmentRequirement
|
||||
*/
|
||||
class WvuiSearchTreatmentRequirementTest extends \MediaWikiUnitTestCase {
|
||||
|
||||
public function providerWvuiSearchTreatmentRequirement() {
|
||||
return [
|
||||
[
|
||||
// Is wvui search enabled
|
||||
false,
|
||||
// is A-B test enabled
|
||||
false,
|
||||
// note 0 = anon user
|
||||
0,
|
||||
false,
|
||||
'If nothing enabled nobody gets wvui search'
|
||||
],
|
||||
[
|
||||
// Is wvui search enabled
|
||||
true,
|
||||
// is A-B test enabled
|
||||
false,
|
||||
// note 0 = anon user
|
||||
0,
|
||||
true,
|
||||
'Anon users should get wvui search if enabled when A/B test disabled'
|
||||
],
|
||||
[
|
||||
// Is wvui search enabled
|
||||
true,
|
||||
// is A-B test enabled
|
||||
false,
|
||||
2,
|
||||
true,
|
||||
'Logged in users should get wvui search if enabled when A/B test disabled'
|
||||
],
|
||||
[
|
||||
// Is wvui search enabled
|
||||
true,
|
||||
// is A-B test enabled
|
||||
false,
|
||||
1,
|
||||
true,
|
||||
'All odd logged in users should get wvui search when A/B test disabled'
|
||||
],
|
||||
[
|
||||
// Is wvui search enabled
|
||||
true,
|
||||
// is A-B test enabled
|
||||
true,
|
||||
// note 0 = anon user
|
||||
0,
|
||||
true,
|
||||
'Anon users with a/b test enabled should see wvui search when search config enabled'
|
||||
],
|
||||
[
|
||||
// Is wvui search enabled
|
||||
true,
|
||||
// is A-B test enabled
|
||||
true,
|
||||
2,
|
||||
true,
|
||||
'Even logged in users get wvui search when A/B test enabled'
|
||||
],
|
||||
[
|
||||
// Is wvui search enabled
|
||||
true,
|
||||
// is A-B test enabled
|
||||
true,
|
||||
1,
|
||||
false,
|
||||
'Odd logged in users do not wvui search when A/B test enabled'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::isMet
|
||||
* @dataProvider providerWvuiSearchTreatmentRequirement
|
||||
* @param bool $wvuiSearchConfigValue
|
||||
* @param bool $abValue
|
||||
* @param int $userId
|
||||
* @param bool $expected
|
||||
* @param string $msg
|
||||
*/
|
||||
public function testWvuiSearchTreatmentRequirement(
|
||||
$wvuiSearchConfigValue, $abValue, $userId, $expected, $msg
|
||||
) {
|
||||
$config = new HashConfig( [
|
||||
Constants::CONFIG_KEY_USE_WVUI_SEARCH => $wvuiSearchConfigValue,
|
||||
Constants::CONFIG_SEARCH_TREATMENT_AB_TEST => $abValue,
|
||||
] );
|
||||
|
||||
$user = $this->createMock( User::class );
|
||||
$user->method( 'isRegistered' )->willReturn( $userId !== 0 );
|
||||
$user->method( 'getID' )->willReturn( $userId );
|
||||
|
||||
$requirement = new WvuiSearchTreatmentRequirement(
|
||||
$config, $user
|
||||
);
|
||||
|
||||
$this->assertSame( $expected, $requirement->isMet(), $msg );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue