Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/247768
Change subject: Check read-only mode for central DB
......................................................................
Check read-only mode for central DB
Change-Id: Ieefc34f1f3a7f2d0410950cb8e6e67daa4f26f74
---
M CentralAuth.php
M includes/CentralAuthHooks.php
M includes/CentralAuthUser.php
A includes/CentralAuthUtils.php
M includes/specials/SpecialMergeAccount.php
5 files changed, 28 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth
refs/changes/68/247768/1
diff --git a/CentralAuth.php b/CentralAuth.php
index c4f55f4..420be69 100644
--- a/CentralAuth.php
+++ b/CentralAuth.php
@@ -282,6 +282,7 @@
$wgAutoloadClasses['RenameQueueTablePager'] =
"$caBase/includes/specials/SpecialGlobalRenameQueue.php";
$wgAutoloadClasses['SpecialSulRenameWarning'] =
"$caBase/includes/specials/SpecialSulRenameWarning.php";
$wgAutoloadClasses['CentralAuthUser'] = "$caBase/includes/CentralAuthUser.php";
+$wgAutoloadClasses['CentralAuthUtils'] =
"$caBase/includes/CentralAuthUtils.php";
$wgAutoloadClasses['CentralAuthPlugin'] =
"$caBase/includes/CentralAuthPlugin.php";
$wgAutoloadClasses['CentralAuthHooks'] =
"$caBase/includes/CentralAuthHooks.php";
$wgAutoloadClasses['CentralAuthSuppressUserJob'] =
"$caBase/includes/SuppressUserJob.php";
diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php
index a29e2e8..5b2aaa1 100644
--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -1132,7 +1132,7 @@
// Don't freak people out on every page view
wfDebug( __METHOD__ . ": denied by
\$wgCentralAuthCreateOnView\n" );
return false;
- } elseif ( wfReadOnly() ) {
+ } elseif ( CentralAuthUtils::isReadOnly() ) {
wfDebug( __METHOD__ . ": denied by wfReadOnly()\n" );
return false;
}
diff --git a/includes/CentralAuthUser.php b/includes/CentralAuthUser.php
index 58b14f4..99a06ce 100644
--- a/includes/CentralAuthUser.php
+++ b/includes/CentralAuthUser.php
@@ -2497,7 +2497,7 @@
}
$this->mStateDirty = false;
- if ( wfReadOnly() ) {
+ if ( CentralAuthUtils::isReadOnly() ) {
return;
}
diff --git a/includes/CentralAuthUtils.php b/includes/CentralAuthUtils.php
new file mode 100644
index 0000000..26c4bd0
--- /dev/null
+++ b/includes/CentralAuthUtils.php
@@ -0,0 +1,23 @@
+<?php
+
+class CentralAuthUtils {
+ public static function isReadOnly() {
+ return ( self::getReadOnlyReason() !== false );
+ }
+
+ public static function getReadOnlyReason() {
+ global $wgCentralAuthDatabase;
+
+ if ( wfReadOnly() ) {
+ return wfReadOnlyReason();
+ }
+
+ $lb = wfGetLB( $wgCentralAuthDatabase );
+ $reason = $lb->getReadOnlyReason( $wgCentralAuthDatabase );
+ if ( $reason !== false ) {
+ return $reason;
+ }
+
+ return false;
+ }
+}
diff --git a/includes/specials/SpecialMergeAccount.php
b/includes/specials/SpecialMergeAccount.php
index 215c962..479e24b 100644
--- a/includes/specials/SpecialMergeAccount.php
+++ b/includes/specials/SpecialMergeAccount.php
@@ -38,9 +38,9 @@
return;
}
- if ( wfReadOnly() ) {
+ if ( CentralAuthUtils::isReadOnly() ) {
$this->getOutput()->setPagetitle( $this->msg(
'readonly' ) );
- $this->getOutput()->addWikiMsg( 'readonlytext',
wfReadOnlyReason() );
+ $this->getOutput()->addWikiMsg( 'readonlytext',
CentralAuthUtils::getReadOnlyReason() );
return;
}
--
To view, visit https://gerrit.wikimedia.org/r/247768
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieefc34f1f3a7f2d0410950cb8e6e67daa4f26f74
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits