Good people of the ExpressionEngine,
We have some strange behaviour with members and total_entries in ‘exp_members’. I’ll try to paint the picture or at least what seems to be the issue.
The website has 4 members. 1 with administrator privileges, 3 others with limited permissions (only editing entries, only adding entries).
The website has a couple of Safecracker forms. These forms have the administrator member assigned and guest are allowed posting. As the member_id for guest we have entered the administrator member ID. While I was writing this up it came to my conclusion that this might not be the way to handle things. But still strange things happen.
Anyway;
- When this administrator member is logged in, and someones submits the form, everything is OK and total_entries for this user gets a +1.
- When this administror member is NOT logged in and someone submits the form, the total_entries for this member get reset to 0 and then a +1 (cause the form submission creates a new entry for this user).
We have added the logged_out_member_id=“1” to the safecracker-tag.
Whenever we set the author of the Safecracker-form entry to a non-administrator member, we get a Database-error. This does not happen the first time - cause this first time the total_entries for administrator member get set to 0. But if we then do it again, the error occurs since the DB cannot do a -1 on a 0-value.
This happends on both EE 2.3.1 and 2.4.0.
Are we doing something horribly wrong or could this really be a bug? I hope neither 😉
Database Error:
A Database Error Occurred
Error Number: 1264
Out of range value for column 'total_entries' at row 1
UPDATE `exp_members` SET `total_entries` = total_entries-1 WHERE
`member_id` = '1'
Filename:
D:\ee\website-nl\beheer\codeigniter\system\database\DB_driver.
php
Line Number: 330