
Fatal error: Call to protected method xPDOObject::_setRaw() from context 'LoginConfirmRegisterController' in /core/component/login/controllers/web/ConfirmRegister.php on line 63
[2015-12-02 21:24:32] (ERROR @ /connectors/index.php) Could not get table class for class: modAccess
[2015-12-02 21:24:32] (ERROR @ /connectors/index.php) Could not get table name for class: modAccess
[2015-12-02 21:24:32] (ERROR @ /connectors/index.php) Error 42000 executing statement:
Array
(
[0] => 42000
[1] => 1064
[2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS `modAccess` WHERE `modAccess`.`principal` = 2' at line 1
)
[2015-12-02 21:24:32] (ERROR @ /connectors/index.php) Could not get table class for class: modAccess
[2015-12-02 21:24:32] (ERROR @ /connectors/index.php) Could not get table name for class: modAccess
[2015-12-02 21:24:32] (ERROR @ /connectors/index.php) Error 42000 executing statement:
Array
(
[0] => 42000
[1] => 1064
[2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS `modAccess` WHERE `modAccess`.`principal` = 3' at line 1
) 61. /* activate user */
62. $this->user->set('active',1);
63. $this->user->_setRaw('cachepwd',''); <= THIS IS THE LINE CAUSING THE TROUBLE.
This question has been answered by multiple community members. See the first response.
$this->user->set('cachepwd','');That call to _setRaw() was added in the latest version of the Login package (and my code editor flags is as a PHP error).
It's actually on line 58 of the /core/component/login/controllers/web/ConfirmRegister.php file.
I think it will solve your problem if you change it to this:
$this->user->set('cachepwd','');
BTW, you might look at the Subscribe extra, which wraps the whole registration process for you and provides some extra options.
if ( (!empty($k)) && in_array($k, array('password', 'cachepwd')) && $this->xpdo->getService('hashing', 'hashing.modHashing')) {I can see why my solution doesn't work. I think the problem is in the set() method of the modUser class file.
I think it needs something like this:
if ( (!empty($k)) && in_array($k, array('password', 'cachepwd')) && $this->xpdo->getService('hashing', 'hashing.modHashing')) {
I don't think there's any reason to create a hash value for an empty password or cachepwd.
/**
* Helper method to empty users cachepwd field.
*
* @access public
* @param integer $userID
* @return void
*/
public function emptyCachePwd($userID) {
$table = $this->modx->getTableName('modUser');
$sql = "UPDATE {$table} SET `cachepwd`='' WHERE id=".$userID;
$stmt = $this->modx->prepare($sql);
$stmt->execute();
}
....
/* activate user */
$this->user->set('active',1);
if (!$this->user->save()) {
$this->modx->log(modX::LOG_LEVEL_ERROR,'[Register] Could not save activated user: '.$this->user->get('username'));
return '';
}
/* Empty the users cachepwd after user object is saved */
$this->login->emptyCachePwd($this->user->get('id'));
....