Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/274607

Change subject: CSSMin: Remove file-existance filter in getLocalFileReferences()
......................................................................

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
---
M includes/libs/CSSMin.php
M includes/resourceloader/ResourceLoaderFileModule.php
M tests/phpunit/structure/ResourcesTest.php
3 files changed, 5 insertions(+), 33 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/07/274607/1

diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php
index ece29e8..2f2faed 100644
--- a/includes/libs/CSSMin.php
+++ b/includes/libs/CSSMin.php
@@ -60,41 +60,13 @@
        /* 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.
+        * 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 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.
-        *
-        * @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 3d26009..1e7329a 100644
--- a/includes/resourceloader/ResourceLoaderFileModule.php
+++ b/includes/resourceloader/ResourceLoaderFileModule.php
@@ -891,7 +891,7 @@
                $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 6b1709f..5c65c1e 100644
--- a/tests/phpunit/structure/ResourcesTest.php
+++ b/tests/phpunit/structure/ResourcesTest.php
@@ -119,13 +119,13 @@
        }
 
        /**
-        * 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,

-- 
To view, visit https://gerrit.wikimedia.org/r/274607
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I864258aad128ba9b54464c7bc854543f2937f977
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to