http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90843

Revision: 90843
Author:   reedy
Date:     2011-06-26 19:16:04 +0000 (Sun, 26 Jun 2011)
Log Message:
-----------
Update calls to deprecated User::isValidEmailAddr

Fix trailing whitespace

Some minor documentation fixes

Modified Paths:
--------------
    trunk/phase3/includes/Autopromote.php
    trunk/phase3/includes/User.php
    trunk/phase3/includes/installer/PostgresInstaller.php
    trunk/phase3/includes/installer/WebInstallerPage.php
    trunk/phase3/includes/media/Generic.php
    trunk/phase3/includes/specials/SpecialConfirmemail.php
    trunk/phase3/includes/specials/SpecialUserlogin.php

Modified: trunk/phase3/includes/Autopromote.php
===================================================================
--- trunk/phase3/includes/Autopromote.php       2011-06-26 19:14:36 UTC (rev 
90842)
+++ trunk/phase3/includes/Autopromote.php       2011-06-26 19:16:04 UTC (rev 
90843)
@@ -29,9 +29,9 @@
 
        /**
         * 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 @@
 
                switch( $cond[0] ) {
                        case APCOND_EMAILCONFIRMED:
-                               if ( User::isValidEmailAddr( $user->getEmail() 
) ) {
+                               if ( Sanitizer::validateEmail( 
$user->getEmail() ) ) {
                                        if ( $wgEmailAuthentication ) {
                                                return 
(bool)$user->getEmailAuthenticationTimestamp();
                                        } else {

Modified: trunk/phase3/includes/User.php
===================================================================
--- trunk/phase3/includes/User.php      2011-06-26 19:14:36 UTC (rev 90842)
+++ trunk/phase3/includes/User.php      2011-06-26 19:16:04 UTC (rev 90843)
@@ -1104,16 +1104,16 @@
 
        /**
         * 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 @@
                                );
                        }
                }
-               return $toPromote; 
+               return $toPromote;
        }
 
        /**
@@ -1152,7 +1152,7 @@
                $this->mSkin = null;
                $this->mRights = null;
                $this->mEffectiveGroups = null;
-               $this->mOptions = null; 
+               $this->mOptions = null;
 
                if ( $reloadFrom ) {
                        $this->mLoadedItems = array();
@@ -2276,15 +2276,15 @@
                }
                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 @@
                        foreach( $res as $row ) {
                                $this->mFormerGroups[] = $row->ufg_group;
                        }
-               }       
+               }
                return $this->mFormerGroups;
        }
-       
+
        /**
         * Get the user's edit count.
         * @return Int
@@ -3310,12 +3310,15 @@
                $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;

Modified: trunk/phase3/includes/installer/PostgresInstaller.php
===================================================================
--- trunk/phase3/includes/installer/PostgresInstaller.php       2011-06-26 
19:14:36 UTC (rev 90842)
+++ trunk/phase3/includes/installer/PostgresInstaller.php       2011-06-26 
19:16:04 UTC (rev 90843)
@@ -129,7 +129,7 @@
 
        /**
         * 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 @@
         * 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 @@
                $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 @@
                if ( !$perms ) {
                        return false;
                }
-               return $perms->rolsuper === 't';                
+               return $perms->rolsuper === 't';
        }
 
        public function getSettingsForm() {
@@ -311,15 +311,15 @@
                }
 
                // 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 @@
                        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 @@
                        // 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 @@
 
                                $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 @@
        }
 
        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 @@
                        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"' ),

Modified: trunk/phase3/includes/installer/WebInstallerPage.php
===================================================================
--- trunk/phase3/includes/installer/WebInstallerPage.php        2011-06-26 
19:14:36 UTC (rev 90842)
+++ trunk/phase3/includes/installer/WebInstallerPage.php        2011-06-26 
19:16:04 UTC (rev 90843)
@@ -766,7 +766,7 @@
 
                // 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;
                }

Modified: trunk/phase3/includes/media/Generic.php
===================================================================
--- trunk/phase3/includes/media/Generic.php     2011-06-26 19:14:36 UTC (rev 
90842)
+++ trunk/phase3/includes/media/Generic.php     2011-06-26 19:16:04 UTC (rev 
90843)
@@ -161,7 +161,7 @@
         * 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 @@
        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 @@
        /**
         * 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 @@
                $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 @@
        /**
         * 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
         */

Modified: trunk/phase3/includes/specials/SpecialConfirmemail.php
===================================================================
--- trunk/phase3/includes/specials/SpecialConfirmemail.php      2011-06-26 
19:14:36 UTC (rev 90842)
+++ trunk/phase3/includes/specials/SpecialConfirmemail.php      2011-06-26 
19:16:04 UTC (rev 90843)
@@ -54,7 +54,7 @@
 
                if( empty( $code ) ) {
                        if( $wgUser->isLoggedIn() ) {
-                               if( User::isValidEmailAddr( $wgUser->getEmail() 
) ) {
+                               if( Sanitizer::validateEmail( 
$wgUser->getEmail() ) ) {
                                        $this->showRequestForm();
                                } else {
                                        $wgOut->addWikiMsg( 
'confirmemail_noemail' );

Modified: trunk/phase3/includes/specials/SpecialUserlogin.php
===================================================================
--- trunk/phase3/includes/specials/SpecialUserlogin.php 2011-06-26 19:14:36 UTC 
(rev 90842)
+++ trunk/phase3/includes/specials/SpecialUserlogin.php 2011-06-26 19:16:04 UTC 
(rev 90843)
@@ -206,7 +206,7 @@
                }
 
                # 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 @@
                        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 @@
                # 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 @@
                if( $msgname ){
                        $wgOut->addWikiMsg( $msgname, wfEscapeWikiText( 
$wgUser->getName() ) );
                }
-               
+
                $wgOut->addHTML( $injected_html );
 
                if ( !empty( $this->mReturnTo ) ) {
@@ -874,7 +874,7 @@
                        $block_reason,
                        $block->getBlocker()->getName()
                );
-               
+
                $wgOut->returnToMain( false );
        }
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to