CSSMin: Remove file-existance filter in getLocalFileReferences()
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 3 Mar 2016 00:16:13 +0000 (00:16 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 3 Mar 2016 00:16:13 +0000 (00:16 +0000)
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
includes/resourceloader/ResourceLoaderFileModule.php
tests/phpunit/structure/ResourcesTest.php

index ece29e8..2f2faed 100644 (file)
@@ -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 = [];
index 3d26009..1e7329a 100644 (file)
@@ -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;
index 6b1709f..5c65c1e 100644 (file)
@@ -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,