From 0bd3a303439611bc62bccb16e996a85df77813f3 Mon Sep 17 00:00:00 2001 From: Func Date: Sun, 16 Jan 2022 13:01:54 +0000 Subject: [PATCH] Use field name for the hide-if statement Field name without 'wp' prefix (which is used as the key in html descriptor) is required. After I58f9df384df8ecc5ebae8cac68ec2251351bc984, values of fields that are supposed to be disabled would be loaded from default, use a miss-matched field name would be treated as disabled. It works in UI now, but it's not a good idea to strip the 'wp' prefix on the server-side. Bug: T298819 Change-Id: If98368ad400986afaef3187867f201044ebf0efb --- includes/Hooks.php | 4 ++-- .../HTMLForm/Fields/HTMLLegacySkinVersionFieldTest.php | 2 +- tests/phpunit/integration/VectorHooksTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/Hooks.php b/includes/Hooks.php index b6dd659ce..08cf2fd6a 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -428,8 +428,8 @@ class Hooks { // Only show this section when the Vector skin is checked. The JavaScript client also uses // this state to determine whether to show or hide the whole section. // If migration mode is enabled, the section is always hidden. - 'hide-if' => self::isMigrationMode() ? [ '!==', 'wpskin', '0' ] : - [ '!==', 'wpskin', Constants::SKIN_NAME_LEGACY ], + 'hide-if' => self::isMigrationMode() ? [ '!==', 'skin', '0' ] : + [ '!==', 'skin', Constants::SKIN_NAME_LEGACY ], ], Constants::PREF_KEY_SIDEBAR_VISIBLE => [ 'type' => 'api', diff --git a/tests/phpunit/integration/HTMLForm/Fields/HTMLLegacySkinVersionFieldTest.php b/tests/phpunit/integration/HTMLForm/Fields/HTMLLegacySkinVersionFieldTest.php index 1fdfda5bd..57108297a 100644 --- a/tests/phpunit/integration/HTMLForm/Fields/HTMLLegacySkinVersionFieldTest.php +++ b/tests/phpunit/integration/HTMLForm/Fields/HTMLLegacySkinVersionFieldTest.php @@ -72,7 +72,7 @@ class HTMLLegacySkinVersionFieldTest extends \MediaWikiIntegrationTestCase { 'label-message' => 'prefs-vector-enable-vector-1-label', 'help-message' => 'prefs-vector-enable-vector-1-help', 'default' => true, - 'hide-if' => [ '!==', 'wpskin', Constants::SKIN_NAME_LEGACY ], + 'hide-if' => [ '!==', 'skin', Constants::SKIN_NAME_LEGACY ], ]; $skinVersionField = new HTMLLegacySkinVersionField( $params ); $checkField = new \HTMLCheckField( $params ); diff --git a/tests/phpunit/integration/VectorHooksTest.php b/tests/phpunit/integration/VectorHooksTest.php index eae7f22d7..87dafb60c 100644 --- a/tests/phpunit/integration/VectorHooksTest.php +++ b/tests/phpunit/integration/VectorHooksTest.php @@ -17,7 +17,7 @@ use Vector\HTMLForm\Fields\HTMLLegacySkinVersionField; * @coversDefaultClass \Vector\Hooks */ class VectorHooksTest extends MediaWikiIntegrationTestCase { - private const HIDE_IF = [ '!==', 'wpskin', Constants::SKIN_NAME_LEGACY ]; + private const HIDE_IF = [ '!==', 'skin', Constants::SKIN_NAME_LEGACY ]; private const SKIN_PREFS_SECTION = 'rendering/skin/skin-prefs';