Index: trunk/extensions/CentralAuth/CentralAuthUser.php |
— | — | @@ -68,15 +68,23 @@ |
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
| 72 | + * Gets a master (read/write) database connection to the CentralAuth database |
| 73 | + * |
72 | 74 | * @return DatabaseBase |
| 75 | + * @throws ReadOnlyError |
73 | 76 | */ |
74 | 77 | public static function getCentralDB() { |
75 | | - global $wgCentralAuthDatabase; |
| 78 | + global $wgCentralAuthDatabase, $wgCentralAuthReadOnly; |
| 79 | + if ( !$wgCentralAuthReadOnly ) { |
| 80 | + throw new CentralAuthReadOnlyError(); |
| 81 | + } |
76 | 82 | return wfGetLB( $wgCentralAuthDatabase )->getConnection( DB_MASTER, array(), |
77 | 83 | $wgCentralAuthDatabase ); |
78 | 84 | } |
79 | 85 | |
80 | 86 | /** |
| 87 | + * Gets a slave (readonly) database connection to the CentralAuth database |
| 88 | + * |
81 | 89 | * @return DatabaseBase |
82 | 90 | */ |
83 | 91 | public static function getCentralSlaveDB() { |
— | — | @@ -1924,13 +1932,19 @@ |
1925 | 1933 | * @return |
1926 | 1934 | */ |
1927 | 1935 | function saveSettings() { |
1928 | | - if ( !$this->mStateDirty ) return; |
| 1936 | + if ( !$this->mStateDirty ) { |
| 1937 | + return; |
| 1938 | + } |
1929 | 1939 | $this->mStateDirty = false; |
1930 | 1940 | |
1931 | | - if ( wfReadOnly() ) return; |
| 1941 | + if ( wfReadOnly() ) { |
| 1942 | + return; |
| 1943 | + } |
1932 | 1944 | |
1933 | 1945 | $this->loadState(); |
1934 | | - if ( !$this->mGlobalId ) return; |
| 1946 | + if ( !$this->mGlobalId ) { |
| 1947 | + return; |
| 1948 | + } |
1935 | 1949 | |
1936 | 1950 | $dbw = self::getCentralDB(); |
1937 | 1951 | $dbw->update( 'globaluser', |
— | — | @@ -1972,8 +1986,9 @@ |
1973 | 1987 | foreach ( $this->mRights as $right ) { |
1974 | 1988 | if ( $right['set'] ) { |
1975 | 1989 | $set = isset( $sets[$right['set']] ) ? $sets[$right['set']] : WikiSet::newFromID( $right['set'] ); |
1976 | | - if ( $set->inSet() ) |
| 1990 | + if ( $set->inSet() ) { |
1977 | 1991 | $rights[] = $right['right']; |
| 1992 | + } |
1978 | 1993 | } else { |
1979 | 1994 | $rights[] = $right['right']; |
1980 | 1995 | } |
Index: trunk/extensions/CentralAuth/CentralAuth.php |
— | — | @@ -137,6 +137,12 @@ |
138 | 138 | $wgCentralAuthWikisPerSuppressJob = 10; |
139 | 139 | |
140 | 140 | /** |
| 141 | + * Like $wgReadOnly, used to set extension to database read only mode |
| 142 | + * @var bool |
| 143 | + */ |
| 144 | +$wgCentralAuthReadOnly = false; |
| 145 | + |
| 146 | +/** |
141 | 147 | * Initialization of the autoloaders, and special extension pages. |
142 | 148 | */ |
143 | 149 | $caBase = dirname( __FILE__ ); |
— | — | @@ -156,6 +162,7 @@ |
157 | 163 | $wgAutoloadClasses['SpecialGlobalGroupPermissions'] = "$caBase/specials/SpecialGlobalGroupPermissions.php"; |
158 | 164 | $wgAutoloadClasses['SpecialWikiSets'] = "$caBase/specials/SpecialWikiSets.php"; |
159 | 165 | $wgAutoloadClasses['ApiQueryGlobalUserInfo'] = "$caBase/ApiQueryGlobalUserInfo.php"; |
| 166 | +$wgAutoloadClasses['CentralAuthReadOnlyError'] = "$caBase/CentralAuthReadOnlyError.php"; |
160 | 167 | |
161 | 168 | $wgExtensionMessagesFiles['SpecialCentralAuth'] = "$caBase/CentralAuth.i18n.php"; |
162 | 169 | $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 |
1 | 18 | + native |
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php |
— | — | @@ -362,6 +362,9 @@ |
363 | 363 | 'centralauth-editset-success-delete' => 'Successfully deleted wiki set.', |
364 | 364 | 'centralauth-editset-return' => 'Return to main view', |
365 | 365 | |
| 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 | + |
366 | 369 | // User rights |
367 | 370 | 'right-globalgroupmembership' => 'Edit membership to global groups', |
368 | 371 | 'right-centralauth-autoaccount' => 'Automatically login with global account', |
— | — | @@ -530,6 +533,10 @@ |
531 | 534 | 'centralauth-editset-submit-delete' => '{{Identical|Delete}}', |
532 | 535 | 'centralauth-editset-grouplink' => '{{optional}}', |
533 | 536 | '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 | + |
534 | 541 | 'right-globalgroupmembership' => '{{doc-right|globalgroupmembership}}', |
535 | 542 | 'right-centralauth-autoaccount' => '{{doc-right|centralauth-autoaccount}}', |
536 | 543 | 'right-centralauth-unmerge' => '{{doc-right|centralauth-unmerge}}', |