r73568 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73567‎ | r73568 | r73569 >
Date:20:44, 22 September 2010
Author:tparscal
Status:ok
Tags:
Comment:
* Added $wgResourceLoaderDebug, a default fallback for debug mode which can be overridden by the debug URL parameter a la $wgLanguageCode
* Merged $wgResourceLoader(Unv|V)ersioned(Client|Server)Maxage vars into $wgResourceLoaderMaxage, which contains an array of the same values.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/ResourceLoader.php (modified) (history)
  • /trunk/phase3/includes/ResourceLoaderContext.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ResourceLoaderContext.php
@@ -40,7 +40,7 @@
4141 /* Methods */
4242
4343 public function __construct( WebRequest $request ) {
44 - global $wgLang, $wgDefaultSkin;
 44+ global $wgLang, $wgDefaultSkin, $wgResourceLoaderDebug;
4545
4646 $this->request = $request;
4747 // Interperet request
@@ -49,7 +49,7 @@
5050 $this->direction = $request->getVal( 'dir' );
5151 $this->skin = $request->getVal( 'skin' );
5252 $this->user = $request->getVal( 'user' );
53 - $this->debug = $request->getFuzzyBool( 'debug' );
 53+ $this->debug = $request->getFuzzyBool( 'debug', $wgResourceLoaderDebug );
5454 $this->only = $request->getVal( 'only' );
5555 $this->version = $request->getVal( 'version' );
5656
Index: trunk/phase3/includes/OutputPage.php
@@ -2281,12 +2281,12 @@
22822282 }
22832283
22842284 static function makeResourceLoaderLink( $skin, $modules, $only ) {
2285 - global $wgUser, $wgLang, $wgRequest, $wgLoadScript;
 2285+ global $wgUser, $wgLang, $wgRequest, $wgLoadScript, $wgResourceLoaderDebug;
22862286 // TODO: Should this be a static function of ResourceLoader instead?
22872287 // TODO: Divide off modules starting with "user", and add the user parameter to them
22882288 $query = array(
22892289 'lang' => $wgLang->getCode(),
2290 - 'debug' => $wgRequest->getFuzzyBool( 'debug' ) ? 'true' : 'false',
 2290+ 'debug' => $wgRequest->getFuzzyBool( 'debug', $wgResourceLoaderDebug ) ? 'true' : 'false',
22912291 'skin' => $wgUser->getSkin()->getSkinName(),
22922292 'only' => $only,
22932293 );
@@ -2346,8 +2346,7 @@
23472347 * @return String: HTML fragment
23482348 */
23492349 function getHeadScripts( Skin $sk ) {
2350 - global $wgUser, $wgRequest;
2351 - global $wgUseSiteJs;
 2350+ global $wgUser, $wgRequest, $wgUseSiteJs, $wgResourceLoaderDebug;
23522351
23532352 // Statup - this will immediately load jquery and mediawiki modules
23542353 $scripts = self::makeResourceLoaderLink( $sk, 'startup', 'scripts' );
@@ -2357,7 +2356,7 @@
23582357 $scripts .= Skin::makeGlobalVariablesScript( $sk->getSkinName() ) . "\n";
23592358
23602359 // Script and Messages "only"
2361 - if ( $wgRequest->getFuzzyBool( 'debug' ) ) {
 2360+ if ( $wgRequest->getFuzzyBool( 'debug', $wgResourceLoaderDebug ) ) {
23622361 // Scripts
23632362 foreach ( $this->getModuleScripts() as $name ) {
23642363 $scripts .= self::makeResourceLoaderLink( $sk, $name, 'scripts' );
@@ -2455,7 +2454,7 @@
24562455 * @return string HTML tag links to be put in the header.
24572456 */
24582457 public function getHeadLinks( $sk ) {
2459 - global $wgFeed, $wgRequest;
 2458+ global $wgFeed, $wgRequest, $wgResourceLoaderDebug;
24602459
24612460 // Ideally this should happen earlier, somewhere. :P
24622461 $this->addDefaultMeta();
@@ -2526,7 +2525,7 @@
25272526 }
25282527
25292528 // Support individual script requests in debug mode
2530 - if ( $wgRequest->getFuzzyBool( 'debug' ) ) {
 2529+ if ( $wgRequest->getFuzzyBool( 'debug', $wgResourceLoaderDebug ) ) {
25312530 foreach ( $this->getModuleStyles() as $name ) {
25322531 $tags[] = self::makeResourceLoaderLink( $sk, $name, 'styles' );
25332532 }
Index: trunk/phase3/includes/ResourceLoader.php
@@ -249,8 +249,7 @@
250250 * @param $context ResourceLoaderContext object
251251 */
252252 public static function respond( ResourceLoaderContext $context ) {
253 - global $wgResourceLoaderVersionedClientMaxage, $wgResourceLoaderVersionedServerMaxage;
254 - global $wgResourceLoaderUnversionedServerMaxage, $wgResourceLoaderUnversionedClientMaxage;
 253+ global $wgResourceLoaderMaxage;
255254
256255 wfProfileIn( __METHOD__ );
257256 self::initialize();
@@ -270,14 +269,14 @@
271270 // If a version wasn't specified we need a shorter expiry time for updates to
272271 // propagate to clients quickly
273272 if ( is_null( $context->getVersion() ) ) {
274 - $maxage = $wgResourceLoaderUnversionedClientMaxage;
275 - $smaxage = $wgResourceLoaderUnversionedServerMaxage;
 273+ $maxage = $wgResourceLoaderMaxage['unversioned']['client'];
 274+ $smaxage = $wgResourceLoaderMaxage['unversioned']['server'];
276275 }
277276 // If a version was specified we can use a longer expiry time since changing
278277 // version numbers causes cache misses
279278 else {
280 - $maxage = $wgResourceLoaderVersionedClientMaxage;
281 - $smaxage = $wgResourceLoaderVersionedServerMaxage;
 279+ $maxage = $wgResourceLoaderMaxage['versioned']['client'];
 280+ $smaxage = $wgResourceLoaderMaxage['versioned']['server'];
282281 }
283282
284283 // To send Last-Modified and support If-Modified-Since, we need to detect
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1645,32 +1645,28 @@
16461646 $wgClockSkewFudge = 5;
16471647
16481648 /**
1649 - * Maximum time in seconds to cache versioned resources served by the resource
1650 - * loader on the client side (e.g. in the browser cache).
 1649+ * Maximum time in seconds to cache resources served by the resource loader
16511650 */
1652 -$wgResourceLoaderVersionedClientMaxage = 30 * 24 * 60 * 60; // 30 days
 1651+$wgResourceLoaderMaxage = array(
 1652+ 'versioned' => array(
 1653+ // Squid/Varnish but also any other public proxy cache between the client and MediaWiki
 1654+ 'server' => 30 * 24 * 60 * 60, // 30 days
 1655+ // On the client side (e.g. in the browser cache).
 1656+ 'client' => 30 * 24 * 60 * 60, // 30 days
 1657+ ),
 1658+ 'unversioned' => array(
 1659+ 'server' => 5 * 60, // 5 minutes
 1660+ 'client' => 5 * 60, // 5 minutes
 1661+ ),
 1662+);
16531663
16541664 /**
1655 - * Maximum time in seconds to cache versioned resources served by the resource
1656 - * loader on the server side. This means Squid/Varnish but also any other public
1657 - * proxy cache between the client and MediaWiki.
 1665+ * The default debug mode (on/off) for of ResourceLoader requests. This will still
 1666+ * be overridden when the debug URL parameter is used.
16581667 */
1659 -$wgResourceLoaderVersionedServerMaxage = 30 * 24 * 60 * 60; // 30 days
 1668+$wgResourceLoaderDebug = false;
16601669
16611670 /**
1662 - * Maximum time in seconds to cache unversioned resources served by the resource
1663 - * loader on the client.
1664 - */
1665 -$wgResourceLoaderUnversionedClientMaxage = 5 * 60; // 5 minutes
1666 -
1667 -/**
1668 - * Maximum time in seconds to cache unversioned resources served by the resource
1669 - * loader on the server. This means Squid/Varnish but also any other public
1670 - * proxy cache between the client and MediaWiki.
1671 - */
1672 -$wgResourceLoaderUnversionedServerMaxage = 5 * 60; // 5 minutes
1673 -
1674 -/**
16751671 * Enable data URL embedding (experimental). This variable is very temporary and
16761672 * will be removed once we get this feature stable.
16771673 */
Index: trunk/phase3/RELEASE-NOTES
@@ -57,11 +57,11 @@
5858 * $wgVectorExtraStyles was removed, and is no longer in use.
5959 * $wgLoadScript was added to specify alternative locations for ResourceLoader
6060 requests.
61 -* $wgResourceLoaderVersionedClientMaxage, $wgResourceLoaderVersionedServerMaxage,
62 - $wgResourceLoaderUnversionedClientMaxage and
63 - $wgResourceLoaderUnversionedServerMaxage were added to specify maxage and
64 - smaxage times for responses from ResourceLoader based on whether the request's
65 - URL contained a version parameter or not.
 61+* $wgResourceLoaderMaxage was added to specify maxage and smaxage times for
 62+ responses from ResourceLoader based on whether the request's URL contained a
 63+ version parameter or not.
 64+* $wgResourceLoaderDebug was added to specify the default state of debug mode;
 65+ this will still be overridden with the debug URL parameter a la $wgLanguageCode.
6666
6767 === New features in 1.17 ===
6868 * (bug 10183) Users can now add personal styles and scripts to all skins via

Status & tagging log