jenkins-bot has submitted this change and it was merged.

Change subject: Make wfReadOnly() a wrapper around wfReadOnlyReason()
......................................................................


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
---
M includes/GlobalFunctions.php
1 file changed, 16 insertions(+), 21 deletions(-)

Approvals:
  Tim Starling: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 4679941..be4ec3e 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -1225,36 +1225,31 @@
 }
 
 /**
- * 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;
 }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/63109
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic723aed368915ac3757f3100ddbbeb3b5a4cdc15
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <pleasest...@live.com>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to