r106784 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106783‎ | r106784 | r106785 >
Date:12:24, 20 December 2011
Author:reedy
Status:resolved
Tags:
Comment:
* (bug 31170) centralauth needs a read-only db flag that allows queries to go to lagged slaves

Added $wgCentralAuthReadOnly

"When the cluster with centralauth is set to read-only (currently S7), it only
applies to wikis also on that cluster"

Need to (possibly) make some changes to disabling replication lag checking
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuth.i18n.php (modified) (history)
  • /trunk/extensions/CentralAuth/CentralAuth.php (modified) (history)
  • /trunk/extensions/CentralAuth/CentralAuthReadOnlyError.php (added) (history)
  • /trunk/extensions/CentralAuth/CentralAuthUser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/CentralAuthUser.php
@@ -68,15 +68,23 @@
6969 }
7070
7171 /**
 72+ * Gets a master (read/write) database connection to the CentralAuth database
 73+ *
7274 * @return DatabaseBase
 75+ * @throws ReadOnlyError
7376 */
7477 public static function getCentralDB() {
75 - global $wgCentralAuthDatabase;
 78+ global $wgCentralAuthDatabase, $wgCentralAuthReadOnly;
 79+ if ( !$wgCentralAuthReadOnly ) {
 80+ throw new CentralAuthReadOnlyError();
 81+ }
7682 return wfGetLB( $wgCentralAuthDatabase )->getConnection( DB_MASTER, array(),
7783 $wgCentralAuthDatabase );
7884 }
7985
8086 /**
 87+ * Gets a slave (readonly) database connection to the CentralAuth database
 88+ *
8189 * @return DatabaseBase
8290 */
8391 public static function getCentralSlaveDB() {
@@ -1924,13 +1932,19 @@
19251933 * @return
19261934 */
19271935 function saveSettings() {
1928 - if ( !$this->mStateDirty ) return;
 1936+ if ( !$this->mStateDirty ) {
 1937+ return;
 1938+ }
19291939 $this->mStateDirty = false;
19301940
1931 - if ( wfReadOnly() ) return;
 1941+ if ( wfReadOnly() ) {
 1942+ return;
 1943+ }
19321944
19331945 $this->loadState();
1934 - if ( !$this->mGlobalId ) return;
 1946+ if ( !$this->mGlobalId ) {
 1947+ return;
 1948+ }
19351949
19361950 $dbw = self::getCentralDB();
19371951 $dbw->update( 'globaluser',
@@ -1972,8 +1986,9 @@
19731987 foreach ( $this->mRights as $right ) {
19741988 if ( $right['set'] ) {
19751989 $set = isset( $sets[$right['set']] ) ? $sets[$right['set']] : WikiSet::newFromID( $right['set'] );
1976 - if ( $set->inSet() )
 1990+ if ( $set->inSet() ) {
19771991 $rights[] = $right['right'];
 1992+ }
19781993 } else {
19791994 $rights[] = $right['right'];
19801995 }
Index: trunk/extensions/CentralAuth/CentralAuth.php
@@ -137,6 +137,12 @@
138138 $wgCentralAuthWikisPerSuppressJob = 10;
139139
140140 /**
 141+ * Like $wgReadOnly, used to set extension to database read only mode
 142+ * @var bool
 143+ */
 144+$wgCentralAuthReadOnly = false;
 145+
 146+/**
141147 * Initialization of the autoloaders, and special extension pages.
142148 */
143149 $caBase = dirname( __FILE__ );
@@ -156,6 +162,7 @@
157163 $wgAutoloadClasses['SpecialGlobalGroupPermissions'] = "$caBase/specials/SpecialGlobalGroupPermissions.php";
158164 $wgAutoloadClasses['SpecialWikiSets'] = "$caBase/specials/SpecialWikiSets.php";
159165 $wgAutoloadClasses['ApiQueryGlobalUserInfo'] = "$caBase/ApiQueryGlobalUserInfo.php";
 166+$wgAutoloadClasses['CentralAuthReadOnlyError'] = "$caBase/CentralAuthReadOnlyError.php";
160167
161168 $wgExtensionMessagesFiles['SpecialCentralAuth'] = "$caBase/CentralAuth.i18n.php";
162169 $wgExtensionMessagesFiles['SpecialCentralAuthAliases'] = "$caBase/CentralAuth.alias.php";
Index: trunk/extensions/CentralAuth/CentralAuthReadOnlyError.php
@@ -0,0 +1,16 @@
 2+<?php
 3+
 4+/**
 5+ * Show an error when the CentralAuth database is locked/read-only
 6+ * and the user tries to do something that requires CentralAuth#
 7+ * write access
 8+ * @ingroup Exception
 9+ */
 10+class CentralAuthReadOnlyError extends ErrorPageError {
 11+ public function __construct(){
 12+ parent::__construct(
 13+ 'centralauth-readonly',
 14+ 'centralauth-readonlytext'
 15+ );
 16+ }
 17+}
Property changes on: trunk/extensions/CentralAuth/CentralAuthReadOnlyError.php
___________________________________________________________________
Added: svn:eol-style
118 + native
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php
@@ -362,6 +362,9 @@
363363 'centralauth-editset-success-delete' => 'Successfully deleted wiki set.',
364364 'centralauth-editset-return' => 'Return to main view',
365365
 366+ 'centralauth-readonly' => 'CentralAuth Database locked',
 367+ 'centralauth-readonlytext' => 'The CentralAuth database is currently locked to new entries and other modifications, probably for routine database maintenance, after which it will be back to normal.',
 368+
366369 // User rights
367370 'right-globalgroupmembership' => 'Edit membership to global groups',
368371 'right-centralauth-autoaccount' => 'Automatically login with global account',
@@ -530,6 +533,10 @@
531534 'centralauth-editset-submit-delete' => '{{Identical|Delete}}',
532535 'centralauth-editset-grouplink' => '{{optional}}',
533536 'centralauth-editset-nouse' => '{{Identical|None}}',
 537+
 538+ 'centralauth-readonly' => 'Error message displayed when the CentralAuth database is locked.',
 539+ 'centralauth-readonlytext' => 'Description of the centralauth-readonlytext error',
 540+
534541 'right-globalgroupmembership' => '{{doc-right|globalgroupmembership}}',
535542 'right-centralauth-autoaccount' => '{{doc-right|centralauth-autoaccount}}',
536543 'right-centralauth-unmerge' => '{{doc-right|centralauth-unmerge}}',

Follow-up revisions

RevisionCommit summaryAuthorDate
r106785Remove # from r106784 and fix @throws to list the correct exception which cou...reedy12:33, 20 December 2011
r106795Fix boolean fail from r106784reedy13:20, 20 December 2011

Status & tagging log