r79678 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79677‎ | r79678 | r79679 >
Date:22:37, 5 January 2011
Author:demon
Status:ok
Tags:
Comment:
* Validate e-mail address if provided
* Actually setEmail() on the sysop account we're creating
* Reinstate "subscribe to mediawiki-announce" feature (reverts r79089) which actually works
Modified paths:
  • /trunk/phase3/includes/installer/CoreInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstallerPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/CoreInstaller.php
@@ -179,13 +179,26 @@
180180 );
181181
182182 /**
 183+ * URL to mediawiki-announce subscription
 184+ */
 185+ protected $mediaWikiAnnounceUrl = 'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
 186+
 187+ /**
 188+ * Supported language codes for Mailman
 189+ */
 190+ protected $mediaWikiAnnounceLanguages = array(
 191+ 'ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fr', 'hr', 'hu',
 192+ 'it', 'ja', 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'pt-br', 'ro', 'ru',
 193+ 'sl', 'sr', 'sv', 'tr', 'uk'
 194+ );
 195+
 196+ /**
183197 * TODO: document
184198 *
185199 * @param $status Status
186200 */
187201 public abstract function showStatusMessage( Status $status );
188202
189 -
190203 /**
191204 * Constructor, always call this from child classes.
192205 */
@@ -480,12 +493,41 @@
481494
482495 $user->addGroup( 'sysop' );
483496 $user->addGroup( 'bureaucrat' );
 497+ if( $this->getVar( '_AdminEmail' ) ) {
 498+ $user->setEmail( $this->getVar( '_AdminEmail' ) );
 499+ }
484500 $user->saveSettings();
485501 }
 502+ $status = Status::newGood();
486503
487 - return Status::newGood();
 504+ if( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
 505+ $this->subscribeToMediaWikiAnnounce( $status );
 506+ }
 507+
 508+ return $status;
488509 }
489510
 511+ private function subscribeToMediaWikiAnnounce( Status $s ) {
 512+ $params = array(
 513+ 'email' => $this->getVar( '_AdminEmail' ),
 514+ 'language' => 'en',
 515+ 'digest' => 0
 516+ );
 517+
 518+ // Mailman doesn't support as many languages as we do, so check to make
 519+ // sure their selected language is available
 520+ $myLang = $this->getVar( '_UserLang' );
 521+ if( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) {
 522+ $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR
 523+ $params['language'] = $myLang;
 524+ }
 525+
 526+ $res = Http::post( $this->mediaWikiAnnounceUrl, array( 'postData' => $params ) );
 527+ if( !$res ) {
 528+ $s->warning( 'config-install-subscribe-fail' );
 529+ }
 530+ }
 531+
490532 /**
491533 * Insert Main Page with default content.
492534 *
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -343,6 +343,7 @@
344344 '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.',
345345 'config-admin-error-user' => 'Internal error when creating an admin with the name "<nowiki>$1</nowiki>".',
346346 'config-admin-error-password' => 'Internal error when setting a password for the admin "<nowiki>$1</nowiki>": <pre>$2</pre>',
 347+ 'config-admin-error-bademail' => 'You have entered an invalid e-mail address',
347348 'config-subscribe' => 'Subscribe to the [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce release announcements mailing list].',
348349 'config-subscribe-help' => 'This is a low-volume mailing list used for release announcements, including important security announcements.
349350 You should subscribe to it and update your MediaWiki installation when new versions come out.',
@@ -465,6 +466,7 @@
466467 Consider changing it manually.",
467468 'config-install-upgradekey' => 'Generating default upgrade key',
468469 'config-install-sysop' => 'Creating administrator user account',
 470+ 'config-install-subscribe-fail' => 'Unable to subscribe to mediawiki-announce',
469471 'config-install-mainpage' => 'Creating main page with default content',
470472 'config-install-mainpage-failed' => 'Could not insert main page.',
471473 'config-install-done' => "'''Congratulations!'''
Index: trunk/phase3/includes/installer/WebInstallerPage.php
@@ -596,16 +596,11 @@
597597 'label' => 'config-admin-email',
598598 'help' => $this->parent->getHelpBox( 'config-admin-email-help' )
599599 ) ) .
600 - /**
601 - * Uncomment this feature once we've got some sort of API to mailman
602 - * to handle these subscriptions. Some dummy wrapper script on the
603 - * mailman box that shell's out to mailman/bin/add_members would do
604 - $this->parent->getCheckBox( array(
 600+ $this->parent->getCheckBox( array(
605601 'var' => '_Subscribe',
606602 'label' => 'config-subscribe',
607603 'help' => $this->parent->getHelpBox( 'config-subscribe-help' )
608604 ) ) .
609 - */
610605 $this->getFieldSetEnd() .
611606 $this->parent->getInfoBox( wfMsg( 'config-almost-done' ) ) .
612607 $this->parent->getRadioSet( array(
@@ -708,6 +703,14 @@
709704 $this->setVar( '_AdminPassword2', '' );
710705 $retVal = false;
711706 }
 707+
 708+ // Validate e-mail if provided
 709+ $email = $this->getVar( '_AdminEmail' );
 710+ if( $email && !User::isValidEmailAddr( $email ) ) {
 711+ $this->parent->showError( 'config-admin-error-bademail' );
 712+ $retVal = false;
 713+ }
 714+
712715 return $retVal;
713716 }
714717

Follow-up revisions

RevisionCommit summaryAuthorDate
r801901.17: MFT first batch of installer changes: r78043, r78231, r78259, r78300, r...catrope20:47, 13 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79089Comment out "subscribe to mediawiki-l" feature until we actually implement it...demon23:02, 27 December 2010

Status & tagging log