Ori.livneh has uploaded a new change for review.

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


Change subject: Make ResourceLoader::makeComment a public static method
......................................................................

Make ResourceLoader::makeComment a public static method

ResourceLoader::makeComment takes a block of text of converts it into a
/* multi-line comment block */ that is safe for inclusion in JavaScript and CSS
source code. There is no reason for the method to be protected, since it is
generic, useful, and free of side-effects.

Change-Id: Ibe45256eddee2ad30d19adcb2f1c0b0d5578e650
---
M includes/resourceloader/ResourceLoader.php
1 file changed, 14 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/39/78639/1

diff --git a/includes/resourceloader/ResourceLoader.php 
b/includes/resourceloader/ResourceLoader.php
index 1240abf..ebcdab3 100644
--- a/includes/resourceloader/ResourceLoader.php
+++ b/includes/resourceloader/ResourceLoader.php
@@ -180,7 +180,7 @@
                        wfDebugLog( 'resourceloader', __METHOD__ . ": 
minification failed: $exception" );
                        $this->hasErrors = true;
                        // Return exception as a comment
-                       $result = $this->makeComment( $exception->__toString() 
);
+                       $result = self::makeComment( $exception->__toString() );
                }
 
                wfProfileOut( __METHOD__ );
@@ -460,7 +460,7 @@
                                        wfDebugLog( 'resourceloader', 
__METHOD__ . ": request for private module '$name' denied" );
                                        $this->hasErrors = true;
                                        // Add exception to the output as a 
comment
-                                       $errors .= $this->makeComment( "Cannot 
show private module \"$name\"" );
+                                       $errors .= self::makeComment( "Cannot 
show private module \"$name\"" );
 
                                        continue;
                                }
@@ -477,7 +477,7 @@
                        wfDebugLog( 'resourceloader', __METHOD__ . ": 
preloading module info failed: $e" );
                        $this->hasErrors = true;
                        // Add exception to the output as a comment
-                       $errors .= $this->makeComment( $e->__toString() );
+                       $errors .= self::makeComment( $e->__toString() );
                }
 
                wfProfileIn( __METHOD__ . '-getModifiedTime' );
@@ -496,7 +496,7 @@
                                wfDebugLog( 'resourceloader', __METHOD__ . ": 
calculating maximum modified time failed: $e" );
                                $this->hasErrors = true;
                                // Add exception to the output as a comment
-                               $errors .= $this->makeComment( $e->__toString() 
);
+                               $errors .= self::makeComment( $e->__toString() 
);
                        }
                }
 
@@ -517,7 +517,7 @@
                // Capture any PHP warnings from the output buffer and append 
them to the
                // response in a comment if we're in debug mode.
                if ( $context->getDebug() && strlen( $warnings = 
ob_get_contents() ) ) {
-                       $response = $this->makeComment( $warnings ) . $response;
+                       $response = self::makeComment( $warnings ) . $response;
                        $this->hasErrors = true;
                }
 
@@ -676,7 +676,13 @@
                return false; // cache miss
        }
 
-       protected function makeComment( $text ) {
+       /**
+        * Generate a CSS or JS comment block
+        *
+        * @param $text string
+        * @return string
+        */
+       public static function makeComment( $text ) {
                $encText = str_replace( '*/', '* /', $text );
                return "/*\n$encText\n*/\n";
        }
@@ -707,7 +713,7 @@
                                wfDebugLog( 'resourceloader', __METHOD__ . ": 
pre-fetching blobs from MessageBlobStore failed: $e" );
                                $this->hasErrors = true;
                                // Add exception to the output as a comment
-                               $exceptions .= $this->makeComment( 
$e->__toString() );
+                               $exceptions .= self::makeComment( 
$e->__toString() );
                        }
                } else {
                        $blobs = array();
@@ -814,7 +820,7 @@
                                wfDebugLog( 'resourceloader', __METHOD__ . ": 
generating module package failed: $e" );
                                $this->hasErrors = true;
                                // Add exception to the output as a comment
-                               $exceptions .= $this->makeComment( 
$e->__toString() );
+                               $exceptions .= self::makeComment( 
$e->__toString() );
 
                                // Register module as missing
                                $missing[] = $name;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe45256eddee2ad30d19adcb2f1c0b0d5578e650
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to