From 764122c00039352ce7bdea322fa13a160645f868 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 17 Nov 2015 21:14:17 +0000 Subject: [PATCH] resourceloader: Reformat code around member grouping in ResourceLoaderContext * No effective change. Only code reformatting. * Logically group related members. * Break up items one per line in getHash(). Change-Id: I8ccbe9d071a5c39f5c3d36d0d990574fb0ed8d72 --- .../resourceloader/ResourceLoaderContext.php | 29 ++++++++++++++----- .../DerivativeResourceLoaderContextTest.php | 4 +-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/includes/resourceloader/ResourceLoaderContext.php b/includes/resourceloader/ResourceLoaderContext.php index 6ecee4c6de..5ea47693c7 100644 --- a/includes/resourceloader/ResourceLoaderContext.php +++ b/includes/resourceloader/ResourceLoaderContext.php @@ -33,19 +33,24 @@ class ResourceLoaderContext { protected $resourceLoader; protected $request; - protected $modules; - protected $language; - protected $direction; + + // Module content vary protected $skin; - protected $user; + protected $language; protected $debug; + protected $user; + + // Request vary (in addition to cache vary) + protected $modules; protected $only; protected $version; - protected $hash; protected $raw; protected $image; protected $variant; protected $format; + + protected $direction; + protected $hash; protected $userObj; protected $imageObj; @@ -346,9 +351,17 @@ class ResourceLoaderContext { public function getHash() { if ( !isset( $this->hash ) ) { $this->hash = implode( '|', array( - $this->getLanguage(), $this->getSkin(), $this->getUser(), - $this->getImage(), $this->getVariant(), $this->getFormat(), - $this->getDebug(), $this->getOnly(), $this->getVersion() + // Module content vary + $this->getLanguage(), + $this->getSkin(), + $this->getDebug(), + $this->getUser(), + // Request vary + $this->getOnly(), + $this->getVersion(), + $this->getImage(), + $this->getVariant(), + $this->getFormat(), ) ); } return $this->hash; diff --git a/tests/phpunit/includes/resourceloader/DerivativeResourceLoaderContextTest.php b/tests/phpunit/includes/resourceloader/DerivativeResourceLoaderContextTest.php index b457ceca70..ee9d766e08 100644 --- a/tests/phpunit/includes/resourceloader/DerivativeResourceLoaderContextTest.php +++ b/tests/phpunit/includes/resourceloader/DerivativeResourceLoaderContextTest.php @@ -25,7 +25,7 @@ class DerivativeResourceLoaderContextTest extends PHPUnit_Framework_TestCase { $this->assertEquals( $derived->getModules(), array( 'test.context' ) ); $this->assertEquals( $derived->getOnly(), 'scripts' ); $this->assertEquals( $derived->getSkin(), 'fallback' ); - $this->assertEquals( $derived->getHash(), 'zh|fallback||||||scripts|' ); + $this->assertEquals( $derived->getHash(), 'zh|fallback|||scripts||||' ); } public function testSetLanguage() { @@ -72,7 +72,7 @@ class DerivativeResourceLoaderContextTest extends PHPUnit_Framework_TestCase { $derived->setLanguage( 'nl' ); // Assert that subclass is able to clear parent class "hash" member - $this->assertEquals( $derived->getHash(), 'nl|fallback||||||scripts|' ); + $this->assertEquals( $derived->getHash(), 'nl|fallback|||scripts||||' ); } } -- 2.20.1