Tweaked location of profiling in query() to split out the implicit BEGIN
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 65b4c23..be4ec3e 100644 (file)
@@ -1225,36 +1225,31 @@ function wfIncrStats( $key, $count = 1 ) {
 }
 
 /**
- * Check if the wiki read-only lock file is present. This can be used to lock
- * off editing functions, but doesn't guarantee that the database will not be
- * modified.
+ * Check whether the wiki is in read-only mode.
  *
  * @return bool
  */
 function wfReadOnly() {
-       global $wgReadOnlyFile, $wgReadOnly;
-
-       if ( !is_null( $wgReadOnly ) ) {
-               return (bool)$wgReadOnly;
-       }
-       if ( $wgReadOnlyFile == '' ) {
-               return false;
-       }
-       // Set $wgReadOnly for faster access next time
-       if ( is_file( $wgReadOnlyFile ) ) {
-               $wgReadOnly = file_get_contents( $wgReadOnlyFile );
-       } else {
-               $wgReadOnly = false;
-       }
-       return (bool)$wgReadOnly;
+       return wfReadOnlyReason() !== false;
 }
 
 /**
- * @return bool
+ * Get the value of $wgReadOnly or the contents of $wgReadOnlyFile.
+ *
+ * @return string|bool: String when in read-only mode; false otherwise
  */
 function wfReadOnlyReason() {
-       global $wgReadOnly;
-       wfReadOnly();
+       global $wgReadOnly, $wgReadOnlyFile;
+
+       if ( $wgReadOnly === null ) {
+               // Set $wgReadOnly for faster access next time
+               if ( is_file( $wgReadOnlyFile ) && filesize( $wgReadOnlyFile ) > 0 ) {
+                       $wgReadOnly = file_get_contents( $wgReadOnlyFile );
+               } else {
+                       $wgReadOnly = false;
+               }
+       }
+
        return $wgReadOnly;
 }
 
@@ -3305,6 +3300,27 @@ function wfFixSessionID() {
        }
 }
 
+/**
+ * Reset the session_id
+ * @since 1.22
+ */
+function wfResetSessionID() {
+       global $wgCookieSecure;
+       $oldSessionId = session_id();
+       $cookieParams = session_get_cookie_params();
+       if ( wfCheckEntropy() && $wgCookieSecure == $cookieParams['secure'] ) {
+               session_regenerate_id( false );
+       } else {
+               $tmp = $_SESSION;
+               session_destroy();
+               wfSetupSession( MWCryptRand::generateHex( 32 ) );
+               $_SESSION = $tmp;
+       }
+       $newSessionId = session_id();
+       wfRunHooks( 'ResetSessionID', array( $oldSessionId, $newSessionId ) );
+}
+
+
 /**
  * Initialise php session
  *
@@ -3390,7 +3406,7 @@ function wfForeignMemcKey( $db, $prefix /*, ... */ ) {
        } else {
                $key = $db . ':' . implode( ':', $args );
        }
-       return $key;
+       return str_replace( ' ', '_', $key );
 }
 
 /**