When importing more than one feature at a time (for example, using drush or features_install_modules()), the node types database might become out of date due to its use of static caching, causing node permissions ("Create $type content", etc.) failing to import. This can be remedied by flushing the node types database before trying to import user permissions.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

smk-ka’s picture

Status: Active » Needs review
FileSize
750 bytes
febbraro’s picture

Assigned: Unassigned » febbraro
recidive’s picture

#1265168: Rebuild the file list properly when a feature is enabled or disabled has more information than this one. This problem affects all entities, not just nodes, and it's related to a module adding a permission that has to do with an entity instantiated in other module.

recidive’s picture

Priority: Normal » Major

Hey guys, can we do a sprint to get this fixed. I'm stuck on this issue for 3 weeks now. Need to get this sorted out in order to move my install profile forward.

febbraro’s picture

Does the patch in #1 fix it for you?

febbraro’s picture

Also, the best way to get this fixed in your time frame is to debug it and fix it and post a patch which we can review and commit. Also, with your patch, if you can provide more detail so that folks can have a specific test case and a patch to verify.

recidive’s picture

@febbraro, no patch in #1 doesn't fix the problem.

I'm debugging this for 3 weeks now, have tried changing things in a myriad of ways. I'm looking forward to have a patch to send. But can't find where the problem is. I'm sure it's related to installing using drush si/aegir, since the problem doesn't occur when using the installer (install.php).

I'm looking for some guidance from Features experts so I can look for the problem in the correct place.

I'm pretty sure this issue is the same as in #1063204: Adding a new permission causes integrity constraint violation. I'll try latest dev code now that #1195432: Use dependency information when importing got committed.

recidive’s picture

smk-ka’s picture

Assigned: Unassigned » febbraro
Status: Fixed » Needs review

#1195432: Use dependency information when importing shouldn't be related, as it only helps with dependencies on module level (i.e., those in .info files). What you are describing sounds more like a dependency issue related to feature *components*, i.e. to my knowledge there isn't a way to tell features to first import the taxonomy vocabularies, which are required later down the pipeline when importing user permissions. You could try adding echo 1; at the top of taxonomy_features_rebuild() function, and echo 2; at the top of user_permission_features_rebuild() to see in which order they're actually executed. This would help to find out whether it's an execution order issue, or a caching issue.

And yes, we need to be able to reproduce this issue. From the various issues at hand (esp. #1265168-1: Rebuild the file list properly when a feature is enabled or disabled) it seems like we have to

  1. create a vocabulary
  2. setup some permissions
  3. export both to a feature
  4. add the feature as a dependency to Drupal's "minimal" install profile
  5. install using drush si features_debug --uri=http://default --db-url=mysql://user:pass@localhost/dbname
recidive’s picture

@smk-ka: thanks! Yes, I'm going to create an install profile to help reproduce the problem.

recidive’s picture

FileSize
2.9 KB

Ok, I've created an install profile, starting from a copy of minimal, to help reproduce the problem.

I added a feature module that creates an user role a taxonomy vocabulary and set permissions for administrating, adding and deleting terms to the vocabulary.

Here are the errors that occur when installing a new site using this profile:

Starting Drupal installation. This takes a few seconds ...                                          [ok]
Missing argument 1 for features_enable() features.module:817                                        [warning]
array_keys() expects parameter 1 to be array, null given features.module:819                        [warning]
Invalid argument supplied for foreach() features.module:775                                         [warning]
WD php: 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] => delete terms in 1
    [:db_insert_placeholder_2] => 
)
 in user_role_grant_permissions() (line 3028 of
/Users/henrique/Webroot/drupal7/modules/user/user.module).
Cannot modify header information - headers already sent by (output started at                       [warning]
/Users/henrique/drush/includes/drush.inc:917) bootstrap.inc:1207
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'module' cannot 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] => delete terms in 1
    [:db_insert_placeholder_2] => 
)
 in user_role_grant_permissions() (line 3028 of /Users/henrique/Webroot/drupal7/modules/user/user.module).
Drush command terminated abnormally due to an unrecoverable error.                                  [error]

Note: the Missing argument 1 for features_enable() error was introduced in latest commits made in Features module, this was not happening few weeks ago.

To reproduce the issue:

  1. Extract the install profile to the /profiles folder of a Drupal 7 core codebase
  2. Add latest Features module to sites/all/modules or profiles/features_debug/modules
  3. Install the site using drush si features_debug --db-url=mysql://root:pass@localhost:port/dbname
recidive’s picture

Confirmed, installing through install.php installer works fine.

febbraro’s picture

The difference b/w a drush si and install.php is that install.php uses the batch api for the modules installs so it must be a cache thing I'm thinking....

recidive’s picture

@febbraro: makes sense. Is there anything I can try?

Since the issue is assigned to yourself, can I assume you're looking at fixing this problem?

Thanks!

febbraro’s picture

Assigned: febbraro » Unassigned
febbraro’s picture

I just ran through your install profile exactly as you detailed in #11 and everything installed cleanly without errors.

febbraro’s picture

FileSize
1.86 KB

@recidive I ran through and think I reliably reproduced your error. Can you try the attached patch and let me know if this fixes your problem?

febbraro’s picture

@smk-ka: committed your patch in #1 to 7.x branch. http://drupalcode.org/project/features.git/commit/b82b16d

febbraro’s picture

Status: Needs review » Fixed

Also committed patch in #17 as it was a regression from an earlier patch.

Going to close this and move recidive's problem to another issue.

attiks’s picture

FYI I just tested with latest dev version with recidive's test module in #11 and it's working, also backlinking to #1265168: Rebuild the file list properly when a feature is enabled or disabled

smk-ka’s picture

Assigned: febbraro » Unassigned
FileSize
1.37 KB

Hm, I had to clear the static caches altogether to be able to install cleanly. Attached patch is IMO the most robust solution. And thanks for the install profile, @febbraro!

febbraro’s picture

@smk-ka you had to remove all static caches to install the profile from #11 cleanly? I did not have to do that for a clean install.

@recidive, does this patch help you with your other profile problem?

recidive’s picture

@attiks: thanks, I forgot to say that was working in my comment.

@smk-ka: I tested your patch in #21, and the MartPlug install completes but with some warnings and I get a broken install with errors and missing stuff. Any clues?

$ drush si martplug
You are about to DROP your 'martplug_beta_test11' database and then CREATE a new one. Do you want to continue? (y/n): y
Starting Drupal installation. This takes a few seconds ...                                          [ok]
WD theme: Theme key "link_formatter_link_default" not found.                                        [warning]
WD theme: Theme key "image_formatter" not found.                                                    [warning]
WD theme: Theme key "link_formatter_link_default" not found.                                        [warning]
WD theme: Theme key "image_formatter" not found.                                                    [warning]
WD theme: Theme key "link_formatter_link_default" not found.                                        [warning]
WD theme: Theme key "image_formatter" not found.                                                    [warning]
WD theme: Theme key "image_formatter" not found.                                                    [warning]
WD theme: Theme key "image_formatter" not found.                                                    [warning]
WD theme: Theme key "image_formatter" not found.                                                    [warning]
A Display Suite code text format has been created.                                                  [status]
smk-ka’s picture

@febbraro Yes, without clearing all static caches, drush outputs the following notices (may need to use verbose output – -v option):

Undefined index: delete terms in 1 features.user.inc:88                 [notice]
Undefined index: edit terms in 1 features.user.inc:88                   [notice]

@recidive I know those errors from my own features, but wouldn't say they're related to this one, so better create a new issue.

recidive’s picture

Status: Needs review » Needs work

@smk-ka: I wonder if we should move this issue to drush queue, It looks like we are trying to do something impossible here.

mrfelton’s picture

mrfelton’s picture

FileSize
1.34 KB

Patch from #21 is the only things that gets things (semi) working for me at the moment. This version (which is exactly the same) applies cleanly against 7.x-1.x using drush make.

smk-ka’s picture

Just a heads-up: while this patch fixes the node permissions import, it introduces a new bug, which results in the features admin UI to appear unstyled (or at least with some styles missing). This happens due to calling drupal_static_reset() without argument clearing out all statically cached CSS files that have been added on the page so far. However, I wasn't able to find the static caches that actually need to be cleared, therefore I can't offer a better solution ATM.

mrfelton’s picture

@smk-ka - I can confirm that. My Features UI page, as well as /admin/modules are completely unthemed.

neochief’s picture

Status: Needs work » Closed (duplicate)

I'm marking this as duplicate in favor of #1265168: Rebuild the file list properly when a feature is enabled or disabled (patch in #20)

Please reopen this issue if that patch doesn't solve issue for you.

agalitsyn’s picture

Confirmed #28. Patch from #27 brokes features page in BO.
delete drupal_static_reset() from function user_permission_features_export_render

drewish’s picture

drewish’s picture