See #773828: Upgrade of disabled modules fails for the background and more details of the bug - it's because it calls user_role_grant_permissions() which does not work on a disabled module's permissions.

Options to fix this include:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

I think that using direct DB queries was the norm before (given no API function to do this), so now that we have the API function, it is probably better to make it work compared to going back to the dark ages :) Looks like a bad maze of issues around this though. Tricky problem.

chx’s picture

Status: Active » Needs review
FileSize
1.21 KB
JacobSingh’s picture

Status: Needs review » Reviewed & tested by the community

I haven't tested that this actually resolves the issue, but the code should do what it is intended to do.

Perhaps another approach is to refactor user_role_grant_permissions() so that one could grant a single permission and provide all the variables.

function user_role_grant_permission(int $rid, string $permission, string $module) {
  // run the db_merge here.
}

This would allow update functions to just run on their own, decoupling the module loading piece.

But if we're not doing that, this seems fine.

-J

chx’s picture

now that we have the API function, it is probably better to make it work

so i'd rather not add a separate func

JacobSingh’s picture

If the API function isn't sufficiently decoupled to perform the tasks it is intended for, then adding a new function is just improving the job the API is doing. It's not stepping around it or changing it's behavior.

I already RTBC'd the patch which loads all the module files. This is an okay approach and means that function will always work as advertised. The downside is that it will have to load every module file. AFAIK, we don't load module files for disabled modules, so this is potentially an issue for performance and if a disabled module has runtime code in it or other issues (which is why it was disabled).

Either way is really fine with me, but here is a patch which provides an alternative means of solving the same problem by decoupling the API.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 794184_user_role_grant_permission.patch, failed testing.

JacobSingh’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
1.56 KB

Sorry, posted that while holding a screaming baby.

This one actually should work should anyone think it is a good idea (not attached personally).

Dries’s picture

About the patch in #7: I don't understand why user_role_grant_permissions() (plural) throws a permission, and why user_role_grant_permission() (singular) doesn't. That seems inconsistent behavior to me. Shouldn't we throw the permission in user_role_grant_permission(), assuming that is what we want to do.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Active

Jacob already moved his patch over to #737816: user_role_grant_permissions() throws PDOException when used with non-existent permissions (e.g. a permission for a disabled/uninstalled module) and there is some discussion of @chx's approach there also. I think it would be better if we left the general API issue/discussion in that issue, where it's already ongoing.

I mainly opened up this issue so we could track the critical contact.module bug itself, and potentially commit a hack to fix it (e.g. just do the direct database query for now) if it winds up being a final blocker for the D6->D7 upgrade path, for example.

catch’s picture

Status: Active » Needs review
FileSize
831 bytes

Direct query. The other issue hasn't been touched for three weeks now.

aspilicious’s picture

#10: 794184-contact.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 794184-contact.patch, failed testing.

aspilicious’s picture

language code has nothing to do with this :s?

retest?

aspilicious’s picture

Status: Needs work » Needs review

#10: 794184-contact.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 794184-contact.patch, failed testing.

catch’s picture

Status: Needs work » Needs review

#10: 794184-contact.patch queued for re-testing.

mr.baileys’s picture

Status: Needs review » Needs work

The only thing missing IMO is an inline comment explaining why user_role_grant_permissions() cannot be used, pointing to #737816: user_role_grant_permissions() throws PDOException when used with non-existent permissions (e.g. a permission for a disabled/uninstalled module) (maybe even in @todo-form?)

Other than that this is RTBC

catch’s picture

Status: Needs work » Needs review
FileSize
1.41 KB

Also removed contact_update_dependencies().

mr.baileys’s picture

Status: Needs review » Reviewed & tested by the community

Applied and reviewed, and agreed that contact_update_dependencies() is obsolete if we're not using user_role_grant_permissions anyway.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 794184-contact-19.patch, failed testing.

aspilicious’s picture

Status: Needs work » Needs review

#19: 794184-contact-19.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 794184-contact-19.patch, failed testing.

catch’s picture

Status: Needs work » Needs review

#19: 794184-contact-19.patch queued for re-testing.

aspilicious’s picture

Status: Needs review » Reviewed & tested by the community

Back to rtbc?

webchick’s picture

Status: Reviewed & tested by the community » Fixed

It sounds like Dries's comments above no longer apply to this latest patch, which just does a merge query directly. The comment explaining why this is seems self-explanatory to me. I agree with comments above that it'd be nice to resolve this with API function calls, but given this is just an update_XXX function, I'm not really that fussed about it, personally. Dries, feel free to revert if you disagree.

Committed to HEAD. Thanks!

Status: Fixed » Closed (fixed)

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

Dave Reid’s picture

Priority: Critical » Major
Status: Closed (fixed) » Active

Actually, we do need the dependencies line, because the {role_permission}.module column doesn't exist until user_update_7006() and causes failures. So I have to re-open this to revert the removal of contact_update_dependencies().

Dave Reid’s picture

Assigned: Unassigned » Dave Reid
David_Rothstein’s picture

Looks like there's already a patch for that at #939562: Update fails on contact #7002, actually?

Dave Reid’s picture

Assigned: Dave Reid » Unassigned
Priority: Major » Critical
Status: Active » Closed (fixed)

Grr for issues not filed under the correct component.