I installed Permissions_API and Secure_Permissions, build the permissions I needed, went to the Secure Permissions Export page only to find that all of the permissions had been erased. Luckily I had a backup on another server of the {roles} and {permissions} tables so I could recover the data, but it clearly should not have erased everything.

Comments

damienmckenna’s picture

The problem appears to be secure_permissions_build_roles() which is called at the start of secure_permissions_export(). This function goes through all of the roles and deletes any of them that are not loaded through the hooks. If this is the case, how are you supposed to export anything - It just deletes everything before you try to export anything?

damienmckenna’s picture

I think the key confusion stems from the difference between using the 'secure_permissions_active' variable versus the 'secure_permissions_disable_forms' variable. It is definitely not clear that when 'secure_permissions_disable_forms'=FALSE (i.e. the "Disable permissions and roles forms" checkbox is unchecked), when you go to export that it'll only export what already has been exported. At the very least there needs to be warnings in place to inform the admin that the module needs to be made inactive first, or better yet change the module's workflow so that it does NOT purge the role and permissions tables of any roles not previously exported.

damienmckenna’s picture

Status: Active » Patch (to be ported)
StatusFileSize
new917 bytes

Here's a patch that stops the permissions from being rebuilt if secure_permissions_disable_forms==FALSE.

damienmckenna’s picture

Status: Patch (to be ported) » Needs review
agentrickard’s picture

Status: Needs review » Needs work

Looking at this after a while away, I'm not sure why we run secure_permissions_rebuild() at the top of the export function anyway. I think the assumption was that you were ready to export and had configured things properly. But that's a dumb assumption.

I don't think that function is the proper place for the kill check you're adding. We should either remove the secure_permissions_rebuild() or wrap it in a check:

/**
 * Page callback to generate roles and permissions in code.
 */
function secure_permissions_export(&$form_state) {
  // Rebuild the permissions, if necessary.
  $check = module_implements('hook_secure_permissions');
  if (!empty($check)) {
    secure_permissions_rebuild();
  }
agentrickard’s picture

StatusFileSize
new11.15 KB

The proposed patch, but we might (as I said) just remove the rebuild.

agentrickard’s picture

Status: Needs review » Needs work

Crap, I've got a CVS issue. Ignore that patch.

agentrickard’s picture

Status: Needs work » Needs review
StatusFileSize
new11.15 KB

OK. Better.

agentrickard’s picture

Status: Needs work » Fixed

I simply removed the rebuild call.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.