From: Kevin Israel Date: Fri, 10 May 2013 07:37:04 +0000 (-0400) Subject: Make wfReadOnly() a wrapper around wfReadOnlyReason() X-Git-Tag: 1.31.0-rc.0~18988 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=b345e2492bd495e5c57cca06255489ea2cc6b8ec;p=lhc%2Fweb%2Fwiklou.git Make wfReadOnly() a wrapper around wfReadOnlyReason() This makes more sense than having wfReadOnlyReason() call wfReadOnly() for its side effect of setting $wgReadOnly to the contents of $wgReadOnlyFile if the file exists. Change-Id: Ic723aed368915ac3757f3100ddbbeb3b5a4cdc15 --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 4679941b70..be4ec3e6fd 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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; }