From: ASchulz Date: Wed, 27 Feb 2013 00:17:58 +0000 (-0800) Subject: Init the user token before adding users. X-Git-Tag: 1.31.0-rc.0~20543 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=873970eda91251d5793a42f930d180e72cc84ad9;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/User.php b/includes/User.php index de34bfcbb0..90cb8c485c 100644 --- a/includes/User.php +++ b/includes/User.php @@ -3114,6 +3114,7 @@ class User { 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 @@ class User { */ public function addToDatabase() { $this->load(); + if ( !$this->mToken ) { + $this->setToken(); // init token + } $this->mTouched = self::newTouchedTimestamp();