Update calls to deprecated User::isValidEmailAddr
authorSam Reed <reedy@users.mediawiki.org>
Sun, 26 Jun 2011 19:16:04 +0000 (19:16 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 26 Jun 2011 19:16:04 +0000 (19:16 +0000)
Fix trailing whitespace

Some minor documentation fixes

includes/Autopromote.php
includes/User.php
includes/installer/PostgresInstaller.php
includes/installer/WebInstallerPage.php
includes/media/Generic.php
includes/specials/SpecialConfirmemail.php
includes/specials/SpecialUserlogin.php

index 2a869ed..d4f9b2f 100644 (file)
@@ -29,9 +29,9 @@ class Autopromote {
 
        /**
         * Get the groups for the given user based on the given criteria.
-        * 
+        *
         * Does not return groups the user already belongs to or has once belonged.
-        * 
+        *
         * @param $user The user to get the groups for
         * @param $event String key in $wgAutopromoteOnce (each one has groups/criteria)
         *
@@ -153,7 +153,7 @@ class Autopromote {
 
                switch( $cond[0] ) {
                        case APCOND_EMAILCONFIRMED:
-                               if ( User::isValidEmailAddr( $user->getEmail() ) ) {
+                               if ( Sanitizer::validateEmail( $user->getEmail() ) ) {
                                        if ( $wgEmailAuthentication ) {
                                                return (bool)$user->getEmailAuthenticationTimestamp();
                                        } else {
index 2660356..c3dd8ea 100644 (file)
@@ -1104,16 +1104,16 @@ class User {
 
        /**
         * Add the user to the group if he/she meets given criteria.
-        * 
-        * Contrary to autopromotion by \ref $wgAutopromote, the group will be 
+        *
+        * Contrary to autopromotion by \ref $wgAutopromote, the group will be
         *   possible to remove manually via Special:UserRights. In such case it
         *   will not be re-added automatically. The user will also not lose the
         *   group if they no longer meet the criteria.
-        *   
+        *
         * @param $event String key in $wgAutopromoteOnce (each one has groups/criteria)
-        *   
-        * @return array Array of groups the user has been promoted to.  
-        * 
+        *
+        * @return array Array of groups the user has been promoted to.
+        *
         * @see $wgAutopromoteOnce
         */
        public function addAutopromoteOnceGroups( $event ) {
@@ -1135,7 +1135,7 @@ class User {
                                );
                        }
                }
-               return $toPromote; 
+               return $toPromote;
        }
 
        /**
@@ -1152,7 +1152,7 @@ class User {
                $this->mSkin = null;
                $this->mRights = null;
                $this->mEffectiveGroups = null;
-               $this->mOptions = null; 
+               $this->mOptions = null;
 
                if ( $reloadFrom ) {
                        $this->mLoadedItems = array();
@@ -2276,15 +2276,15 @@ class User {
                }
                return $this->mEffectiveGroups;
        }
-       
+
        /**
-        * Returns the groups the user has belonged to. 
-        * 
+        * Returns the groups the user has belonged to.
+        *
         * The user may still belong to the returned groups. Compare with getGroups().
-        * 
+        *
         * The function will not return groups the user had belonged to before MW 1.17
-        *  
-        * @return array Names of the groups the user has belonged to. 
+        *
+        * @return array Names of the groups the user has belonged to.
         */
        function getFormerGroups() {
                if( is_null( $this->mFormerGroups ) ) {
@@ -2297,10 +2297,10 @@ class User {
                        foreach( $res as $row ) {
                                $this->mFormerGroups[] = $row->ufg_group;
                        }
-               }       
+               }
                return $this->mFormerGroups;
        }
-       
+
        /**
         * Get the user's edit count.
         * @return Int
@@ -3310,12 +3310,15 @@ class User {
                $this->load();
                $confirmed = true;
                if( wfRunHooks( 'EmailConfirmed', array( &$this, &$confirmed ) ) ) {
-                       if( $this->isAnon() )
+                       if( $this->isAnon() ) {
                                return false;
-                       if( !self::isValidEmailAddr( $this->mEmail ) )
+                       }
+                       if( !Sanitizer::validateEmail( $this->mEmail ) ) {
                                return false;
-                       if( $wgEmailAuthentication && !$this->getEmailAuthenticationTimestamp() )
+                       }
+                       if( $wgEmailAuthentication && !$this->getEmailAuthenticationTimestamp() ) {
                                return false;
+                       }
                        return true;
                } else {
                        return $confirmed;
index ea0e8d9..7c4a6a8 100644 (file)
@@ -129,7 +129,7 @@ class PostgresInstaller extends DatabaseInstaller {
 
        /**
         * Get a special type of connection
-        * @param $type See openPgConnection() for details.
+        * @param $type string See openPgConnection() for details.
         * @return Status
         */
        protected function getPgConnection( $type ) {
@@ -151,35 +151,35 @@ class PostgresInstaller extends DatabaseInstaller {
         * Get a connection of a specific PostgreSQL-specific type. Connections
         * of a given type are cached.
         *
-        * PostgreSQL lacks cross-database operations, so after the new database is 
-        * created, you need to make a separate connection to connect to that 
-        * database and add tables to it. 
+        * PostgreSQL lacks cross-database operations, so after the new database is
+        * created, you need to make a separate connection to connect to that
+        * database and add tables to it.
         *
-        * New tables are owned by the user that creates them, and MediaWiki's 
-        * PostgreSQL support has always assumed that the table owner will be 
-        * $wgDBuser. So before we create new tables, we either need to either 
-        * connect as the other user or to execute a SET ROLE command. Using a 
-        * separate connection for this allows us to avoid accidental cross-module 
+        * New tables are owned by the user that creates them, and MediaWiki's
+        * PostgreSQL support has always assumed that the table owner will be
+        * $wgDBuser. So before we create new tables, we either need to either
+        * connect as the other user or to execute a SET ROLE command. Using a
+        * separate connection for this allows us to avoid accidental cross-module
         * dependencies.
         *
         * @param $type The type of connection to get:
         *    - create-db:     A connection for creating DBs, suitable for pre-
         *                     installation.
-        *    - create-schema: A connection to the new DB, for creating schemas and 
+        *    - create-schema: A connection to the new DB, for creating schemas and
         *                     other similar objects in the new DB.
         *    - create-tables: A connection with a role suitable for creating tables.
         *
-        * @return A Status object. On success, a connection object will be in the 
+        * @return A Status object. On success, a connection object will be in the
         *   value member.
         */
        protected function openPgConnection( $type ) {
                switch ( $type ) {
                        case 'create-db':
                                return $this->openConnectionToAnyDB(
-                                       $this->getVar( '_InstallUser' ), 
+                                       $this->getVar( '_InstallUser' ),
                                        $this->getVar( '_InstallPassword' ) );
                        case 'create-schema':
-                               return $this->openConnectionWithParams( 
+                               return $this->openConnectionWithParams(
                                        $this->getVar( '_InstallUser' ),
                                        $this->getVar( '_InstallPassword' ),
                                        $this->getVar( 'wgDBname' ) );
@@ -236,7 +236,7 @@ class PostgresInstaller extends DatabaseInstaller {
                $conn = $status->value;
                $superuser = $this->getVar( '_InstallUser' );
 
-               $row = $conn->selectRow( '"pg_catalog"."pg_roles"', '*', 
+               $row = $conn->selectRow( '"pg_catalog"."pg_roles"', '*',
                        array( 'rolname' => $superuser ), __METHOD__ );
                return $row;
        }
@@ -254,7 +254,7 @@ class PostgresInstaller extends DatabaseInstaller {
                if ( !$perms ) {
                        return false;
                }
-               return $perms->rolsuper === 't';                
+               return $perms->rolsuper === 't';
        }
 
        public function getSettingsForm() {
@@ -311,15 +311,15 @@ class PostgresInstaller extends DatabaseInstaller {
                }
 
                // Existing web account. Test the connection.
-               $status = $this->openConnectionToAnyDB( 
+               $status = $this->openConnectionToAnyDB(
                        $this->getVar( 'wgDBuser' ),
                        $this->getVar( 'wgDBpassword' ) );
                if ( !$status->isOK() ) {
                        return $status;
                }
 
-               // The web user is conventionally the table owner in PostgreSQL 
-               // installations. Make sure the install user is able to create 
+               // The web user is conventionally the table owner in PostgreSQL
+               // installations. Make sure the install user is able to create
                // objects on behalf of the web user.
                if ( $same || $this->canCreateObjectsForWebUser() ) {
                        return Status::newGood();
@@ -444,14 +444,14 @@ class PostgresInstaller extends DatabaseInstaller {
                        try {
                                $conn->query( "CREATE SCHEMA $safeschema AUTHORIZATION $safeuser" );
                        } catch ( DBQueryError $e ) {
-                               return Status::newFatal( 'config-install-pg-schema-failed', 
+                               return Status::newFatal( 'config-install-pg-schema-failed',
                                        $this->getVar( '_InstallUser' ), $schema );
                        }
                }
 
                // If we created a user, alter it now to search the new schema by default
                if ( $this->getVar( '_CreateDBAccount' ) ) {
-                       $conn->query( "ALTER ROLE $safeuser SET search_path = $safeschema, public", 
+                       $conn->query( "ALTER ROLE $safeuser SET search_path = $safeschema, public",
                                __METHOD__ );
                }
 
@@ -487,8 +487,8 @@ class PostgresInstaller extends DatabaseInstaller {
                        // Create the user
                        try {
                                $sql = "CREATE ROLE $safeuser NOCREATEDB LOGIN PASSWORD $safepass";
-                               
-                               // If the install user is not a superuser, we need to make the install 
+
+                               // If the install user is not a superuser, we need to make the install
                                // user a member of the new user's group, so that the install user will
                                // be able to create a schema and other objects on behalf of the new user.
                                if ( !$this->isSuperUser() ) {
@@ -497,7 +497,7 @@ class PostgresInstaller extends DatabaseInstaller {
 
                                $conn->query( $sql, __METHOD__ );
                        } catch ( DBQueryError $e ) {
-                               return Status::newFatal( 'config-install-user-create-failed', 
+                               return Status::newFatal( 'config-install-user-create-failed',
                                        $this->getVar( 'wgDBuser' ), $e->getMessage() );
                        }
                }
@@ -559,7 +559,7 @@ class PostgresInstaller extends DatabaseInstaller {
        }
 
        public function setupPLpgSQL() {
-               // Connect as the install user, since it owns the database and so is 
+               // Connect as the install user, since it owns the database and so is
                // the user that needs to run "CREATE LANGAUGE"
                $status = $this->getPgConnection( 'create-schema' );
                if ( !$status->isOK() ) {
@@ -574,7 +574,7 @@ class PostgresInstaller extends DatabaseInstaller {
                        return Status::newGood();
                }
 
-               // plpgsql is not installed, but if we have a pg_pltemplate table, we 
+               // plpgsql is not installed, but if we have a pg_pltemplate table, we
                // should be able to create it
                $exists = $conn->selectField(
                        array( '"pg_catalog"."pg_class"', '"pg_catalog"."pg_namespace"' ),
index a06dc20..3da184d 100644 (file)
@@ -766,7 +766,7 @@ class WebInstaller_Name extends WebInstallerPage {
 
                // Validate e-mail if provided
                $email = $this->getVar( '_AdminEmail' );
-               if( $email && !User::isValidEmailAddr( $email ) ) {
+               if( $email && !Sanitizer::validateEmail( $email ) ) {
                        $this->parent->showError( 'config-admin-error-bademail' );
                        $retVal = false;
                }
index 527dd36..0c6de78 100644 (file)
@@ -161,7 +161,7 @@ abstract class MediaHandler {
         * MediaHanlder::METADATA_COMPATIBLE if metadata is old but backwards
         * compatible (which may or may not trigger a metadata reload).
         */
-       function isMetadataValid( $image, $metadata ) { 
+       function isMetadataValid( $image, $metadata ) {
                return self::METADATA_GOOD;
        }
 
@@ -210,14 +210,14 @@ abstract class MediaHandler {
        function getThumbType( $ext, $mime, $params = null ) {
                $magic = MimeMagic::singleton();
                if ( !$ext || $magic->isMatchingExtension( $ext, $mime ) === false ) {
-                       // The extension is not valid for this mime type and we do 
+                       // The extension is not valid for this mime type and we do
                        // recognize the mime type
                        $extensions = $magic->getExtensionsForType( $mime );
                        if ( $extensions ) {
                                return array( strtok( $extensions, ' ' ), $mime );
                        }
                }
-               
+
                // The extension is correct (true) or the mime type is unknown to
                // MediaWiki (null)
                return array( $ext, $mime );
@@ -357,12 +357,12 @@ abstract class MediaHandler {
        /**
         * This is used to generate an array element for each metadata value
         * That array is then used to generate the table of metadata values
-        * on the image page 
+        * on the image page
         *
         * @param &$array Array An array containing elements for each type of visibility
         * and each of those elements being an array of metadata items. This function adds
         * a value to that array.
-        * @param $visibility string ('visible' or 'collapsed') if this value is hidden
+        * @param $visbility string ('visible' or 'collapsed') if this value is hidden
         * by default.
         * @param $type String type of metadata tag (currently always 'exif')
         * @param $id String the name of the metadata tag (like 'artist' for example).
@@ -381,7 +381,7 @@ abstract class MediaHandler {
                $msgName = "$type-$id";
                if ( wfEmptyMsg( $msgName ) ) {
                        // This is for future compatibility when using instant commons.
-                       // So as to not display as ugly a name if a new metadata 
+                       // So as to not display as ugly a name if a new metadata
                        // property is defined that we don't know about
                        // (not a major issue since such a property would be collapsed
                        // by default).
@@ -455,10 +455,10 @@ abstract class MediaHandler {
        /**
         * File validation hook called on upload.
         *
-        * If the file at the given local path is not valid, or its MIME type does not 
+        * If the file at the given local path is not valid, or its MIME type does not
         * match the handler class, a Status object should be returned containing
         * relevant errors.
-        * 
+        *
         * @param $fileName The local path to the file.
         * @return Status object
         */
index 3e45d30..2370b6b 100644 (file)
@@ -54,7 +54,7 @@ class EmailConfirmation extends UnlistedSpecialPage {
 
                if( empty( $code ) ) {
                        if( $wgUser->isLoggedIn() ) {
-                               if( User::isValidEmailAddr( $wgUser->getEmail() ) ) {
+                               if( Sanitizer::validateEmail( $wgUser->getEmail() ) ) {
                                        $this->showRequestForm();
                                } else {
                                        $wgOut->addWikiMsg( 'confirmemail_noemail' );
index e16e00f..e8de862 100644 (file)
@@ -206,7 +206,7 @@ class LoginForm extends SpecialPage {
                }
 
                # Send out an email authentication message if needed
-               if( $wgEmailAuthentication && User::isValidEmailAddr( $u->getEmail() ) ) {
+               if( $wgEmailAuthentication && Sanitizer::validateEmail( $u->getEmail() ) ) {
                        $status = $u->sendConfirmationMail();
                        if( $status->isGood() ) {
                                $wgOut->addWikiMsg( 'confirmemail_oncreate' );
@@ -355,7 +355,7 @@ class LoginForm extends SpecialPage {
                        return false;
                }
 
-               if( !empty( $this->mEmail ) && !User::isValidEmailAddr( $this->mEmail ) ) {
+               if( !empty( $this->mEmail ) && !Sanitizer::validateEmail( $this->mEmail ) ) {
                        $this->mainLoginForm( wfMsg( 'invalidemailaddress' ) );
                        return false;
                }
@@ -814,12 +814,12 @@ class LoginForm extends SpecialPage {
                # Run any hooks; display injected HTML
                $injected_html = '';
                $welcome_creation_msg = 'welcomecreation';
-               
+
                wfRunHooks( 'UserLoginComplete', array( &$wgUser, &$injected_html ) );
-               
+
                //let any extensions change what message is shown
                wfRunHooks( 'BeforeWelcomeCreation', array( &$welcome_creation_msg, &$injected_html ) );
-               
+
                $this->displaySuccessfulLogin( $welcome_creation_msg, $injected_html );
        }
 
@@ -833,7 +833,7 @@ class LoginForm extends SpecialPage {
                if( $msgname ){
                        $wgOut->addWikiMsg( $msgname, wfEscapeWikiText( $wgUser->getName() ) );
                }
-               
+
                $wgOut->addHTML( $injected_html );
 
                if ( !empty( $this->mReturnTo ) ) {
@@ -874,7 +874,7 @@ class LoginForm extends SpecialPage {
                        $block_reason,
                        $block->getBlocker()->getName()
                );
-               
+
                $wgOut->returnToMain( false );
        }