Two web artists. One amazing company.

Articles tagged: Caching

Killing pesky caching during migrations and upgrades part 1: drupal_static()

from Michael Prasuhn on September 25, 2012 01:30pm

At the end of a long day of writing and testing some new features for a Drupal site I decided to be a good developer and wrap up my changes in a migration, or update function and get the code out the door. My code looked something like this:

function my_module_update_7001() {

  $plugin_info = _bean_admin_default_plugin();
  $plugin_info['name'] = '';

  $bean_type = new BeanCustom($plugin_info);
  $bean_type->type = 'social_links';
  $bean_type->setLabel(t('Social links'));

  user_role_grant_permissions(1, array('view any social_links bean'));

Seem simple enough, just create a new entity type, and setup permission inside of hook_update_N. It's a piece of cake thanks to many of the new APIs in Drupal 7, right? When I tried this code, I was presented with the following error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'module' cannot be null:    [error]
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] => 1
    [:db_insert_placeholder_1] => view any social_links bean
    [:db_insert_placeholder_2] =>
 in user_role_grant_permissions() (line 3034 of modules/user/user.module).

Huh? How can that module not be enabled, and why doesn't user_role_grant_permission know about this module?

Read more

Subscribe via RSS