r65698 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65697‎ | r65698 | r65699 >
Date:16:12, 30 April 2010
Author:avar
Status:ok
Tags:
Comment:
Bark with something more than "Failed" if !$user or if we get a PasswordError

The root cause of this issue is failed validation earlier in the
installer. It's still a good idea to bark with specific internal
errors at this point, in case something bad happens that we hadn't
thought to check for.

In my case I got "Failed" because $user === $password. I couldn't
produce a failure in User::newFromName() but sanity checks are good.
Modified paths:
  • /branches/new-installer/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /branches/new-installer/phase3/includes/installer/Installer.php (modified) (history)

Diff [purge]

Index: branches/new-installer/phase3/includes/installer/Installer.i18n.php
@@ -280,6 +280,8 @@
281281 'config-admin-password-mismatch' => 'The two passwords you entered do not match.',
282282 'config-admin-email' => 'E-mail address:',
283283 'config-admin-email-help' => 'Enter an e-mail address here to allow you to receive e-mail from other users on the wiki, reset your password, and be notified of changes to pages on your watchlist.',
 284+ 'config-admin-error-user' => 'Internal error when creating an admin with the name "<nowiki>$1</nowiki>".',
 285+ 'config-admin-error-password' => 'Internal error when setting a password for the admin "<nowiki>$1</nowiki>": <pre>$2</pre>',
284286 'config-subscribe' => 'Subscribe to the [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce release announcements mailing list].',
285287 'config-subscribe-help' => 'This is a low-volume mailing list used for release announcements, including important security announcements.
286288 You should subscribe to it and update your MediaWiki installation when new versions come out.',
Index: branches/new-installer/phase3/includes/installer/Installer.php
@@ -863,15 +863,19 @@
864864 }
865865
866866 public function installSysop() {
867 - $user = User::newFromName( $this->getVar( '_AdminName' ) );
 867+ $name = $this->getVar( '_AdminName' );
 868+ $user = User::newFromName( $name );
868869 if ( !$user ) {
869 - return false; // we should've validated this earlier anyway!
 870+ // we should've validated this earlier anyway!
 871+ $this->output->addWarningMsg( 'config-admin-error-user', $name );
 872+ return false;
870873 }
871874 if ( $user->idForName() == 0 ) {
872875 $user->addToDatabase();
873876 try {
874877 $user->setPassword( $this->getVar( '_AdminPassword' ) );
875878 } catch( PasswordError $pwe ) {
 879+ $this->output->addWarningMsg( 'config-admin-error-password', $name, $pwe->getMessage() );
876880 return false;
877881 }
878882 $user->saveSettings();

Status & tagging log