r59842 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59841‎ | r59842 | r59843 >
Date:19:32, 8 December 2009
Author:simetrical
Status:ok
Tags:
Comment:
Rename some extauth functions and fields

Per Code Review at
<http://www.mediawiki.org/wiki/Special:Code/MediaWiki/53497#c4633&gt;. One
of the changes was a database field, and updaters might have to be
written for pgsql and DB2.
Modified paths:
  • /trunk/phase3/includes/ExternalUser.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-eu_local_id.sql (added) (history)
  • /trunk/phase3/maintenance/archives/patch-external_user.sql (modified) (history)
  • /trunk/phase3/maintenance/ibm_db2/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/postgres/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-external_user.sql
@@ -1,6 +1,6 @@
22 CREATE TABLE /*_*/external_user (
33 -- Foreign key to user_id
4 - eu_wiki_id int unsigned NOT NULL PRIMARY KEY,
 4+ eu_local_id int unsigned NOT NULL PRIMARY KEY,
55
66 -- Some opaque identifier provided by the external database
77 eu_external_id varchar(255) binary NOT NULL
Index: trunk/phase3/maintenance/archives/patch-eu_local_id.sql
@@ -0,0 +1,3 @@
 2+ALTER TABLE /*_*/external_user
 3+CHANGE COLUMN eu_wiki_id
 4+eu_local_id int unsigned NOT NULL;
Property changes on: trunk/phase3/maintenance/archives/patch-eu_local_id.sql
___________________________________________________________________
Name: svn:eol-style
15 + native
Index: trunk/phase3/maintenance/postgres/tables.sql
@@ -201,7 +201,7 @@
202202 CREATE INDEX externallinks_index ON externallinks (el_index);
203203
204204 CREATE TABLE external_user (
205 - eu_wiki_id INTEGER NOT NULL PRIMARY KEY,
 205+ eu_local_id INTEGER NOT NULL PRIMARY KEY,
206206 eu_external_id TEXT
207207 );
208208
Index: trunk/phase3/maintenance/updaters.inc
@@ -165,6 +165,9 @@
166166 array( 'add_index', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ),
167167 array( 'add_index', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ),
168168 array( 'add_field', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ),
 169+ // A field changed name mid-release cycle, so fix it for anyone using
 170+ // trunk
 171+ array( 'rename_eu_wiki_id' ),
169172 ),
170173
171174 'sqlite' => array(
@@ -1328,6 +1331,17 @@
13291332 wfOut( "Done populating log_search table.\n" );
13301333 }
13311334
 1335+function rename_eu_wiki_id() {
 1336+ global $wgDatabase;
 1337+ wfOut( "Renaming eu_wiki_id -> eu_local_id... " );
 1338+ if ( $wgDatabase->fieldExists( 'external_user', 'eu_local_id' ) ) {
 1339+ wfOut( "already done.\n" );
 1340+ return;
 1341+ }
 1342+ $wgDatabase->sourceFile( archive( 'patch-eu_local_id.sql' ) );
 1343+ wfOut( "ok\n" );
 1344+}
 1345+
13321346 /***********************************************************************
13331347 * Start PG stuff
13341348 * TODO: merge with above
Index: trunk/phase3/maintenance/ibm_db2/tables.sql
@@ -248,16 +248,16 @@
249249 --
250250 CREATE TABLE external_user (
251251 -- Foreign key to user_id
252 - eu_wiki_id BIGINT NOT NULL PRIMARY KEY,
 252+ eu_local_id BIGINT NOT NULL PRIMARY KEY,
253253
254254 -- Some opaque identifier provided by the external database
255255 eu_external_id VARCHAR(255) NOT NULL
256256 );
257257 CREATE UNIQUE INDEX eu_external_id_idx
258258 ON external_user (eu_external_id)
259 - INCLUDE (eu_wiki_id);
260 -CREATE UNIQUE INDEX eu_wiki_id_idx
261 - ON external_user (eu_wiki_id)
 259+ INCLUDE (eu_local_id);
 260+CREATE UNIQUE INDEX eu_local_id_idx
 261+ ON external_user (eu_local_id)
262262 INCLUDE (eu_external_id);
263263
264264
Index: trunk/phase3/maintenance/tables.sql
@@ -580,7 +580,7 @@
581581 --
582582 CREATE TABLE /*_*/external_user (
583583 -- Foreign key to user_id
584 - eu_wiki_id int unsigned NOT NULL PRIMARY KEY,
 584+ eu_local_id int unsigned NOT NULL PRIMARY KEY,
585585
586586 -- Some opaque identifier provided by the external database
587587 eu_external_id varchar(255) binary NOT NULL
Index: trunk/phase3/includes/ExternalUser.php
@@ -105,7 +105,7 @@
106106
107107 $dbr = wfGetDB( DB_SLAVE );
108108 $id = $dbr->selectField( 'external_user', 'eu_external_id',
109 - array( 'eu_wiki_id' => $user->getId() ), __METHOD__ );
 109+ array( 'eu_local_id' => $user->getId() ), __METHOD__ );
110110 if ( $id === false ) {
111111 return false;
112112 }
@@ -242,7 +242,7 @@
243243 * @param $pref string
244244 * @return mixed String or false
245245 */
246 - public static function prefMessage( $pref ) {
 246+ public static function getPrefMessage( $pref ) {
247247 return false;
248248 }
249249
@@ -277,11 +277,11 @@
278278 *
279279 * @param $id int user_id
280280 */
281 - public final function link( $id ) {
 281+ public final function linkToLocal( $id ) {
282282 $dbw = wfGetDB( DB_MASTER );
283283 $dbw->replace( 'external_user',
284 - array( 'eu_wiki_id', 'eu_external_id' ),
285 - array( 'eu_wiki_id' => $id,
 284+ array( 'eu_local_id', 'eu_external_id' ),
 285+ array( 'eu_local_id' => $id,
286286 'eu_external_id' => $this->getId() ),
287287 __METHOD__ );
288288 }
@@ -299,8 +299,8 @@
300300 array( 'eu_external_id' => $this->getId() )
301301 );
302302 return $row
303 - ? User::newFromId( $row->eu_wiki_id )
 303+ ? User::newFromId( $row->eu_local_id )
304304 : null;
305305 }
306306
307 -}
\ No newline at end of file
 307+}
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -371,7 +371,7 @@
372372 $wgAuth->initUser( $u, $autocreate );
373373
374374 if ( $this->mExtUser ) {
375 - $this->mExtUser->link( $u->getId() );
 375+ $this->mExtUser->linkToLocal( $u->getId() );
376376 $email = $this->mExtUser->getPref( 'emailaddress' );
377377 if ( $email && !$this->mEmail ) {
378378 $u->setEmail( $email );

Status & tagging log