Menu ▾ ▴

#42 timesheet_times not updated on change of user login name

open
nobody
None
5
2012-09-14
2005-09-14
No
  • login as administrator
  • edit a user's account
  • change the username in the field labeled "Login username"
    ---> the user seems to lose all his entered data

  • change the username back to its original value
    ---> the data seems to "magically" reappear

What really happens is that when the user name is
changed, Timesheet forgets to update the attribute
"uid" in table timesheet_times with the new username.
Subsequent queries fail because the relationship
between timesheet_users and timesheet_times is broken.

Suggested solutions:

  • update the attribute "uid" in table timesheet_times
    when the login name changes

or

  • the attribute "uid" in table timesheet_times should
    reference the attribute "uid" in table timesheet_users
    (would be logical, after all the attribute name already
    suggests this relationship)

As to the 2nd solution: I would like to go even further
and suggest that all tables that reference
timesheet_users should use the numeric attribute "uid"
as their foreign key. Currently these are the tables
timesheet_assignments, timesheet_task_assignments and
timesheet_times. This would have the advantages

  • database takes up less space because a numeric ID is
    almost always shorter than a string user name

  • PHP code becomes simpler because no update is
    required in referencing tables when the user data changes

Discussion

  • ivan_nz

    ivan_nz - 2005-10-06

    Logged In: YES
    user_id=1330385

    I have noticed this problem as well. Has anyone started on
    the mods needed?

     
  • ivan_nz

    ivan_nz - 2005-10-06

    Logged In: YES
    user_id=1330385

    Quick and ugly fix, but I agree that the uid should be the key
    for all tables.

    //update the assignments
    dbQuery("UPDATE
    $ASSIGNMENTS_TABLE SET username='$username'
    WHERE username='$data[username]'");
    dbQuery("UPDATE
    $TASK_ASSIGNMENTS_TABLE SET username='$username'
    WHERE username='$data[username]'");
    dbQuery("UPDATE
    $PROJECT_TABLE SET proj_leader='$username' WHERE
    proj_leader='$data[username]'");

    //mod by ivan_nz 07-10-05
    dbQuery("UPDATE
    $TIMES_TABLE SET uid='$username' WHERE uid='$data
    [username]'");

     
  • ivan_nz

    ivan_nz - 2005-10-06

    Logged In: YES
    user_id=1330385

    oops changes made to user_action.php

     

Log in to post a comment.