Received the following error when submitting profile_role_restrict_form.

user warning: Duplicate entry '0-ubercart' for key 'PRIMARY' query: INSERT INTO profile_role VALUES (0, 'ubercart') in /var/www/self/shm/sites/all/modules/profile_role/profile_role.module on line 160.

This results in all role selections being unchecked (not saved) and anonymous role selected...
The attached patch fixes the list below.

  1. module is trying to insert rid = 0 for each 'off' checkbox, this creates duplicate entries... also there is no rid = 0. profile_role_restrict_form_submit does not filter the results from the form checkboxes
    patch: applies array_filter() to remove any 0 values
  2. with rid = 0, why was anonymous (rid = 1) selected? That problem is in profile_role_get_roles. profile_role_get_roles returns an array of rids per category indexed at 0, and profile_role_restrict_form uses this return to set the default values for the role selection. Role selection #options are user_roles() which indexes on rid...
    patch: match up indexes by indexing with rid in profile_role_get_roles
CommentFileSizeAuthor
#1 profile_role-form-submit-error.patch1.08 KBrecrit

Comments

recrit’s picture

StatusFileSize
new1.08 KB

ok this has to be something with firefox or drupal... when submitting a patch it drops the file. The original file must exist in /files since re-posting it adds "_0"...
anyways, here it is again