Merge "Localisation updates from http://translatewiki.net."
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 3de25e7..d0a2042 100644 (file)
@@ -1037,7 +1037,7 @@ function wfDebugLog( $logGroup, $text, $public = true ) {
                        wfErrorLog( "$time $host $wiki: $text", $wgDebugLogGroups[$logGroup] );
                }
        } elseif ( $public === true ) {
-               wfDebug( $text, true );
+               wfDebug( "[$logGroup] $text", true );
        }
 }
 
@@ -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 );
 }
@@ -1418,6 +1427,8 @@ function wfMessageFallback( /*...*/ ) {
  * @return String
  */
 function wfMsg( $key ) {
+       wfDeprecated( __METHOD__, '1.21' );
+
        $args = func_get_args();
        array_shift( $args );
        return wfMsgReal( $key, $args );
@@ -1432,6 +1443,8 @@ function wfMsg( $key ) {
  * @return String
  */
 function wfMsgNoTrans( $key ) {
+       wfDeprecated( __METHOD__, '1.21' );
+
        $args = func_get_args();
        array_shift( $args );
        return wfMsgReal( $key, $args, true, false, false );
@@ -1463,6 +1476,8 @@ function wfMsgNoTrans( $key ) {
  * @return String
  */
 function wfMsgForContent( $key ) {
+       wfDeprecated( __METHOD__, '1.21' );
+
        global $wgForceUIMsgAsContentMsg;
        $args = func_get_args();
        array_shift( $args );
@@ -1484,6 +1499,8 @@ function wfMsgForContent( $key ) {
  * @return String
  */
 function wfMsgForContentNoTrans( $key ) {
+       wfDeprecated( __METHOD__, '1.21' );
+
        global $wgForceUIMsgAsContentMsg;
        $args = func_get_args();
        array_shift( $args );
@@ -1509,6 +1526,8 @@ function wfMsgForContentNoTrans( $key ) {
  * @return String: the requested message.
  */
 function wfMsgReal( $key, $args, $useDB = true, $forContent = false, $transform = true ) {
+       wfDeprecated( __METHOD__, '1.21' );
+
        wfProfileIn( __METHOD__ );
        $message = wfMsgGetKey( $key, $useDB, $forContent, $transform );
        $message = wfMsgReplaceArgs( $message, $args );
@@ -1529,6 +1548,8 @@ function wfMsgReal( $key, $args, $useDB = true, $forContent = false, $transform
  * @return string
  */
 function wfMsgGetKey( $key, $useDB = true, $langCode = false, $transform = true ) {
+       wfDeprecated( __METHOD__, '1.21' );
+
        wfRunHooks( 'NormalizeMessageKey', array( &$key, &$useDB, &$langCode, &$transform ) );
 
        $cache = MessageCache::singleton();
@@ -1583,6 +1604,8 @@ function wfMsgReplaceArgs( $message, $args ) {
  * @return string
  */
 function wfMsgHtml( $key ) {
+       wfDeprecated( __METHOD__, '1.21' );
+
        $args = func_get_args();
        array_shift( $args );
        return wfMsgReplaceArgs( htmlspecialchars( wfMsgGetKey( $key ) ), $args );
@@ -1602,6 +1625,8 @@ function wfMsgHtml( $key ) {
  * @return string
  */
 function wfMsgWikiHtml( $key ) {
+       wfDeprecated( __METHOD__, '1.21' );
+
        $args = func_get_args();
        array_shift( $args );
        return wfMsgReplaceArgs(
@@ -1633,6 +1658,8 @@ function wfMsgWikiHtml( $key ) {
  * @return String
  */
 function wfMsgExt( $key, $options ) {
+       wfDeprecated( __METHOD__, '1.21' );
+
        $args = func_get_args();
        array_shift( $args );
        array_shift( $args );
@@ -1713,6 +1740,8 @@ function wfMsgExt( $key, $options ) {
  * @return Boolean True if the message *doesn't* exist.
  */
 function wfEmptyMsg( $key ) {
+       wfDeprecated( __METHOD__, '1.21' );
+
        return MessageCache::singleton()->get( $key, /*useDB*/true, /*content*/false ) === false;
 }
 
@@ -2331,7 +2360,7 @@ function wfSuppressWarnings( $end = false ) {
                }
        } else {
                if ( !$suppressCount ) {
-                       $originalLevel = error_reporting( E_ALL & ~( E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED ) );
+                       $originalLevel = error_reporting( E_ALL & ~( E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT ) );
                }
                ++$suppressCount;
        }
@@ -2895,11 +2924,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
@@ -3256,6 +3289,18 @@ function wfHttpOnlySafe() {
        return true;
 }
 
+/**
+ * Check if there is sufficent entropy in php's built-in session generation
+ * @return bool true = there is sufficient entropy
+ */
+function wfCheckEntropy() {
+       return (
+                       ( wfIsWindows() && version_compare( PHP_VERSION, '5.3.3', '>=' ) )
+                       || ini_get( 'session.entropy_file' )
+               )
+               && intval( ini_get( 'session.entropy_length' ) ) >= 32;
+}
+
 /**
  * Override session_id before session startup if php's built-in
  * session generation code is not secure.
@@ -3270,11 +3315,7 @@ function wfFixSessionID() {
        // - entropy_file is set or you're on Windows with php 5.3.3+
        // - AND entropy_length is > 0
        // We treat it as disabled if it doesn't have an entropy length of at least 32
-       $entropyEnabled = (
-                       ( wfIsWindows() && version_compare( PHP_VERSION, '5.3.3', '>=' ) )
-                       || ini_get( 'session.entropy_file' )
-               )
-               && intval( ini_get( 'session.entropy_length' ) ) >= 32;
+       $entropyEnabled = wfCheckEntropy();
 
        // If built-in entropy is not enabled or not sufficient override php's built in session id generation code
        if ( !$entropyEnabled ) {