Tim Starling has submitted this change and it was merged.

Change subject: Init the user token before adding users.
......................................................................


Init the user token before adding users.

* The DB column has garbage padding as the default value, which
  was intented to just be "". Since the the insert functions cast
  the value to a string, inserting a user without creating a token
  causes garbage to be inserted. The logic to automatically fix
  empty tokens does not trigger. This fixes createNew() to set the
  token and makes sure that addToDatabase() does.

Change-Id: I3529fe8afbc62bac37063217d5aa0179a4a6e169
---
M includes/User.php
1 file changed, 4 insertions(+), 0 deletions(-)

Approvals:
  Tim Starling: Verified; Looks good to me, approved
  jenkins-bot: Checked



diff --git a/includes/User.php b/includes/User.php
index de34bfc..90cb8c4 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -3114,6 +3114,7 @@
        public static function createNew( $name, $params = array() ) {
                $user = new User;
                $user->load();
+               $user->setToken(); // init token
                if ( isset( $params['options'] ) ) {
                        $user->mOptions = $params['options'] + 
(array)$user->mOptions;
                        unset( $params['options'] );
@@ -3175,6 +3176,9 @@
         */
        public function addToDatabase() {
                $this->load();
+               if ( !$this->mToken ) {
+                       $this->setToken(); // init token
+               }
 
                $this->mTouched = self::newTouchedTimestamp();
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3529fe8afbc62bac37063217d5aa0179a4a6e169
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to