Improve how we render help messages in preferences

* The 'help' parameter expects a string, not a Message object. It
  seemed to be working, but caused fatals when switching the
  preferences form to the OOUI implementation (T117781).
* Use 'help-message' instead, which also avoids using the global
  request context for Message objects.

Bug: T117781
Change-Id: I5b2e44df35a2696da0e7ba8394eccf41914f6dda
This commit is contained in:
Bartosz Dziewoński 2017-09-12 18:53:40 +02:00
parent dfad838fa7
commit 2b637e42ef
2 changed files with 4 additions and 4 deletions

View file

@ -76,7 +76,7 @@ class PopupsHooks {
$option = [
'type' => 'radio',
'label-message' => 'popups-prefs-optin-title',
'help' => wfMessage( 'popups-prefs-conflicting-gadgets-info' ),
'help-message' => 'popups-prefs-conflicting-gadgets-info',
'options' => [
wfMessage( 'popups-prefs-optin-enabled-label' )->text()
=> PopupsContext::PREVIEWS_ENABLED,
@ -87,8 +87,8 @@ class PopupsHooks {
];
if ( $context->conflictsWithNavPopupsGadget( $user ) ) {
$option[ 'disabled' ] = true;
$option[ 'help' ] = wfMessage( 'popups-prefs-disable-nav-gadgets-info',
'Special:Preferences#mw-prefsection-gadgets' );
$option[ 'help-message' ] = [ 'popups-prefs-disable-nav-gadgets-info',
'Special:Preferences#mw-prefsection-gadgets' ];
}
$skinPosition = array_search( 'skin', array_keys( $prefs ) );

View file

@ -105,7 +105,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
$prefs[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME ] );
$this->assertEquals( true,
$prefs[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME]['disabled'] );
$this->assertNotEmpty( $prefs[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME]['help'] );
$this->assertNotEmpty( $prefs[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME]['help-message'] );
}
/**