ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Bug? Safecracker form and total_entries for a member gets reset to 0.

January 26, 2012 9:38am

Subscribe [1]
  • #1 / Jan 26, 2012 9:38am

    Trendesign

    1 posts

    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

     

  • #2 / Jan 27, 2012 3:08pm

    Dan Decker

    7338 posts

    Hi Trendesign,

    There are a couple of ways to solve this. First, I would like to state that it could be a potential problem to have the guest user of the SafeCracker for set as the Super Admin account. So, with that in mind, you can:
    1) Create a special member account and grant them access to use the channel and SafeCracer, then use that ID as the guest ID
    2) Require that your users login before posting, the entry would automatically be assigned to them. You can use the member login form to accomplish this. They would not need to login to the Control Panel.

    Let me know if I can help further!

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases