From e9608cc17d6f2383f7e0f05ae17aa0f57d23c242 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 22 Nov 2020 23:07:27 +0000 Subject: [PATCH] Revert "Deprecate Skin::setupSkinUserCss" The commit did not really hard-deprecate overriding of setupSkinUserCss() as stated in the commit message, rather it removed core calls to setupSkinUserCss(), instantly breaking the many skins that still override it. It did not actually create a deprecation period for graceful migration. As discussed in T267080, there is presently no way to hard-deprecate the override of a method. This reverts commit 334cfeffd66462001fb5053bb5d9f0d70fc3a4ad. Bug: T257990 Change-Id: I8f669ba30affc437800890c3a875994a9f2eb3c8 --- includes/OutputPage.php | 1 + includes/api/ApiParse.php | 2 ++ includes/skins/Skin.php | 2 +- tests/phpunit/includes/api/ApiParseTest.php | 11 ++++++----- tests/phpunit/includes/skins/SkinTest.php | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index d4544e8589c..a93e9531bfd 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2993,6 +2993,7 @@ class OutputPage extends ContextSource { 'noscript', 'user.styles', ] ); + $this->getSkin()->setupSkinUserCss( $this ); // Prepare exempt modules for buildExemptModules() $exemptGroups = [ 'site' => [], 'noscript' => [], 'private' => [], 'user' => [] ]; diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 61fc052d523..3f7fdd0fdcd 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -388,6 +388,8 @@ class ApiParse extends ApiBase { $context->setOutput( $outputPage ); if ( $skin ) { + // Based on OutputPage::headElement() + $skin->setupSkinUserCss( $outputPage ); // Based on OutputPage::output() $outputPage->loadSkinModules( $skin ); } diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 19ecf4d4cd6..4c40a0f070e 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -454,7 +454,7 @@ abstract class Skin extends ContextSource { * @param OutputPage $out Legacy parameter, identical to $this->getOutput() */ public function setupSkinUserCss( OutputPage $out ) { - wfDeprecated( __METHOD__, '1.32' ); + // Stub. } /** diff --git a/tests/phpunit/includes/api/ApiParseTest.php b/tests/phpunit/includes/api/ApiParseTest.php index 70bf2254345..f1474ca94b2 100644 --- a/tests/phpunit/includes/api/ApiParseTest.php +++ b/tests/phpunit/includes/api/ApiParseTest.php @@ -159,17 +159,18 @@ class ApiParseTest extends ApiTestCase { $factory = new SkinFactory( new ObjectFactory( $this->createMock( ContainerInterface::class ) ), [] ); $factory->register( 'testing', 'Testing', function () { $skin = $this->getMockBuilder( SkinFallback::class ) - ->setMethods( [ 'getDefaultModules' ] ) + ->setMethods( [ 'getDefaultModules', 'setupSkinUserCss' ] ) ->getMock(); $skin->expects( $this->once() )->method( 'getDefaultModules' ) ->willReturn( [ - 'styles' => [ - 'user' => [ 'foo.styles' ], - 'core' => [ 'quux.styles' ] - ], + 'styles' => [ 'core' => [ 'quux.styles' ] ], 'core' => [ 'foo', 'bar' ], 'content' => [ 'baz' ] ] ); + $skin->expects( $this->once() )->method( 'setupSkinUserCss' ) + ->will( $this->returnCallback( function ( OutputPage $out ) { + $out->addModuleStyles( 'foo.styles' ); + } ) ); return $skin; } ); $this->setService( 'SkinFactory', $factory ); diff --git a/tests/phpunit/includes/skins/SkinTest.php b/tests/phpunit/includes/skins/SkinTest.php index c33b75ab5d1..e3f605a398c 100644 --- a/tests/phpunit/includes/skins/SkinTest.php +++ b/tests/phpunit/includes/skins/SkinTest.php @@ -7,7 +7,7 @@ class SkinTest extends MediaWikiIntegrationTestCase { */ public function testGetDefaultModules() { $skin = $this->getMockBuilder( Skin::class ) - ->setMethods( [ 'outputPage' ] ) + ->setMethods( [ 'outputPage', 'setupSkinUserCss' ] ) ->getMock(); $modules = $skin->getDefaultModules();