2

I am attempting to create a feature to be used in an install profile that exports a vocabulary and the permissions that are associated with the vocabulary. The problem that I am running into is that the vocabulary vid's on my development site do not match the vid's when running an install profile. Features exports the vocabulary and when imported the next available index in the table is used to create the new vocabulary being imported by the feature. Term permissions use the vid, so when you export the permissions with a feature they look something like:

// Exported permission: edit terms in 4.
  $permissions['edit terms in 4'] = array(
    'name' => 'edit terms in 4',
    'roles' => array(),
    'module' => 'taxonomy',
  );

When I run my install profile the vocabulary I exported is imported with vid 1. So when it attempts to add the permissions for vid 4 it throw an integrity constraint error. I could change the features permissions code to align the id's but this does not bode well when I need to release a new feature that uses vocabularies and their permissions on top of an existing site that already has some vocabularies associated with it. I wanted to check here first before submitting an issue with features. Does anyone know a trick on how to get vocabularies and their permissions exported properly with features?

I was originally using features 7.x-1.0-rc2 then attempted to rectify the issue with 7.x-1.0-rc3 as there are a number of threads with similar issues but not quite the same issue as I am having.

1 Answer 1

0

That's not possible in Drupal 7 (and earlier) — permissions are hardcoded to use vocabulary autoincrement IDs, and there's no hook to override them.

This issue proposes switching to using the vocabulary's machine name for permissions in Drupal 8 — please consider reviewing the latest patch on that issue and providing feedback.

3
  • That is what I figured. So I proposed an option for features to do a replacement when exporting and importing to use the machine name. Hopefully it gets some traction so we have a solution for D7.
    – Jepedo
    Jun 21, 2012 at 15:12
  • Looks like it is being back ported to D7. Goods news all around. Thanks for the heads up.
    – Jepedo
    Jun 21, 2012 at 15:47
  • So finnaly what is the solution? Do you have any link?
    – Mika A.
    Mar 1, 2013 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.