Index: trunk/phase3/includes/libs/CSSMin.php |
— | — | @@ -131,11 +131,18 @@ |
132 | 132 | // to absolute URLs but otherwise left alone |
133 | 133 | if ( $match['file'][0] !== '' && $match['file'][0][0] === '/' ) { |
134 | 134 | // Replace the file path with an expanded URL |
135 | | - $source = substr_replace( $source, wfExpandUrl( $match['file'][0] ), |
136 | | - $match['file'][1], strlen( $match['file'][0] ) |
137 | | - ); |
| 135 | + // ...but only if wfExpandUrl() is even available. This will not be the case if we're running outside of MW |
| 136 | + $lengthIncrease = 0; |
| 137 | + if ( function_exists( 'wfExpandUrl' ) ) { |
| 138 | + $expanded = wfExpandUrl( $match['file'][0] ); |
| 139 | + $origLength = strlen( $match['file'][0] ); |
| 140 | + $lengthIncrease = strlen( $expanded ) - $origLength; |
| 141 | + $source = substr_replace( $source, wfExpandUrl( $match['file'][0] ), |
| 142 | + $match['file'][1], $origLength |
| 143 | + ); |
| 144 | + } |
138 | 145 | // Move the offset to the end of the match, leaving it alone |
139 | | - $offset = $match[0][1] + strlen( $match[0][0] ); |
| 146 | + $offset = $match[0][1] + strlen( $match[0][0] ) + $lengthIncrease; |
140 | 147 | continue; |
141 | 148 | } |
142 | 149 | // Shortcuts |