From: Reedy Date: Tue, 29 May 2018 20:24:40 +0000 (+0000) Subject: Fix PreferencesForm alias X-Git-Tag: 1.34.0-rc.0~5257^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=6b6c71558e782812938704503a9585a0a9e2a1a9;hp=765370a6db20c95907abd9ed1b6d4a285638acb3 Fix PreferencesForm alias Change-Id: I6f24c6283b4165b9209e53f8fc3b8ecb5feb9ca4 --- diff --git a/includes/Preferences.php b/includes/Preferences.php index 035b494240..c458af0eab 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -262,12 +262,12 @@ class Preferences { * @param IContextSource $context * @param string $formClass * @param array $remove Array of items to remove - * @return PreferencesForm|HTMLForm + * @return PreferencesFormLegacy|HTMLForm */ public static function getFormObject( $user, IContextSource $context, - $formClass = PreferencesForm::class, + $formClass = PreferencesFormLegacy::class, array $remove = [] ) { $preferencesFactory = self::getDefaultPreferencesFactory(); diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php index 755d108fba..eb94ff1f66 100644 --- a/includes/preferences/DefaultPreferencesFactory.php +++ b/includes/preferences/DefaultPreferencesFactory.php @@ -45,7 +45,7 @@ use MWTimestamp; use OutputPage; use Parser; use ParserOptions; -use PreferencesForm; +use PreferencesFormLegacy; use Psr\Log\LoggerAwareTrait; use Psr\Log\NullLogger; use Skin; @@ -1488,7 +1488,7 @@ class DefaultPreferencesFactory implements PreferencesFactory { public function getForm( User $user, IContextSource $context, - $formClass = PreferencesForm::class, + $formClass = PreferencesFormLegacy::class, array $remove = [] ) { if ( SpecialPreferences::isOouiEnabled( $context ) ) { diff --git a/includes/preferences/PreferencesFactory.php b/includes/preferences/PreferencesFactory.php index 685f78caaf..478edce857 100644 --- a/includes/preferences/PreferencesFactory.php +++ b/includes/preferences/PreferencesFactory.php @@ -28,8 +28,8 @@ use User; * A PreferencesFactory is a MediaWiki service that provides the definitions of preferences for a * given user. These definitions are in the form of an HTMLForm descriptor. * - * PreferencesForm (a subclass of HTMLForm) is used to generate the Preferences form, and handles - * generic submission, CSRF protection, layout and other logic in a reusable manner. + * PreferencesFormLegacy (a subclass of HTMLForm) is used to generate the Preferences form, and + * handles generic submission, CSRF protection, layout and other logic in a reusable manner. * * In order to generate the form, the HTMLForm object needs an array structure detailing the * form fields available, and that's what this implementations of this interface provide. Each @@ -62,7 +62,7 @@ interface PreferencesFactory { public function getForm( User $user, IContextSource $contextSource, - $formClass = \PreferencesForm::class, + $formClass = \PreferencesFormLegacy::class, array $remove = [] ); diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index 27b6a07c73..41ee353a78 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -163,7 +163,7 @@ class SpecialPreferences extends SpecialPage { * Get the preferences form to use. * @param User $user The user. * @param IContextSource $context The context. - * @return PreferencesForm|HTMLForm + * @return PreferencesFormLegacy|HTMLForm */ protected function getFormObject( $user, IContextSource $context ) { $preferencesFactory = MediaWikiServices::getInstance()->getPreferencesFactory(); diff --git a/includes/specials/forms/PreferencesFormLegacy.php b/includes/specials/forms/PreferencesFormLegacy.php index 8193c5a984..48bded4e04 100644 --- a/includes/specials/forms/PreferencesFormLegacy.php +++ b/includes/specials/forms/PreferencesFormLegacy.php @@ -144,9 +144,10 @@ class PreferencesFormLegacy extends HTMLForm { } } -// Retain the old class name for backwards compatibility. -// In the future, this alias will be changed to point to PreferencesFormOOUI. -class PreferencesForm extends PreferencesFormLegacy { -} -// Phan doesn't understand class_alias()? -// class_alias( PreferencesFormLegacy::class, 'PreferencesForm' ); +/** + * Retain the old class name for backwards compatibility. + * In the future, this alias will be changed to point to PreferencesFormOOUI. + * + * @deprecated since 1.32 + */ +class_alias( PreferencesFormLegacy::class, 'PreferencesForm' ); diff --git a/tests/phpunit/includes/preferences/DefaultPreferencesFactoryTest.php b/tests/phpunit/includes/preferences/DefaultPreferencesFactoryTest.php index 62ab44c440..9a8608f475 100644 --- a/tests/phpunit/includes/preferences/DefaultPreferencesFactoryTest.php +++ b/tests/phpunit/includes/preferences/DefaultPreferencesFactoryTest.php @@ -66,7 +66,7 @@ class DefaultPreferencesFactoryTest extends MediaWikiTestCase { public function testGetForm() { $testUser = $this->getTestUser(); $form = $this->getPreferencesFactory()->getForm( $testUser->getUser(), $this->context ); - $this->assertInstanceOf( PreferencesForm::class, $form ); + $this->assertInstanceOf( PreferencesFormLegacy::class, $form ); $this->assertCount( 5, $form->getPreferenceSections() ); }