Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#2878 Fatal error when creating new user fails

v4.2.4
open
Gerry Kroll
None
5
2011-10-03
2011-09-14
Blaza
No

When creating new user fails useradmin.php still tries to update user settings and returns fatal error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "user_id" violates not-null constraint' in /includes/classes/class_pgv_db.php:835 Stack trace: #0 [internal function]: PDOStatement->execute(Array) #1 /includes/classes/class_pgv_db.php(835): call_user_func_array(Array, Array) #2 /includes/functions/functions_db.php(2759): PGV_DBStatement->__call('execute', Array) #3 /includes/functions/functions_db.php(2759): PGV_DBStatement->execute(Array) #4 /var/www/drzewo-4.2.4/www/useradmin.php(161): set_user_setting(NULL, 'firstname', 'Edie') #5 {main} thrown in /includes/classes/class_pgv_db.php on line 835

useradmin.php:
135 if ($action=='createuser') {
136 if ($user_id=create_user($username, crypt($pass1))) {
137 set_user_setting($user_id, 'reg_timestamp', date('U'));
138 set_user_setting($user_id, 'sessiontime', '0');
139 AddToLog("User ->{$username}<- created");
140 } else {
141 AddToLog("User ->{$username}<- was not created");
142 $user_id=get_user_id($username);
143 }
144 } else {
145 $user_id=get_user_id($username);
146 }
147 // Change password
148 if ($action=='edituser2' && !empty($pass1)) {
149 set_user_password($user_id, crypt($pass1));
150 AddToLog("User ->{$oldusername}<- had password changed");
151 }

When line 136 fails then we get fatal error. This may happen for example when the user_id returned by database already exists. The code should be modified that if we do hit line 141 then lines 147 till 229 will not be executed! A proper error message should be displayed.

Discussion

  • Gerry Kroll
    Gerry Kroll
    2011-10-03

    • assigned_to: nobody --> canajun2eh