Index: trunk/extensions/CentralAuth/CentralAuthUser.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | function newFromLocal( $dbname, $userid ) { |
31 | 31 | $dbr = wfGetDB( DB_MASTER, 'CentralAuth' ); |
32 | 32 | $username = $dbr->selectField( |
33 | | - array( 'globaluser', 'localuser' ), |
| 33 | + array( self::tableName( 'globaluser' ), self::tableName( 'localuser' ) ), |
34 | 34 | 'gu_name', |
35 | 35 | array( |
36 | 36 | 'gu_id=lu_global_id', |
— | — | @@ -55,13 +55,23 @@ |
56 | 56 | $this->mName = $username; |
57 | 57 | } |
58 | 58 | |
| 59 | + static function tableName( $name ) { |
| 60 | + global $wgCentralAuthDatabase; |
| 61 | + return |
| 62 | + '`' . |
| 63 | + $wgCentralAuthDatabase . |
| 64 | + '`.`' . |
| 65 | + $name . |
| 66 | + '`'; |
| 67 | + } |
| 68 | + |
59 | 69 | /** |
60 | 70 | * this code is crap |
61 | 71 | */ |
62 | 72 | function getId() { |
63 | 73 | $dbr = wfGetDB( DB_MASTER, 'CentralAuth' ); |
64 | 74 | $id = $dbr->selectField( |
65 | | - 'globaluser', |
| 75 | + self::tableName( 'globaluser' ), |
66 | 76 | 'gu_id', |
67 | 77 | array( 'gu_name' => $this->mName ), |
68 | 78 | __METHOD__ ); |
— | — | @@ -79,7 +89,7 @@ |
80 | 90 | $dbw = wfGetDB( DB_MASTER, 'CentralAuth' ); |
81 | 91 | list( $salt, $hash ) = $this->saltedPassword( $password ); |
82 | 92 | $ok = $dbw->insert( |
83 | | - 'globaluser', |
| 93 | + self::tableName( 'globaluser' ), |
84 | 94 | array( |
85 | 95 | 'gu_name' => $this->mName, |
86 | 96 | |
— | — | @@ -113,7 +123,7 @@ |
114 | 124 | static function storeLocalData( $dbname, $row, $editCount ) { |
115 | 125 | $dbw = wfGetDB( DB_MASTER, 'CentralAuth' ); |
116 | 126 | $ok = $dbw->insert( |
117 | | - 'localuser', |
| 127 | + self::tableName( 'localuser' ), |
118 | 128 | array( |
119 | 129 | 'lu_global_id' => null, // Not yet migrated! |
120 | 130 | 'lu_dbname' => $dbname, |
— | — | @@ -135,7 +145,7 @@ |
136 | 146 | */ |
137 | 147 | function storeGlobalData( $salt, $hash, $email, $emailAuth ) { |
138 | 148 | $dbw = wfGetDB( DB_MASTER, 'CentralAuth' ); |
139 | | - $dbw->insert( 'globaluser', |
| 149 | + $dbw->insert( self::tableName( 'globaluser' ), |
140 | 150 | array( |
141 | 151 | 'gu_name' => $this->mName, |
142 | 152 | 'gu_salt' => $salt, |
— | — | @@ -286,31 +296,6 @@ |
287 | 297 | } |
288 | 298 | |
289 | 299 | /** |
290 | | - * Check if the current username is defined and attached on this wiki yet |
291 | | - * @param $dbname Local database key to look up |
292 | | - * @return ("attached", "unattached", "no local user") |
293 | | - */ |
294 | | - /* |
295 | | - function isAttached( $dbname ) { |
296 | | - $dbr = wfGetDB( DB_MASTER, 'CentralAuth' ); |
297 | | - $row = $dbr->selectRow( 'localuser', |
298 | | - array( 'lu_attached' ), |
299 | | - array( 'lu_name' => $this->mName, 'lu_database' => $dbname ), |
300 | | - __METHOD__ ); |
301 | | - |
302 | | - if( !$row ) { |
303 | | - return "no local user"; |
304 | | - } |
305 | | - |
306 | | - if( $row->lu_attached ) { |
307 | | - return "attached"; |
308 | | - } else { |
309 | | - return "unattached"; |
310 | | - } |
311 | | - } |
312 | | - */ |
313 | | - |
314 | | - /** |
315 | 300 | * Add a local account record for the given wiki to the central database. |
316 | 301 | * @param string $dbname |
317 | 302 | * @param int $localid |
— | — | @@ -320,7 +305,7 @@ |
321 | 306 | */ |
322 | 307 | function addLocal( $dbname, $localid ) { |
323 | 308 | $dbw = wfGetDB( DB_MASTER, 'CentralAuth' ); |
324 | | - $dbw->insert( 'localuser', |
| 309 | + $dbw->insert( self::tableName( 'localuser' ), |
325 | 310 | array( |
326 | 311 | 'lu_global_id' => $this->getId(), |
327 | 312 | 'lu_dbname' => $dbname, |
— | — | @@ -336,7 +321,7 @@ |
337 | 322 | */ |
338 | 323 | public function attach( $dbname, $method ) { |
339 | 324 | $dbw = wfGetDB( DB_MASTER, 'CentralAuth' ); |
340 | | - $dbw->update( 'localuser', |
| 325 | + $dbw->update( self::tableName( 'localuser' ), |
341 | 326 | array( |
342 | 327 | // Boo-yah! |
343 | 328 | 'lu_global_id' => $this->getId(), |
— | — | @@ -365,7 +350,7 @@ |
366 | 351 | */ |
367 | 352 | public function authenticate( $password ) { |
368 | 353 | $dbw = wfGetDB( DB_MASTER, 'CentralAuth' ); |
369 | | - $row = $dbw->selectRow( 'globaluser', |
| 354 | + $row = $dbw->selectRow( self::tableName( 'globaluser' ), |
370 | 355 | array( 'gu_salt', 'gu_password', 'gu_locked' ), |
371 | 356 | array( 'gu_id' => $this->getId() ), |
372 | 357 | __METHOD__ ); |
— | — | @@ -424,7 +409,7 @@ |
425 | 410 | |
426 | 411 | function fetchUnattached() { |
427 | 412 | $dbw = wfGetDB( DB_MASTER, 'CentralAuth' ); |
428 | | - $result = $dbw->select( 'localuser', |
| 413 | + $result = $dbw->select( self::tableName( 'localuser' ), |
429 | 414 | array( |
430 | 415 | 'lu_dbname', |
431 | 416 | 'lu_local_id', |
— | — | @@ -449,7 +434,8 @@ |
450 | 435 | |
451 | 436 | function getEmail() { |
452 | 437 | $dbr = wfGetDB( DB_MASTER, 'CentralAuth' ); |
453 | | - return $dbr->selectField( 'globaluser', 'gu_email', |
| 438 | + return $dbr->selectField( self::tableName( 'globaluser' ), |
| 439 | + 'gu_email', |
454 | 440 | array( 'gu_id' => $this->getId() ), |
455 | 441 | __METHOD__ ); |
456 | 442 | } |
— | — | @@ -472,7 +458,7 @@ |
473 | 459 | list( $salt, $hash ) = $this->saltedPassword( $password ); |
474 | 460 | |
475 | 461 | $dbw = wfGetDB( DB_MASTER, 'CentralAuth' ); |
476 | | - $result = $dbr->update( 'globaluser', |
| 462 | + $result = $dbr->update( self::tableName( 'globaluser' ), |
477 | 463 | array( |
478 | 464 | 'gu_salt' => $salt, |
479 | 465 | 'gu_password' => $hash, |
Index: trunk/extensions/CentralAuth/CentralAuth.php |
— | — | @@ -1,5 +1,13 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | +/** |
| 5 | + * Database name you keep central auth data in. |
| 6 | + * |
| 7 | + * If this is not on the primary database connection, don't forget |
| 8 | + * to also set up $wgDBservers to have an entry with a groupLoads |
| 9 | + * setting for the 'CentralAuth' group. |
| 10 | + */ |
| 11 | +$wgCentralAuthDatabase = 'centralauth'; |
4 | 12 | |
5 | 13 | /** |
6 | 14 | * For making pretty HTTPS links to other wikis |
Index: trunk/extensions/CentralAuth/migratePass1.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | function migratePassOne() { |
10 | 10 | $dbBackground = wfGetDB( DB_SLAVE, 'CentralAuth' ); // fixme for large dbs |
11 | 11 | $result = $dbBackground->select( |
12 | | - 'localuser', |
| 12 | + CentralAuthUser::tableName( 'localuser' ), |
13 | 13 | array( 'lu_migrated_name' ), |
14 | 14 | '', |
15 | 15 | __METHOD__, |