Add config var to disable Beta Feature

Add new $wgWikiEditorRealtimePreviewBeta configuration variable
to make it possible to turn off the RTP Beta Feature even when
the BetaFeatures extension is installed.

Bug: T323033
Change-Id: Ib79f4eaee9cee7404ff883f5e0685610d9dba9d9
This commit is contained in:
Sam Wilson 2023-01-09 22:58:54 +08:00 committed by MusikAnimal
parent cf73418e9c
commit 68c6d366ce
2 changed files with 8 additions and 3 deletions

View file

@ -452,9 +452,13 @@
},
"config": {
"WikiEditorRealtimePreview": {
"description": "Whether to enable the Realtime Preview feature.",
"description": "Whether to enable the Realtime Preview feature. If true, the feature might still be limited to a beta feature depending on WikiEditorRealtimePreviewBeta and general beta feature availability. If false, the feature is not available in any form.",
"value": false
},
"WikiEditorRealtimePreviewBeta": {
"description": "Offer Realtime Preview as a Beta Feature (assuming the BetaFeatures extension is installed). If false, WikiEditorRealtimePreview directly controls whether the feature is enabled or not.",
"value": true
},
"WikiEditorRealtimePreviewDebounce": {
"description": "Debounce time in milliseconds for the Realtime Preview feature.",
"value": 2500

View file

@ -245,8 +245,9 @@ class Hooks implements
$user = $article->getContext()->getUser();
$betaFeatureEnabled = $betaFeaturesInstalled &&
BetaFeatures::isFeatureEnabled( $user, 'wikieditor-realtime-preview' );
$useBetaFeature = $this->config->get( 'WikiEditorRealtimePreviewBeta' );
if ( $this->config->get( 'WikiEditorRealtimePreview' ) &&
( $betaFeatureEnabled || !$betaFeaturesInstalled )
( $useBetaFeature && $betaFeatureEnabled || !$betaFeaturesInstalled || !$useBetaFeature )
) {
$outputPage->addModules( 'ext.wikiEditor.realtimepreview' );
}
@ -603,7 +604,7 @@ class Hooks implements
*/
public static function onGetBetaFeaturePreferences( $user, &$prefs ) {
$config = MediaWikiServices::getInstance()->getMainConfig();
if ( !$config->get( 'WikiEditorRealtimePreview' ) ) {
if ( !$config->get( 'WikiEditorRealtimePreview' ) || !$config->get( 'WikiEditorRealtimePreviewBeta' ) ) {
return;
}
$extensionAssetsPath = $config->get( 'ExtensionAssetsPath' );