JavaScriptContentHandler: Fix typo in comment block (actual: 'CSS'; intended: 'JS')
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 3de25e7..982e965 100644 (file)
@@ -1214,9 +1214,18 @@ function wfLogProfilingData() {
        if ( $wgUser->isItemLoaded( 'id' ) && $wgUser->isAnon() ) {
                $forward .= ' anon';
        }
+
+       // Command line script uses a FauxRequest object which does not have
+       // any knowledge about an URL and throw an exception instead.
+       try {
+               $requestUrl = $wgRequest->getRequestURL();
+       } catch ( MWException $e ) {
+               $requestUrl = 'n/a';
+       }
+
        $log = sprintf( "%s\t%04.3f\t%s\n",
                gmdate( 'YmdHis' ), $elapsed,
-               urldecode( $wgRequest->getRequestURL() . $forward ) );
+               urldecode( $requestUrl . $forward ) );
 
        wfErrorLog( $log . $profiler->getOutput(), $wgDebugLogFile );
 }
@@ -2895,11 +2904,15 @@ function wfMerge( $old, $mine, $yours, &$result ) {
        $mytextFile = fopen( $mytextName = tempnam( $td, 'merge-mine-' ), 'w' );
        $yourtextFile = fopen( $yourtextName = tempnam( $td, 'merge-your-' ), 'w' );
 
-       fwrite( $oldtextFile, $old );
+       # NOTE: diff3 issues a warning to stderr if any of the files does not end with
+       #       a newline character. To avoid this, we normalize the trailing whitespace before
+       #       creating the diff.
+
+       fwrite( $oldtextFile, rtrim( $old ) . "\n" );
        fclose( $oldtextFile );
-       fwrite( $mytextFile, $mine );
+       fwrite( $mytextFile, rtrim( $mine ) . "\n" );
        fclose( $mytextFile );
-       fwrite( $yourtextFile, $yours );
+       fwrite( $yourtextFile, rtrim( $yours ) . "\n" );
        fclose( $yourtextFile );
 
        # Check for a conflict