When working with a installation profile workflow, or building a distribution it's impossible to control the default field storage. At least in a sane way :)

If one do like this in settings.php...

  $conf['field_storage_default'] = 'field_sql_storage';

...it will be overwritten when the profile is installed. It will be overwritten in mongodb_field_storage_install(). Any fields defined in the install profile (or in Features modules) after that will get mongodb_field_storage as the field storage. And that might not always be what you want.

So I suggest that we let it be up to the user to decide what should be default storage. That sounds better to me at least :)

Attached is a patch that fixes this, and also adds a note in README.txt on how this is configured. The tests should not need an update since they already have:

  function setUp() {
    parent::setUp(array('mongodb', 'mongodb_field_storage', 'field_test'));
    variable_set('field_storage_default', 'mongodb_field_storage');
    // ...
  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, mongodb-dont-set-default-storage.patch, failed testing.

dixon_’s picture

Status: Needs work » Active

I'm not sure why the tests are failing. To me it seems like the tests should not need an update due to the changes in this patch. But I might be wrong?

I will look some more into this.

langworthy’s picture

I'm following the current instructions in the README which say to add the following to settings.php $conf['field_storage_default'] = 'mongodb_field_storage';. This is similar to what the patch above uses.

When installing a new custom profile that includes mongodb_field_storage.module I get the following error.

WD php: FieldException: Attempt to create a field with unknown storage type mongodb_field_storage. in field_create_field() (line 126 of                          [error]
.../modules/field/field.crud.inc).
chx’s picture

Title: Don't set 'field_storage_default' upon installation » unknown storage type when used in an install profile
Category: feature » bug

This is a bug report I am gladly accepting patches for. Removing hook_install is not something I am going to consider, sorry.

phayes’s picture

I've found that putting the following in my install profile seems to fix it:

module_enable(array('mongodb_field_storage'));
drupal_flush_all_caches();

The flush-all-caches seems to fix the problem. Note that the above needs to be run before enabling any feature modules or other modules that create fields.

langworthy’s picture

Where in the install profile did you put that code? I tried in the .install file hook_install() but I received the same error?

phayes’s picture

I made a task for it in hook_profile_install_tasks. So basically, instead of enabling modules for the profile in the .info file, I enable them using an install task.

langworthy’s picture

Status: Active » Needs review
FileSize
629 bytes

I found it easier to include the code from #5 in hook_install as long as I didn't enable the module in the .info and removed the relevant $conf variable from settings.php

chx’s picture

Status: Needs review » Reviewed & tested by the community

That makes sense.

chx’s picture

Status: Reviewed & tested by the community » Fixed

I mean, committed, thanks :)

Status: Fixed » Closed (fixed)

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