resourceloader: Deprecate ResourceLoaderContext::getConfig and ::getLogger
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 11 Apr 2019 22:22:08 +0000 (23:22 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 13 Jun 2019 17:28:58 +0000 (18:28 +0100)
The methods existed for two use cases.

1. Inside ResourceLoaderContext, usage was removed with I4e4ee758cd22.
2. In Module class methods that get $context, already have their own
   Config and Logger instances injected from ResourceLoader::getModule(),
   which should be used instead.

Deprecating these opens the paths for making ResourceLoaderContext
a purer value object with no ResourceLoader, Config, or Logger objects
needing to be passed (in the future).

Bug: T32956
Change-Id: I74a9535918ea43b2c00073c5d4469f864d1eeb41

RELEASE-NOTES-1.34
includes/resourceloader/ResourceLoaderContext.php
includes/resourceloader/ResourceLoaderStartUpModule.php
tests/phpunit/includes/resourceloader/ResourceLoaderContextTest.php

index 33d060d..5391c98 100644 (file)
@@ -258,6 +258,9 @@ because of Phabricator reports.
 * DatabaseBlock::setCookie, DatabaseBlock::getCookieValue,
   DatabaseBlock::getIdFromCookieValue and AbstractBlock::shouldTrackWithCookie
   are moved to internal helper methods for BlockManager::trackBlockWithCookie.
+* ResourceLoaderContext::getConfig and ResourceLoaderContext::getLogger have
+  been deprecated. Inside ResourceLoaderModule subclasses, use the local methods
+  instead. Elsewhere, use the methods from the ResourceLoader class.
 
 === Other changes in 1.34 ===
 * …
index 58152ea..c596a23 100644 (file)
@@ -134,6 +134,8 @@ class ResourceLoaderContext implements MessageLocalizer {
        }
 
        /**
+        * @deprecated since 1.34 Use ResourceLoaderModule::getConfig instead
+        * inside module methods. Use ResourceLoader::getConfig elsewhere.
         * @return Config
         */
        public function getConfig() {
@@ -148,6 +150,8 @@ class ResourceLoaderContext implements MessageLocalizer {
        }
 
        /**
+        * @deprecated since 1.34 Use ResourceLoaderModule::getLogger instead
+        * inside module methods. Use ResourceLoader::getLogger elsewhere.
         * @since 1.27
         * @return \Psr\Log\LoggerInterface
         */
index d6cc646..efed418 100644 (file)
@@ -258,7 +258,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        }
 
                        if ( $versionHash !== '' && strlen( $versionHash ) !== 7 ) {
-                               $context->getLogger()->warning(
+                               $this->getLogger()->warning(
                                        "Module '{module}' produced an invalid version hash: '{version}'.",
                                        [
                                                'module' => $name,
index 7f4d9a8..2ec8ea9 100644 (file)
@@ -47,8 +47,10 @@ class ResourceLoaderContextTest extends PHPUnit\Framework\TestCase {
 
        public function testAccessors() {
                $ctx = new ResourceLoaderContext( $this->getResourceLoader(), new FauxRequest( [] ) );
+               $this->assertInstanceOf( ResourceLoader::class, $ctx->getResourceLoader() );
+               $this->assertInstanceOf( Config::class, $ctx->getConfig() );
                $this->assertInstanceOf( WebRequest::class, $ctx->getRequest() );
-               $this->assertInstanceOf( \Psr\Log\LoggerInterface::class, $ctx->getLogger() );
+               $this->assertInstanceOf( Psr\Log\LoggerInterface::class, $ctx->getLogger() );
        }
 
        public function testTypicalRequest() {