Merge "Work around preg_replace_callback() issue in CSSJanus"
authorKrinkle <ttijhof@wikimedia.org>
Tue, 28 Aug 2012 22:00:38 +0000 (22:00 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 28 Aug 2012 22:00:38 +0000 (22:00 +0000)
includes/libs/CSSJanus.php

index e6672b4..4ebbc49 100644 (file)
@@ -268,10 +268,17 @@ class CSSJanus {
         * @return string
         */
        private static function fixBackgroundPosition( $css ) {
-               $css = preg_replace_callback( self::$patterns['bg_horizontal_percentage'],
+               $replaced = preg_replace_callback( self::$patterns['bg_horizontal_percentage'],
                        array( 'self', 'calculateNewBackgroundPosition' ), $css );
-               $css = preg_replace_callback( self::$patterns['bg_horizontal_percentage_x'],
+               if ( $replaced !== null ) {
+                       // Check for null; sometimes preg_replace_callback() returns null here for some weird reason
+                       $css = $replaced;
+               }
+               $replaced = preg_replace_callback( self::$patterns['bg_horizontal_percentage_x'],
                        array( 'self', 'calculateNewBackgroundPosition' ), $css );
+               if ( $replaced !== null ) {
+                       $css = $replaced;
+               }
 
                return $css;
        }