r24864 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24863‎ | r24864 | r24865 >
Date:22:01, 16 August 2007
Author:brion
Status:old
Tags:
Comment:
Implement a couple of migration improvements suggested in wikitech-l discussions:
* Only use e-mail to verify other accounts when the account we got it from has verified it
* List the merge method in the pre-merge list
** FIXME -- needs localization and pretty UI; currently just spitting out the internal key strings ('primary', 'mail', 'password', etc)
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuthUser.php (modified) (history)
  • /trunk/extensions/CentralAuth/SpecialMergeAccount.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/CentralAuthUser.php
@@ -363,8 +363,11 @@
364364 // we can use it to match other accounts. If it doesn't,
365365 // we can't be sure that the other accounts with no mail
366366 // are the same person, so err on the side of caution.
 367+ //
 368+ // For additional safety, we'll only let the mail check
 369+ // propagate from a confirmed account
367370 $passingMail = array();
368 - if( $this->mEmail != '' ) {
 371+ if( $this->mEmail != '' && $this->mEmailAuthenticated ) {
369372 $passingMail[$this->mEmail] = true;
370373 }
371374
@@ -373,6 +376,7 @@
374377 if( $passwords ) {
375378 foreach( $migrationSet as $db => $local ) {
376379 if( $local['email'] != ''
 380+ && $local['emailAuthenticated']
377381 && $this->matchHashes( $passwords, $local['id'], $local['password'] ) ) {
378382 $passingMail[$local['email']] = true;
379383 }
@@ -419,9 +423,10 @@
420424 * @param string &$home set to false if no permission to do checks
421425 * @param array &$attached on success, list of wikis which will be auto-attached
422426 * @param array &$unattached on success, list of wikis which won't be auto-attached
 427+ * @param array &$methods on success, associative array of each wiki's attachment method
423428 * @return bool true if password matched current and home account
424429 */
425 - function migrationDryRun( $passwords, &$home, &$attached, &$unattached ) {
 430+ function migrationDryRun( $passwords, &$home, &$attached, &$unattached, &$methods ) {
426431 global $wgDBname;
427432
428433 $home = false;
@@ -449,14 +454,17 @@
450455
451456 $this->mHomeWiki = $home;
452457 $this->mEmail = $local['email'];
 458+ $this->mEmailAuthenticated = $local['emailAuthenticated'];
453459 $attach = $this->prepareMigration( $migrationSet, $passwords );
454460
455461 $all = array_keys( $migrationSet );
456462 $attached = array_keys( $attach );
457463 $unattached = array_diff( $all, $attached );
 464+ $methods = $attach;
458465
459466 sort( $attached );
460467 sort( $unattached );
 468+ ksort( $methods );
461469
462470 return true;
463471 }
@@ -473,6 +481,7 @@
474482 $this->mHomeWiki = $this->chooseHomeWiki( $migrationSet );
475483 $home = $migrationSet[$this->mHomeWiki];
476484 $this->mEmail = $home['email'];
 485+ $this->mEmailAuthenticated = $home['emailAuthenticated'];
477486
478487 $attach = $this->prepareMigration( $migrationSet, $passwords );
479488
Index: trunk/extensions/CentralAuth/SpecialMergeAccount.php
@@ -159,7 +159,8 @@
160160 $home = false;
161161 $attached = array();
162162 $unattached = array();
163 - $ok = $globalUser->migrationDryRun( $passwords, $home, $attached, $unattached );
 163+ $methods = array();
 164+ $ok = $globalUser->migrationDryRun( $passwords, $home, $attached, $unattached, $methods );
164165
165166 if( $ok ) {
166167 // This is the global account or matched it
@@ -185,7 +186,7 @@
186187 }
187188
188189 $subAttached = array_diff( $attached, array( $home ) );
189 - $wgOut->addHtml( $this->step3ActionForm( $home, $subAttached ) );
 190+ $wgOut->addHtml( $this->step3ActionForm( $home, $subAttached, $methods ) );
190191
191192 } elseif( $home ) {
192193 $wgOut->addWikiText( "The migration system couldn't confirm that you're the owner of the home wiki account for your username." .
@@ -338,39 +339,37 @@
339340 }
340341 }
341342
342 - function listAttached( $dblist ) {
343 - return $this->listForm( $dblist, 'unmerge', wfMsg( 'centralauth-admin-unmerge' ) );
 343+ function listAttached( $dblist, $methods=array() ) {
 344+ return $this->listWikis( $dblist, $methods );
344345 }
345346
346347 function listUnattached( $dblist ) {
347 - return $this->listForm( $dblist, 'admin', wfMsg( 'centralauth-admin-merge' ) );
 348+ return $this->listWikis( $dblist );
348349 }
349350
350 - function listForm( $dblist /* Params not used: , $action, $buttonText */ ) {
351 - $list = $this->listWikis( $dblist );
352 -
353 - return $list;
354 - }
355 -
356 - function listWikis( $list ) {
 351+ function listWikis( $list, $methods=array() ) {
357352 asort( $list );
358 - return $this->formatList( $list, array( $this, 'listWikiItem' ) );
 353+ return $this->formatList( $list, $methods, array( $this, 'listWikiItem' ) );
359354 }
360355
361 - function formatList( $items, $callback ) {
 356+ function formatList( $items, $methods, $callback ) {
362357 if( empty( $items ) ) {
363358 return '';
364359 } else {
 360+ $itemMethods = array();
 361+ foreach( $items as $item ) {
 362+ $itemMethods[] = isset( $methods[$item] ) ? $methods[$item] : '';
 363+ }
365364 return "<ul>\n<li>" .
366365 implode( "</li>\n<li>",
367 - array_map( $callback, $items ) ) .
 366+ array_map( $callback, $items, $itemMethods ) ) .
368367 "</li>\n</ul>\n";
369368 }
370369 }
371370
372 - function listWikiItem( $dbname ) {
 371+ function listWikiItem( $dbname, $method ) {
373372 return
374 - $this->foreignUserLink( $dbname );
 373+ $this->foreignUserLink( $dbname ) . ' ' . $method;
375374 }
376375
377376 function foreignUserLink( $dbname ) {
@@ -463,7 +462,7 @@
464463 wfMsg( 'centralauth-merge-step2-submit' ) );
465464 }
466465
467 - private function step3ActionForm( $home, $attached ) {
 466+ private function step3ActionForm( $home, $attached, $methods ) {
468467 global $wgUser;
469468 return $this->actionForm(
470469 'initial',
@@ -471,12 +470,12 @@
472471 wfMsgExt( 'centralauth-merge-step3-detail', 'parse', $wgUser->getName() ) .
473472 '<h3>' . wfMsgHtml( 'centralauth-list-home-title' ) . '</h3>' .
474473 wfMsgExt( 'centralauth-list-home-dryrun', 'parse' ) .
475 - $this->listAttached( array( $home ) ) .
 474+ $this->listAttached( array( $home ), $methods ) .
476475 ( count( $attached )
477476 ? ( '<h3>' . wfMsgHtml( 'centralauth-list-attached-title' ) . '</h3>' .
478477 wfMsgExt( 'centralauth-list-attached-dryrun', 'parse', $wgUser->getName() ) )
479478 : '' ) .
480 - $this->listAttached( $attached ) .
 479+ $this->listAttached( $attached, $methods ) .
481480 '<p>' .
482481 Xml::submitButton( wfMsg( 'centralauth-merge-step3-submit' ),
483482 array( 'name' => 'wpLogin' ) ) .

Status & tagging log