r71814 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71813‎ | r71814 | r71815 >
Date:22:08, 27 August 2010
Author:tparscal
Status:ok
Tags:
Comment:
Made the $path argument to CSSMin::getLocalFileReferences optional, to support using it on already remapped CSS data.
Modified paths:
  • /branches/resourceloader/phase3/includes/CSSMin.php (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/includes/CSSMin.php
@@ -18,15 +18,15 @@
1919 * Gets a list of local file paths which are referenced in a CSS style sheet
2020 *
2121 * @param $source string CSS data to remap
22 - * @param $path string File path where the source was read from
 22+ * @param $path string File path where the source was read from (optional)
2323 * @return array List of local file references
2424 */
25 - public static function getLocalFileReferences( $source, $path ) {
 25+ public static function getLocalFileReferences( $source, $path = null ) {
2626 $pattern = '/url\([\'"]?(?<file>[^\?\)\:]*)\??[^\)]*[\'"]?\)/';
2727 $files = array();
2828 if ( preg_match_all( $pattern, $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER ) ) {
2929 foreach ( $matches as $match ) {
30 - $file = "{$path}/{$match['file'][0]}";
 30+ $file = ( isset( $path ) ? rtrim( $path, '/' ) . '/' : '' ) . "{$match['file'][0]}";
3131 // Only proceed if we can access the file
3232 if ( file_exists( $file ) ) {
3333 $files[] = $file;

Status & tagging log