From c4e5364ea051131b5ae71ed4ef2557706a384e5e Mon Sep 17 00:00:00 2001 From: Tim Eulitz Date: Mon, 4 Mar 2019 16:40:45 +0100 Subject: [PATCH] Implement temporary rollback confirmation toggle This change implements a temporary feature toggle for the rollback confirmation change. The main purpose is to allow users of certain wikis (de-wiki, pl-wiki, for example) to turn off this upcoming feature before it is released to production. Bug: T217039 Change-Id: I6ed59afde5b75756053da3ae46858304dda9317d --- includes/DefaultSettings.php | 10 ++++++++++ includes/Linker.php | 10 +++++++++- includes/actions/RollbackAction.php | 10 +++++++++- includes/preferences/DefaultPreferencesFactory.php | 11 +++++++++++ languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + 6 files changed, 41 insertions(+), 2 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 91170c4778..3afa593254 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -9049,6 +9049,16 @@ $wgPriorityHints = false; */ $wgElementTiming = false; +/** + * Temporary option to show rollback confirmation user settings + * without activating the feature itself + * @see T217039 + * @since 1.33 + * @deprecated 1.33 + * @var bool + */ +$wgDisableRollbackConfirmationFeature = false; + /** * For really cool vim folding this needs to be at the end: * vim: foldmarker=@{,@} foldmethod=marker diff --git a/includes/Linker.php b/includes/Linker.php index a02d57df01..7dc6541c5f 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1768,7 +1768,15 @@ class Linker { $inner = $context->msg( 'brackets' )->rawParams( $inner )->escaped(); } - if ( $context->getUser()->getBoolOption( 'showrollbackconfirmation' ) ) { + /** + * FIXME + * Remove all references to DisableRollbackConfirmationFeature + * after release of rollback feature. See T199534 + */ + if ( !MediaWikiServices::getInstance() + ->getMainConfig()->get( 'DisableRollbackConfirmationFeature' ) && + $context->getUser()->getBoolOption( 'showrollbackconfirmation' ) + ) { $stats = MediaWikiServices::getInstance()->getStatsdDataFactory(); $stats->increment( 'rollbackconfirmation.event.load' ); $context->getOutput()->addModules( 'mediawiki.page.rollback.confirmation' ); diff --git a/includes/actions/RollbackAction.php b/includes/actions/RollbackAction.php index e2fc265f96..0e86fda81a 100644 --- a/includes/actions/RollbackAction.php +++ b/includes/actions/RollbackAction.php @@ -73,12 +73,20 @@ class RollbackAction extends FormAction { } /** + * @throws ConfigException * @throws ErrorPageError * @throws ReadOnlyError * @throws ThrottledError */ public function show() { - if ( $this->getUser()->getOption( 'showrollbackconfirmation' ) == false || + /** + * FIXME + * Remove temporary check of DisableRollbackConfirmationFeature + * after release of rollback feature. See T199534 + */ + $config = \MediaWiki\MediaWikiServices::getInstance()->getMainConfig(); + if ( $config->get( 'DisableRollbackConfirmationFeature' ) == true || + $this->getUser()->getOption( 'showrollbackconfirmation' ) == false || $this->getRequest()->wasPosted() ) { $this->handleRollbackRequest(); } else { diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php index a42726f7b4..b2f5342ad2 100644 --- a/includes/preferences/DefaultPreferencesFactory.php +++ b/includes/preferences/DefaultPreferencesFactory.php @@ -870,6 +870,17 @@ class DefaultPreferencesFactory implements PreferencesFactory { 'section' => 'rendering/advancedrendering', 'label-message' => 'tog-showrollbackconfirmation', ]; + + /** + * FIXME + * Remove temporary help text and references to DisableRollbackConfirmationFeature + * after release of rollback feature. See T199534 + */ + if ( MediaWikiServices::getInstance() + ->getMainConfig()->get( 'DisableRollbackConfirmationFeature' ) ) { + $defaultPreferences['showrollbackconfirmation'] + ['help-message'] = 'tog-showrollbackconfirmation-prerelease-warning'; + } } } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index db247b90af..85866066ca 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -47,6 +47,7 @@ "tog-useeditwarning": "Warn me when I leave an edit page with unsaved changes", "tog-prefershttps": "Always use a secure connection while logged in", "tog-showrollbackconfirmation": "Show a confirmation prompt when clicking on a rollback link", + "tog-showrollbackconfirmation-prerelease-warning": "Please note: This feature is not available yet. If you set this preference now, your choice will be remembered [https://meta.wikimedia.org/wiki/WMDE_Technical_Wishes/Rollback#Status when the feature is released].", "underline-always": "Always", "underline-never": "Never", "underline-default": "Skin or browser default", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 109bba8359..5305c432a7 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -253,6 +253,7 @@ "tog-useeditwarning": "Used as label for the checkbox in [[Special:Preferences#mw-prefsection-editing|Special:Preferences]].", "tog-prefershttps": "Toggle option used in [[Special:Preferences]] that indicates if the user wants to use a secure connection when logged in", "tog-showrollbackconfirmation": "Toggle option used in [[Special:Preferences]] to enable/disable rollback confirmation prompt. Should be visible only to users with rollback rights.", + "tog-showrollbackconfirmation-prerelease-warning": "Notice for wikis where the option can be set before the feature is enabled.\n\nNote: This notice is temporary and will only appear before the rollback confirmation feature is released.", "underline-always": "Used in [[Special:Preferences#mw-prefsection-rendering|Preferences]].\n\nThis option means \"always underline links\", there are also options {{msg-mw|Underline-never}} and {{msg-mw|Underline-default}}.\n\n{{Gender}}\n{{Identical|Always}}", "underline-never": "Used in [[Special:Preferences#mw-prefsection-rendering|Preferences]].\n\nThis option means \"never underline links\", there are also options {{msg-mw|Underline-always}} and {{msg-mw|Underline-default}}.\n\n{{Gender}}\n{{Identical|Never}}", "underline-default": "Used in [[Special:Preferences#mw-prefsection-rendering|Preferences]].\n\nThis option means \"underline links as in your user skin or your browser\", there are also options {{msg-mw|Underline-never}} and {{msg-mw|Underline-always}}.\n\n{{Gender}}\n{{Identical|Browser default}}", -- 2.20.1