Bug #164

Adding a new user fails with SQL error.

Added by Oscar Bajner over 2 years ago. Updated over 2 years ago.

Status:Closed Start:08/08/2009
Priority:Normal Due date:
Assigned to:Jeremy Bush % Done:

100%

Category:User Accounts
Target version:0.7.3
Resolution:fixed

Description

Reproduce: Select settings, add user, with only Login privilege selected.

Error message:

There was an SQL error: Incorrect integer value: '' for column 'id' at row 1 - INSERT INTO `AI_users` (`id`, `username`, `first_name`, `last_name`, `password`, `email`, `last_login`, `logins`) VALUES ('', 'boozer', 'Boo', 'Zer', '88abf00e3436d043378e16303c056277b8924f39a3d8458b47', '', 0, 0)

./htdocs/argentumsvn/system/libraries/drivers/Database/Mysql.php [392]:

Setup: Windows Vista, Apache 2.2.6, PHP 5.2.6, MySQL 5.1.0, argentum svn trunk

Proposed solution: Patch attached. (patch05.diff)
In ./models/user.php the user id is initialised as null.
However, in ./controllers/admin/user.php at line 41 when the
call to user->save() is made the user-id var is not set.

If the variable is explicitly assigned (line 37+) then it works, ie:
$user->id = NULL;

Perhaps the set_fields does not actually set the user id value?

patch05.diff (331 Bytes) Oscar Bajner, 08/08/2009 11:50 am

Associated revisions

Revision 265
Added by Jeremy Bush over 2 years ago

Fixing #164.

History

Updated by Jeremy Bush over 2 years ago

This is odd, I had this problem before, but setting the ID field in the model to NULL (as it is now) seemed to fix it. The odd thing is that the mode id should already be set to null from the new model creation...

Updated by Jeremy Bush over 2 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Applied in changeset r264.

Updated by Jeremy Bush over 2 years ago

  • Resolution set to fixed

The view actually had an empty ID in it, which was converting it to a string with $_POST.

Also available in: Atom PDF