Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-6798

acl_set_role inserting nonsense after acl_add_option

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 3.0.1
    • 3.0.0
    • Authentication
    • None
    • PHP Environment: 5.1.1
      Database: Mysql 5.0.18

      If acl_set_role is used to populate a roles settings after acl_add_option has been used to add the rights inserted into that role, the SQL Statements generated are similar to this:

      INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) VALUES (24, 0, 0)

      As it can be seen, the auth_option_id is wrong, if you are setting more than one right and you are setting it to ACL_YES, auth_admin will try to insert more than one row at a time with the exact same Values:
      (25, 0, 1), (25, 0, 1) ... which of course leads to an error "Duplicate Entry...".

      This error is the result of acl_add_option not updating the auth_admin Objects option_ids attribute adding the new options, so that acl_set_role is not able to access the new options and therefore inserting 0 for the auth_option_id.
      It should be possible to resolve this problem by simply updating the auth class with a call to the constructor at the very end of acl_add_option after deleting the options attribute which will reinitialize the attribute with all values:

      Find:

      $db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary);
       
      		$cache->destroy('_acl_options');
      		$this->acl_clear_prefetch();

      After add:

      $this->option_ids = array();
      $this->auth_admin();

            Acyd Burn Meik Sievertsen [X] (Inactive)
            gn#36 gn#36 [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: