Chad has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/148916

Change subject: Further User define cleanups
......................................................................

Further User define cleanups

- Token length unused outside of class, so removed from global scope and
  name shortened
- Use class constant for edit token suffix instead of global
- EDIT_TOKEN_SUFFIX still used in a number of extensions so it will remain

Change-Id: Id10a15e8e17e96390a6d64d7ec776af85a73960a
---
M includes/User.php
1 file changed, 9 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/16/148916/1

diff --git a/includes/User.php b/includes/User.php
index b170707..5b18334 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -21,12 +21,6 @@
  */
 
 /**
- * Int Number of characters in user_token field.
- * @ingroup Constants
- */
-define( 'USER_TOKEN_LENGTH', 32 );
-
-/**
  * String Some punctuation to prevent editing from broken text-mangling 
proxies.
  * @ingroup Constants
  */
@@ -52,10 +46,14 @@
  */
 class User implements IDBAccessObject {
        /**
-        * Global constants made accessible as class constants so that 
autoloader
+        * @const int Number of characters in user_token field.
+        */
+       const TOKEN_LENGTH = 32;
+
+       /**
+        * Global constant made accessible as class constants so that autoloader
         * magic can be used.
         */
-       const USER_TOKEN_LENGTH = USER_TOKEN_LENGTH;
        const EDIT_TOKEN_SUFFIX = EDIT_TOKEN_SUFFIX;
 
        /**
@@ -2301,7 +2299,7 @@
        public function setToken( $token = false ) {
                $this->load();
                if ( !$token ) {
-                       $this->mToken = MWCryptRand::generateHex( 
USER_TOKEN_LENGTH );
+                       $this->mToken = MWCryptRand::generateHex( 
self::TOKEN_LENGTH );
                } else {
                        $this->mToken = $token;
                }
@@ -3804,7 +3802,7 @@
                }
 
                if ( $this->isAnon() ) {
-                       return EDIT_TOKEN_SUFFIX;
+                       return self::EDIT_TOKEN_SUFFIX;
                } else {
                        $token = $request->getSessionData( 'wsEditToken' );
                        if ( $token === null ) {
@@ -3814,7 +3812,7 @@
                        if ( is_array( $salt ) ) {
                                $salt = implode( '|', $salt );
                        }
-                       return md5( $token . $salt ) . EDIT_TOKEN_SUFFIX;
+                       return md5( $token . $salt ) . self::EDIT_TOKEN_SUFFIX;
                }
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/148916
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id10a15e8e17e96390a6d64d7ec776af85a73960a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Chad <ch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to