From b41930486fec01826ed4affcf80b0fc470efd907 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 5 Jul 2018 20:35:03 +0200 Subject: [PATCH] Avoid duplicate IDs on Special:Preferences The value of the 'section' parameter is used to generate some ID attributes on Special:Preferences. Awkwardly, only the second part (after the slash) is used, so have to ensure these are unique. It is also used for the default localisation message for the title of the section. Override this so that we don't have to rename and duplicate the messages. Bug: T198875 Change-Id: I0f22aafc8b2ad860dd42c5373eafdf88e848e3ad --- includes/preferences/DefaultPreferencesFactory.php | 4 ++-- includes/specials/forms/PreferencesFormLegacy.php | 3 ++- includes/specials/forms/PreferencesFormOOUI.php | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php index 03e4bdbd20..bcd15b3b9f 100644 --- a/includes/preferences/DefaultPreferencesFactory.php +++ b/includes/preferences/DefaultPreferencesFactory.php @@ -1080,7 +1080,7 @@ class DefaultPreferencesFactory implements PreferencesFactory { if ( $this->config->get( 'StructuredChangeFiltersShowPreference' ) ) { $defaultPreferences['rcenhancedfilters-disable'] = [ 'type' => 'toggle', - 'section' => 'rc/opt-out', + 'section' => 'rc/optoutrc', 'label-message' => 'rcfilters-preference-label', 'help-message' => 'rcfilters-preference-help', ]; @@ -1283,7 +1283,7 @@ class DefaultPreferencesFactory implements PreferencesFactory { if ( $this->config->get( 'StructuredChangeFiltersShowWatchlistPreference' ) ) { $defaultPreferences['wlenhancedfilters-disable'] = [ 'type' => 'toggle', - 'section' => 'watchlist/opt-out', + 'section' => 'watchlist/optoutwatchlist', 'label-message' => 'rcfilters-watchlist-preference-label', 'help-message' => 'rcfilters-watchlist-preference-help', ]; diff --git a/includes/specials/forms/PreferencesFormLegacy.php b/includes/specials/forms/PreferencesFormLegacy.php index cae895f626..c1f1026691 100644 --- a/includes/specials/forms/PreferencesFormLegacy.php +++ b/includes/specials/forms/PreferencesFormLegacy.php @@ -130,7 +130,8 @@ class PreferencesFormLegacy extends HTMLForm { * @return string */ function getLegend( $key ) { - $legend = parent::getLegend( $key ); + $aliasKey = ( $key === 'optoutwatchlist' || $key === 'optoutrc' ) ? 'opt-out' : $key; + $legend = parent::getLegend( $aliasKey ); Hooks::run( 'PreferencesGetLegend', [ $this, $key, &$legend ] ); return $legend; } diff --git a/includes/specials/forms/PreferencesFormOOUI.php b/includes/specials/forms/PreferencesFormOOUI.php index 423e2bb80a..cfa8f8fa1d 100644 --- a/includes/specials/forms/PreferencesFormOOUI.php +++ b/includes/specials/forms/PreferencesFormOOUI.php @@ -227,7 +227,8 @@ class PreferencesFormOOUI extends OOUIHTMLForm { * @return string */ function getLegend( $key ) { - $legend = parent::getLegend( $key ); + $aliasKey = ( $key === 'optoutwatchlist' || $key === 'optoutrc' ) ? 'opt-out' : $key; + $legend = parent::getLegend( $aliasKey ); Hooks::run( 'PreferencesGetLegend', [ $this, $key, &$legend ] ); return $legend; } -- 2.20.1