From 98911418c229905d6901f25df94e85246b851bce Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 3 Mar 2016 00:16:13 +0000 Subject: [PATCH] CSSMin: Remove file-existance filter in getLocalFileReferences() Follows-up 8f5cd11d82fa. The old getLocalFileReferences() method is no longer used anywhere. Remove it and rename getAllLocalFileReferences back to it. Change-Id: I864258aad128ba9b54464c7bc854543f2937f977 --- includes/libs/CSSMin.php | 32 ++----------------- .../ResourceLoaderFileModule.php | 2 +- tests/phpunit/structure/ResourcesTest.php | 4 +-- 3 files changed, 5 insertions(+), 33 deletions(-) diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index ece29e85cc..2f2faed3bd 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -60,41 +60,13 @@ class CSSMin { /* Static Methods */ /** - * Gets a list of local file paths which are referenced in a CSS style sheet. - * - * If you wish non-existent files to be listed too, use getAllLocalFileReferences(). - * - * For backwards-compatibility, if the second parameter is not given or null, - * this function will return an empty array instead of erroring out. - * - * @param string $source CSS stylesheet source to process - * @param string $path File path where the source was read from - * @return array List of local file references - */ - public static function getLocalFileReferences( $source, $path = null ) { - if ( $path === null ) { - return []; - } - - $files = self::getAllLocalFileReferences( $source, $path ); - - // Skip non-existent files - $files = array_filter( $files, function ( $file ) { - return file_exists( $file ); - } ); - - return $files; - } - - /** - * Gets a list of local file paths which are referenced in a CSS style sheet, including - * non-existent files. + * Get a list of local files referenced in a stylesheet (includes non-existent files). * * @param string $source CSS stylesheet source to process * @param string $path File path where the source was read from * @return array List of local file references */ - public static function getAllLocalFileReferences( $source, $path ) { + public static function getLocalFileReferences( $source, $path ) { $stripped = preg_replace( '/' . self::COMMENT_REGEX . '/s', '', $source ); $path = rtrim( $path, '/' ) . '/'; $files = []; diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index 3d26009cfd..1e7329a091 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -891,7 +891,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { $localDir = dirname( $localPath ); $remoteDir = dirname( $remotePath ); // Get and register local file references - $localFileRefs = CSSMin::getAllLocalFileReferences( $style, $localDir ); + $localFileRefs = CSSMin::getLocalFileReferences( $style, $localDir ); foreach ( $localFileRefs as $file ) { if ( file_exists( $file ) ) { $this->localFileRefs[] = $file; diff --git a/tests/phpunit/structure/ResourcesTest.php b/tests/phpunit/structure/ResourcesTest.php index 6b1709fc5d..5c65c1ef89 100644 --- a/tests/phpunit/structure/ResourcesTest.php +++ b/tests/phpunit/structure/ResourcesTest.php @@ -119,13 +119,13 @@ class ResourcesTest extends MediaWikiTestCase { } /** - * CSSMin::getAllLocalFileReferences should ignore url(...) expressions + * CSSMin::getLocalFileReferences should ignore url(...) expressions * that have been commented out. */ public function testCommentedLocalFileReferences() { $basepath = __DIR__ . '/../data/css/'; $css = file_get_contents( $basepath . 'comments.css' ); - $files = CSSMin::getAllLocalFileReferences( $css, $basepath ); + $files = CSSMin::getLocalFileReferences( $css, $basepath ); $expected = [ $basepath . 'not-commented.gif' ]; $this->assertArrayEquals( $expected, -- 2.20.1