r98603 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98602‎ | r98603 | r98604 >
Date:05:03, 1 October 2011
Author:aaron
Status:ok
Tags:
Comment:
Reverted stuff from r98602 committed by mistake
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoader.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoader.php
@@ -353,18 +353,8 @@
354354 * @param $context ResourceLoaderContext: Context in which a response should be formed
355355 */
356356 public function respond( ResourceLoaderContext $context ) {
357 - global $wgCacheEpoch, $wgUseFileCache;
 357+ global $wgCacheEpoch;
358358
359 - // Use file cache if enabled and available...
360 - if ( $wgUseFileCache ) {
361 - $type = 'resources-' . ( $context->getOnly() === 'styles' ? 'css' : 'js' );
362 - $hash = sha1( $context->getHash() . implode( ',', $context->getModules() ) );
363 - $fileCache = ObjectFileCache::newFromKey( $hash, $type );
364 - if ( $this->tryRespondFromFileCache( $fileCache, $context ) ) {
365 - return; // output handled
366 - }
367 - }
368 -
369359 // Buffer output to catch warnings. Normally we'd use ob_clean() on the
370360 // top-level output buffer to clear warnings, but that breaks when ob_gzhandler
371361 // is used: ob_clean() will clear the GZIP header in that case and it won't come
@@ -442,15 +432,6 @@
443433 ob_end_clean();
444434 echo $response;
445435
446 - // Save response to file cache if enabled
447 - if ( isset( $fileCache ) && !$private && !$exceptions && !$missing ) {
448 - $request = $context->getRequest();
449 - // Don't cache URLs that the user was not given by site
450 - if ( $request->getVal( 'fckey' ) == self::fileCacheKey( $request->getRequestURL() ) ) {
451 - $fileCache->saveText( $response );
452 - }
453 - }
454 -
455436 wfProfileOut( __METHOD__ );
456437 }
457438
@@ -539,50 +520,6 @@
540521 }
541522
542523 /**
543 - * Send out code for a response from file cache if possible
544 - *
545 - * @param $fileCache ObjectFileCache: Cache object for this request URL
546 - * @param $context ResourceLoaderContext: Context in which to generate a response
547 - * @return bool If this found a cache file and handled the response
548 - */
549 - protected function tryRespondFromFileCache(
550 - ObjectFileCache $fileCache, ResourceLoaderContext $context
551 - ) {
552 - global $wgResourceLoaderMaxage;
553 - // Buffer output to catch warnings.
554 - ob_start();
555 - // Get the maximum age the cache can be
556 - $maxage = is_null( $context->getVersion() )
557 - ? $wgResourceLoaderMaxage['unversioned']['server']
558 - : $wgResourceLoaderMaxage['versioned']['server'];
559 - // Minimum timestamp the cache file must have
560 - $good = $fileCache->isCacheGood( wfTimestamp( TS_MW, time() - $maxage ) );
561 - if ( !$good ) {
562 - try { // RL always hits the DB on file cache miss...
563 - wfGetDB( DB_SLAVE );
564 - } catch( DBConnectionError $e ) { // ...check if we need to fallback to cache
565 - $good = $fileCache->isCacheGood(); // cache existence check
566 - }
567 - }
568 - if ( $good ) {
569 - $ts = $fileCache->cacheTimestamp();
570 - // Send content type and cache headers
571 - $this->sendResponseHeaders( $context, $ts, false );
572 - // If there's an If-Modified-Since header, respond with a 304 appropriately
573 - if ( $this->tryRespondLastModified( $context, $ts ) ) {
574 - return; // output handled (buffers cleared)
575 - }
576 - $response = $fileCache->fetchText();
577 - // Remove the output buffer and output the response
578 - ob_end_clean();
579 - echo $response . "\n/* Cached {$ts} */";
580 - return true; // cache hit
581 - }
582 - ob_end_clean();
583 - return false; // cache miss
584 - }
585 -
586 - /**
587524 * Generates code for a response
588525 *
589526 * @param $context ResourceLoaderContext: Context in which to generate a response
@@ -975,32 +912,17 @@
976913 */
977914 public static function makeLoaderURL( $modules, $lang, $skin, $user = null, $version = null, $debug = false, $only = null,
978915 $printable = false, $handheld = false, $extraQuery = array() ) {
979 - global $wgLoadScript, $wgUseFileCache;
 916+ global $wgLoadScript;
980917 $query = self::makeLoaderQuery( $modules, $lang, $skin, $user, $version, $debug,
981918 $only, $printable, $handheld, $extraQuery
982919 );
983 -
984 - $url = wfAppendQuery( $wgLoadScript, $query );
985 - // Avoid deliberate FS pollution with hand-made URLs
986 - if ( $wgUseFileCache ) {
987 - $url .= '&fckey=' . self::fileCacheKey( $url . '&*' );
988 - }
989 -
 920+
990921 // Prevent the IE6 extension check from being triggered (bug 28840)
991 - // by appending a character that's invalid in Windows extensions ('*')
992 - return $url . '&*';
 922+ // by appending a character that's invalid in Windows extensions ('*')
 923+ return wfExpandUrl( wfAppendQuery( $wgLoadScript, $query ) . '&*', PROTO_RELATIVE );
993924 }
994925
995926 /**
996 - * Get a filecache key for a load.php URL
997 - * @return string
998 - */
999 - protected static function fileCacheKey( $url ) {
1000 - global $wgSecretKey;
1001 - return sha1( preg_replace( '/&fckey=[^&]*/', '', $url ) . $wgSecretKey . wfWikiID() );
1002 - }
1003 -
1004 - /**
1005927 * Build a query array (array representation of query string) for load.php. Helper
1006928 * function for makeLoaderURL().
1007929 * @return array

Follow-up revisions

RevisionCommit summaryAuthorDate
r98604MFT r98602, r98603aaron05:06, 1 October 2011
r102519REL1_18 MFT r98602, r98603, r98605reedy15:00, 9 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98602Made provideIPCIDRs() not add a '/' if there is no prefix length. Fixes bug 3...aaron04:54, 1 October 2011

Status & tagging log