Closed (fixed)
Project:
Default config
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 May 2013 at 15:58 UTC
Updated:
11 Nov 2022 at 16:23 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mpotter commentedI'm getting this also. Specifically, the error is:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'module' cannot [error]
be null: INSERT INTO {role_permission} (rid, permission, module) VALUES (:db_insert_placeholder_0,
:db_insert_placeholder_1, :db_insert_placeholder_2); Array
(
[:db_insert_placeholder_0] => 3
[:db_insert_placeholder_1] => use text format panopoly_html_text
[:db_insert_placeholder_2] =>
)
in user_role_grant_permissions() (line 3079 of
/opt/development/mpotter/openatrium-7.x-2.x-dev/modules/user/user.module).
In this case the "use text format panopoly_html_text" permission is being installed by the panopoly_wysiwyg module using defaultconfig. The defaultconfig file looks like this:
// Exported permission: use text format panopoly_html_text.
$permissions['use text format panopoly_html_text'] = array(
'name' => 'use text format panopoly_html_text',
'roles' => array(
'administrator' => 'administrator',
'editor' => 'editor',
),
'module' => 'filter',
);
So we can see that the Module is defined, but somehow isn't making it into the user_role_grant_permissions() callback.
Looking at the code in defaultconfig.module, it's the defaultconfig_component_rebuild($component, $module = FALSE) function that is calling user_role_grant_permissions() at the end (via $component['rebuild callback']) via defaultconfig_component_rebuild_permissions().
The defaultconfig_component_rebuild_permissions() function largely came from Features (user_permission_features_rebuild), but in Features, relevant to the #1975512: Installing user permission feature when module not available crashes build issue, we added a check for an invalid module.
Now, while we could add a similar check for a valid module here, in this case the module in question is the "filter" module, which is properly listed in the dependencies of the profile. So the real question is: why isn't "filter" enabled and available as a valid module.
Note that this error comes up when testing a profile installation using the drush "site-install" command. So my guess is that some cache isn't getting refreshed somewhere so the module list is not updated.
Rather than just patching the error (which would defeat the purpose of defaultconfig actually setting the desired permission), I will explore in more detail to see if there is just a static cache clear needed somewhere. So stay tuned.
Comment #2
mpotter commentedSo here's the core problem:
The user_role_grant_permissions() function in Drupal gets the module name from the user_permission_get_modules() function. The actual "module" key in the feature export is ignored.
The user_permission_get_modules() function gets the array of permissions and modules by invoking hook_permission for enabled modules. In this case, the panopoly_wysiwyg module has not yet been enabled, so it isn't in the list of permissions/modules returned by user_permission_get_modules().
So how did this ever work? Seems like by definition the module using defaultconfig won't be enabled before it tries to add permissions.
Comment #3
hefox commentedmodules are enabled during hook_modules_enabled, which are when defaultconfig works.
However, is it running before or after features, and is the filter panopoly_html_text defined via features or defaultconfig?
Comment #4
mpotter commentedOK, I found the problem. If the same feature includes both the defaultconfig for a filter permission *and* the filter itself, the defaultconfig runs before the filter is created by Features.
Looks like there was already some code to try and handle this:
The problem with this is that filter_features_rebuild doesn't create the filters because the filter feature hasn't been imported yet. Specifically, Features is not including the module.features.filter.inc file that defines the default_hook needed to rebuild the filter.
The patch is simple. It just adds:
just before the filter_features_rebuild. This worked on the Panopoly/OpenAtrium install and no longer gives the error in the original post. I tried various combinations of features_include(TRUE) and clearing caches, but this direct include was the only method that really worked. Seems a bit kludgy, but since defaultconfig was already doing something special for filters I guess it's no worse than what it had before.
Comment #5
mpotter commentedComment #6
mpotter commentedOK, drupal.org, why did that patch not attach? Let's try that again.
Comment #7
lslinnet commentedHave reviewed, tested and commit this. Thanks for the work and thorough walkthrough of the issue.
Comment #9
timaholt commentedI was having this same issue with features with Taxonomy Vocab and permissions for that vocab in defaultconfig. I realized that Features has changed the original function that defaultconfig_component_rebuild_permissions was based on, so I'm including a new patch that updates this function. This patch fixed the issues I was having with defaultconfig and taxonomy permissions.
Comment #10
Anonymous (not verified) commentedApplied the patch in #9, didn't test for what it was intended for but I received warnings on install.
Warning in features rebuild of adapt_core. No module defines permission "access contextual links". [warning]
Warning in features rebuild of adapt_core. No module defines permission "administer blocks". [warning]
Warning in features rebuild of adapt_core. No module defines permission "administer taxonomy".
The permissions are set correctly though.
Comment #11
timaholt commented@samspinoy - those warnings are relevant, are you saying you see those but you also see those exact permissions set correctly in the database? In my testing when I see the errors I don't see the perms set correctly. But this is better than previously when I was getting a PDO exception.
Comment #12
Anonymous (not verified) commentedyes
Comment #13
lsolesen commentedReference #2008186: Panopoly users, default config permissions, and panealizer static cache issue
Comment #14
saltednutThis patch is working primarily except in the case of the drush command
drush drato rebuild everything. Just needs a minor addition to ensure the optional components are not empty whendefaultconfig_rebuild_all();is called.Comment #15
mkhamash commentedConfirm that patch #14 does work .
Comment #16
heathdutton commentedBeen using this in our builds for a long time. #14 works great.
Comment #17
joseph.olstadPatch #14 works for us! Thanks.
Comment #18
lesleyfernandes commentedThis issue was fixed on defaultconfig 7.x-1.0-alpha11:
https://www.drupal.org/project/defaultconfig/releases/7.x-1.0-alpha11
I am marking this issue as fixed.
Comment #19
lesleyfernandes commented