r90843 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90842‎ | r90843 | r90844 >
Date:19:16, 26 June 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Update calls to deprecated User::isValidEmailAddr

Fix trailing whitespace

Some minor documentation fixes
Modified paths:
  • /trunk/phase3/includes/Autopromote.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/installer/PostgresInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstallerPage.php (modified) (history)
  • /trunk/phase3/includes/media/Generic.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialConfirmemail.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1104,16 +1104,16 @@
11051105
11061106 /**
11071107 * Add the user to the group if he/she meets given criteria.
1108 - *
1109 - * Contrary to autopromotion by \ref $wgAutopromote, the group will be
 1108+ *
 1109+ * Contrary to autopromotion by \ref $wgAutopromote, the group will be
11101110 * possible to remove manually via Special:UserRights. In such case it
11111111 * will not be re-added automatically. The user will also not lose the
11121112 * group if they no longer meet the criteria.
1113 - *
 1113+ *
11141114 * @param $event String key in $wgAutopromoteOnce (each one has groups/criteria)
1115 - *
1116 - * @return array Array of groups the user has been promoted to.
1117 - *
 1115+ *
 1116+ * @return array Array of groups the user has been promoted to.
 1117+ *
11181118 * @see $wgAutopromoteOnce
11191119 */
11201120 public function addAutopromoteOnceGroups( $event ) {
@@ -1135,7 +1135,7 @@
11361136 );
11371137 }
11381138 }
1139 - return $toPromote;
 1139+ return $toPromote;
11401140 }
11411141
11421142 /**
@@ -1152,7 +1152,7 @@
11531153 $this->mSkin = null;
11541154 $this->mRights = null;
11551155 $this->mEffectiveGroups = null;
1156 - $this->mOptions = null;
 1156+ $this->mOptions = null;
11571157
11581158 if ( $reloadFrom ) {
11591159 $this->mLoadedItems = array();
@@ -2276,15 +2276,15 @@
22772277 }
22782278 return $this->mEffectiveGroups;
22792279 }
2280 -
 2280+
22812281 /**
2282 - * Returns the groups the user has belonged to.
2283 - *
 2282+ * Returns the groups the user has belonged to.
 2283+ *
22842284 * The user may still belong to the returned groups. Compare with getGroups().
2285 - *
 2285+ *
22862286 * The function will not return groups the user had belonged to before MW 1.17
2287 - *
2288 - * @return array Names of the groups the user has belonged to.
 2287+ *
 2288+ * @return array Names of the groups the user has belonged to.
22892289 */
22902290 function getFormerGroups() {
22912291 if( is_null( $this->mFormerGroups ) ) {
@@ -2297,10 +2297,10 @@
22982298 foreach( $res as $row ) {
22992299 $this->mFormerGroups[] = $row->ufg_group;
23002300 }
2301 - }
 2301+ }
23022302 return $this->mFormerGroups;
23032303 }
2304 -
 2304+
23052305 /**
23062306 * Get the user's edit count.
23072307 * @return Int
@@ -3310,12 +3310,15 @@
33113311 $this->load();
33123312 $confirmed = true;
33133313 if( wfRunHooks( 'EmailConfirmed', array( &$this, &$confirmed ) ) ) {
3314 - if( $this->isAnon() )
 3314+ if( $this->isAnon() ) {
33153315 return false;
3316 - if( !self::isValidEmailAddr( $this->mEmail ) )
 3316+ }
 3317+ if( !Sanitizer::validateEmail( $this->mEmail ) ) {
33173318 return false;
3318 - if( $wgEmailAuthentication && !$this->getEmailAuthenticationTimestamp() )
 3319+ }
 3320+ if( $wgEmailAuthentication && !$this->getEmailAuthenticationTimestamp() ) {
33193321 return false;
 3322+ }
33203323 return true;
33213324 } else {
33223325 return $confirmed;
Index: trunk/phase3/includes/installer/PostgresInstaller.php
@@ -129,7 +129,7 @@
130130
131131 /**
132132 * Get a special type of connection
133 - * @param $type See openPgConnection() for details.
 133+ * @param $type string See openPgConnection() for details.
134134 * @return Status
135135 */
136136 protected function getPgConnection( $type ) {
@@ -151,35 +151,35 @@
152152 * Get a connection of a specific PostgreSQL-specific type. Connections
153153 * of a given type are cached.
154154 *
155 - * PostgreSQL lacks cross-database operations, so after the new database is
156 - * created, you need to make a separate connection to connect to that
157 - * database and add tables to it.
 155+ * PostgreSQL lacks cross-database operations, so after the new database is
 156+ * created, you need to make a separate connection to connect to that
 157+ * database and add tables to it.
158158 *
159 - * New tables are owned by the user that creates them, and MediaWiki's
160 - * PostgreSQL support has always assumed that the table owner will be
161 - * $wgDBuser. So before we create new tables, we either need to either
162 - * connect as the other user or to execute a SET ROLE command. Using a
163 - * separate connection for this allows us to avoid accidental cross-module
 159+ * New tables are owned by the user that creates them, and MediaWiki's
 160+ * PostgreSQL support has always assumed that the table owner will be
 161+ * $wgDBuser. So before we create new tables, we either need to either
 162+ * connect as the other user or to execute a SET ROLE command. Using a
 163+ * separate connection for this allows us to avoid accidental cross-module
164164 * dependencies.
165165 *
166166 * @param $type The type of connection to get:
167167 * - create-db: A connection for creating DBs, suitable for pre-
168168 * installation.
169 - * - create-schema: A connection to the new DB, for creating schemas and
 169+ * - create-schema: A connection to the new DB, for creating schemas and
170170 * other similar objects in the new DB.
171171 * - create-tables: A connection with a role suitable for creating tables.
172172 *
173 - * @return A Status object. On success, a connection object will be in the
 173+ * @return A Status object. On success, a connection object will be in the
174174 * value member.
175175 */
176176 protected function openPgConnection( $type ) {
177177 switch ( $type ) {
178178 case 'create-db':
179179 return $this->openConnectionToAnyDB(
180 - $this->getVar( '_InstallUser' ),
 180+ $this->getVar( '_InstallUser' ),
181181 $this->getVar( '_InstallPassword' ) );
182182 case 'create-schema':
183 - return $this->openConnectionWithParams(
 183+ return $this->openConnectionWithParams(
184184 $this->getVar( '_InstallUser' ),
185185 $this->getVar( '_InstallPassword' ),
186186 $this->getVar( 'wgDBname' ) );
@@ -236,7 +236,7 @@
237237 $conn = $status->value;
238238 $superuser = $this->getVar( '_InstallUser' );
239239
240 - $row = $conn->selectRow( '"pg_catalog"."pg_roles"', '*',
 240+ $row = $conn->selectRow( '"pg_catalog"."pg_roles"', '*',
241241 array( 'rolname' => $superuser ), __METHOD__ );
242242 return $row;
243243 }
@@ -254,7 +254,7 @@
255255 if ( !$perms ) {
256256 return false;
257257 }
258 - return $perms->rolsuper === 't';
 258+ return $perms->rolsuper === 't';
259259 }
260260
261261 public function getSettingsForm() {
@@ -311,15 +311,15 @@
312312 }
313313
314314 // Existing web account. Test the connection.
315 - $status = $this->openConnectionToAnyDB(
 315+ $status = $this->openConnectionToAnyDB(
316316 $this->getVar( 'wgDBuser' ),
317317 $this->getVar( 'wgDBpassword' ) );
318318 if ( !$status->isOK() ) {
319319 return $status;
320320 }
321321
322 - // The web user is conventionally the table owner in PostgreSQL
323 - // installations. Make sure the install user is able to create
 322+ // The web user is conventionally the table owner in PostgreSQL
 323+ // installations. Make sure the install user is able to create
324324 // objects on behalf of the web user.
325325 if ( $same || $this->canCreateObjectsForWebUser() ) {
326326 return Status::newGood();
@@ -444,14 +444,14 @@
445445 try {
446446 $conn->query( "CREATE SCHEMA $safeschema AUTHORIZATION $safeuser" );
447447 } catch ( DBQueryError $e ) {
448 - return Status::newFatal( 'config-install-pg-schema-failed',
 448+ return Status::newFatal( 'config-install-pg-schema-failed',
449449 $this->getVar( '_InstallUser' ), $schema );
450450 }
451451 }
452452
453453 // If we created a user, alter it now to search the new schema by default
454454 if ( $this->getVar( '_CreateDBAccount' ) ) {
455 - $conn->query( "ALTER ROLE $safeuser SET search_path = $safeschema, public",
 455+ $conn->query( "ALTER ROLE $safeuser SET search_path = $safeschema, public",
456456 __METHOD__ );
457457 }
458458
@@ -487,8 +487,8 @@
488488 // Create the user
489489 try {
490490 $sql = "CREATE ROLE $safeuser NOCREATEDB LOGIN PASSWORD $safepass";
491 -
492 - // If the install user is not a superuser, we need to make the install
 491+
 492+ // If the install user is not a superuser, we need to make the install
493493 // user a member of the new user's group, so that the install user will
494494 // be able to create a schema and other objects on behalf of the new user.
495495 if ( !$this->isSuperUser() ) {
@@ -497,7 +497,7 @@
498498
499499 $conn->query( $sql, __METHOD__ );
500500 } catch ( DBQueryError $e ) {
501 - return Status::newFatal( 'config-install-user-create-failed',
 501+ return Status::newFatal( 'config-install-user-create-failed',
502502 $this->getVar( 'wgDBuser' ), $e->getMessage() );
503503 }
504504 }
@@ -559,7 +559,7 @@
560560 }
561561
562562 public function setupPLpgSQL() {
563 - // Connect as the install user, since it owns the database and so is
 563+ // Connect as the install user, since it owns the database and so is
564564 // the user that needs to run "CREATE LANGAUGE"
565565 $status = $this->getPgConnection( 'create-schema' );
566566 if ( !$status->isOK() ) {
@@ -574,7 +574,7 @@
575575 return Status::newGood();
576576 }
577577
578 - // plpgsql is not installed, but if we have a pg_pltemplate table, we
 578+ // plpgsql is not installed, but if we have a pg_pltemplate table, we
579579 // should be able to create it
580580 $exists = $conn->selectField(
581581 array( '"pg_catalog"."pg_class"', '"pg_catalog"."pg_namespace"' ),
Index: trunk/phase3/includes/installer/WebInstallerPage.php
@@ -766,7 +766,7 @@
767767
768768 // Validate e-mail if provided
769769 $email = $this->getVar( '_AdminEmail' );
770 - if( $email && !User::isValidEmailAddr( $email ) ) {
 770+ if( $email && !Sanitizer::validateEmail( $email ) ) {
771771 $this->parent->showError( 'config-admin-error-bademail' );
772772 $retVal = false;
773773 }
Index: trunk/phase3/includes/media/Generic.php
@@ -161,7 +161,7 @@
162162 * MediaHanlder::METADATA_COMPATIBLE if metadata is old but backwards
163163 * compatible (which may or may not trigger a metadata reload).
164164 */
165 - function isMetadataValid( $image, $metadata ) {
 165+ function isMetadataValid( $image, $metadata ) {
166166 return self::METADATA_GOOD;
167167 }
168168
@@ -210,14 +210,14 @@
211211 function getThumbType( $ext, $mime, $params = null ) {
212212 $magic = MimeMagic::singleton();
213213 if ( !$ext || $magic->isMatchingExtension( $ext, $mime ) === false ) {
214 - // The extension is not valid for this mime type and we do
 214+ // The extension is not valid for this mime type and we do
215215 // recognize the mime type
216216 $extensions = $magic->getExtensionsForType( $mime );
217217 if ( $extensions ) {
218218 return array( strtok( $extensions, ' ' ), $mime );
219219 }
220220 }
221 -
 221+
222222 // The extension is correct (true) or the mime type is unknown to
223223 // MediaWiki (null)
224224 return array( $ext, $mime );
@@ -357,12 +357,12 @@
358358 /**
359359 * This is used to generate an array element for each metadata value
360360 * That array is then used to generate the table of metadata values
361 - * on the image page
 361+ * on the image page
362362 *
363363 * @param &$array Array An array containing elements for each type of visibility
364364 * and each of those elements being an array of metadata items. This function adds
365365 * a value to that array.
366 - * @param $visibility string ('visible' or 'collapsed') if this value is hidden
 366+ * @param $visbility string ('visible' or 'collapsed') if this value is hidden
367367 * by default.
368368 * @param $type String type of metadata tag (currently always 'exif')
369369 * @param $id String the name of the metadata tag (like 'artist' for example).
@@ -381,7 +381,7 @@
382382 $msgName = "$type-$id";
383383 if ( wfEmptyMsg( $msgName ) ) {
384384 // This is for future compatibility when using instant commons.
385 - // So as to not display as ugly a name if a new metadata
 385+ // So as to not display as ugly a name if a new metadata
386386 // property is defined that we don't know about
387387 // (not a major issue since such a property would be collapsed
388388 // by default).
@@ -455,10 +455,10 @@
456456 /**
457457 * File validation hook called on upload.
458458 *
459 - * If the file at the given local path is not valid, or its MIME type does not
 459+ * If the file at the given local path is not valid, or its MIME type does not
460460 * match the handler class, a Status object should be returned containing
461461 * relevant errors.
462 - *
 462+ *
463463 * @param $fileName The local path to the file.
464464 * @return Status object
465465 */
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -206,7 +206,7 @@
207207 }
208208
209209 # Send out an email authentication message if needed
210 - if( $wgEmailAuthentication && User::isValidEmailAddr( $u->getEmail() ) ) {
 210+ if( $wgEmailAuthentication && Sanitizer::validateEmail( $u->getEmail() ) ) {
211211 $status = $u->sendConfirmationMail();
212212 if( $status->isGood() ) {
213213 $wgOut->addWikiMsg( 'confirmemail_oncreate' );
@@ -355,7 +355,7 @@
356356 return false;
357357 }
358358
359 - if( !empty( $this->mEmail ) && !User::isValidEmailAddr( $this->mEmail ) ) {
 359+ if( !empty( $this->mEmail ) && !Sanitizer::validateEmail( $this->mEmail ) ) {
360360 $this->mainLoginForm( wfMsg( 'invalidemailaddress' ) );
361361 return false;
362362 }
@@ -814,12 +814,12 @@
815815 # Run any hooks; display injected HTML
816816 $injected_html = '';
817817 $welcome_creation_msg = 'welcomecreation';
818 -
 818+
819819 wfRunHooks( 'UserLoginComplete', array( &$wgUser, &$injected_html ) );
820 -
 820+
821821 //let any extensions change what message is shown
822822 wfRunHooks( 'BeforeWelcomeCreation', array( &$welcome_creation_msg, &$injected_html ) );
823 -
 823+
824824 $this->displaySuccessfulLogin( $welcome_creation_msg, $injected_html );
825825 }
826826
@@ -833,7 +833,7 @@
834834 if( $msgname ){
835835 $wgOut->addWikiMsg( $msgname, wfEscapeWikiText( $wgUser->getName() ) );
836836 }
837 -
 837+
838838 $wgOut->addHTML( $injected_html );
839839
840840 if ( !empty( $this->mReturnTo ) ) {
@@ -874,7 +874,7 @@
875875 $block_reason,
876876 $block->getBlocker()->getName()
877877 );
878 -
 878+
879879 $wgOut->returnToMain( false );
880880 }
881881
Index: trunk/phase3/includes/specials/SpecialConfirmemail.php
@@ -54,7 +54,7 @@
5555
5656 if( empty( $code ) ) {
5757 if( $wgUser->isLoggedIn() ) {
58 - if( User::isValidEmailAddr( $wgUser->getEmail() ) ) {
 58+ if( Sanitizer::validateEmail( $wgUser->getEmail() ) ) {
5959 $this->showRequestForm();
6060 } else {
6161 $wgOut->addWikiMsg( 'confirmemail_noemail' );
Index: trunk/phase3/includes/Autopromote.php
@@ -29,9 +29,9 @@
3030
3131 /**
3232 * Get the groups for the given user based on the given criteria.
33 - *
 33+ *
3434 * Does not return groups the user already belongs to or has once belonged.
35 - *
 35+ *
3636 * @param $user The user to get the groups for
3737 * @param $event String key in $wgAutopromoteOnce (each one has groups/criteria)
3838 *
@@ -153,7 +153,7 @@
154154
155155 switch( $cond[0] ) {
156156 case APCOND_EMAILCONFIRMED:
157 - if ( User::isValidEmailAddr( $user->getEmail() ) ) {
 157+ if ( Sanitizer::validateEmail( $user->getEmail() ) ) {
158158 if ( $wgEmailAuthentication ) {
159159 return (bool)$user->getEmailAuthenticationTimestamp();
160160 } else {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86364Move User::isValidEmailAddr() to Sanitizer.happy-melon23:16, 18 April 2011

Comments

#Comment by Krinkle (talk | contribs)   20:28, 26 June 2011

ftr, move was done in r86364

Status & tagging log