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');
// ...
}
Comment | File | Size | Author |
---|---|---|---|
#8 | storage_type-1196432-8.patch | 629 bytes | langworthy |
mongodb-dont-set-default-storage.patch | 1.21 KB | dixon_ | |
Comments
Comment #2
dixon_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.
Comment #3
langworthy CreditAttribution: langworthy commentedI'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.
Comment #4
chx CreditAttribution: chx commentedThis is a bug report I am gladly accepting patches for. Removing hook_install is not something I am going to consider, sorry.
Comment #5
phayes CreditAttribution: phayes commentedI've found that putting the following in my install profile seems to fix it:
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.
Comment #6
langworthy CreditAttribution: langworthy commentedWhere in the install profile did you put that code? I tried in the .install file hook_install() but I received the same error?
Comment #7
phayes CreditAttribution: phayes commentedI 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.
Comment #8
langworthy CreditAttribution: langworthy commentedI 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
Comment #9
chx CreditAttribution: chx commentedThat makes sense.
Comment #10
chx CreditAttribution: chx commentedI mean, committed, thanks :)