r72122 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72121‎ | r72122 | r72123 >
Date:17:38, 1 September 2010
Author:catrope
Status:deferred
Tags:
Comment:
resourceloader: Prepend $IP to file names so we're not dependent about the working directory being the MW root
Modified paths:
  • /branches/resourceloader/phase3/includes/ResourceLoaderModule.php (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/includes/ResourceLoaderModule.php
@@ -396,7 +396,7 @@
397397 $this->loaders,
398398 $this->getFileDependencies( $skin )
399399 );
400 - $this->modifiedTime = max( array_map( 'filemtime', $files ) );
 400+ $this->modifiedTime = max( array_map( 'filemtime', array_map( array( __CLASS__, 'remapFilename' ), $files ) ) );
401401 return $this->modifiedTime;
402402 }
403403
@@ -513,7 +513,7 @@
514514 * @return string Concatenated contents of $files
515515 */
516516 protected static function concatScripts( $files ) {
517 - return implode( "\n", array_map( 'file_get_contents', array_unique( (array) $files ) ) );
 517+ return implode( "\n", array_map( 'file_get_contents', array_map( array( __CLASS__, 'remapFilename' ), array_unique( (array) $files ) ) ) );
518518 }
519519
520520 /**
@@ -527,13 +527,23 @@
528528 }
529529
530530 /**
 531+ * Remap a relative to $IP. Used as a callback for array_map()
 532+ * @param $file string File name
 533+ * @return string $IP/$file
 534+ */
 535+ protected static function remapFilename( $file ) {
 536+ global $IP;
 537+ return "$IP/$file";
 538+ }
 539+
 540+ /**
531541 * Get the contents of a CSS file and run it through CSSMin::remap().
532542 * This wrapper is needed so we can use array_map() in concatStyles()
533543 * @param $file string File name
534544 * @return string Remapped CSS
535545 */
536546 protected static function remapStyle( $file ) {
537 - return CSSMin::remap( file_get_contents( $file ), dirname( $file ) );
 547+ return CSSMin::remap( file_get_contents( self::remapFilename( $file ) ), dirname( $file ) );
538548 }
539549 }
540550

Status & tagging log