As pwolanin said in #1134610: Features Exportables Ctools Export
Obviously we need a follow-up for import (needs to be optionally available when ctools is enabled)
.
| Comment | File | Size | Author |
|---|---|---|---|
| #26 | 1357588-26.patch | 6.38 KB | nick_vh |
| #19 | 1357588-19.patch | 5.74 KB | pwolanin |
| #14 | 1357588-14-apachesolr-ctools_exportables.patch | 5.76 KB | becw |
| #11 | 1357588-11-apachesolr-ctools_exportables.patch | 5.54 KB | becw |
| #4 | ctools-import-1357588-4.patch | 2.21 KB | Bußmeyer |
Comments
Comment #1
Bußmeyer commentedThe export function comes from ctools and the export array in hook_schema(). So you can export your configuration. But there is no way to (re-)import this configuration.
Possible solution: Do you know this issue? http://drupal.org/node/624018#comment-5278644
Basically it is one file (wysiwyg.features.inc) with some implemented features hooks. Especially the two functions wysiwyg_features_revert($module) and wysiwyg_features_rebuild($module) do the work of importing the wysiwyg configuration via a simple db_merge() and cache clear.
What do you think?
Possible steps:
- Get all defaults: features_get_default('apachesolr_search_page', $module).
- Write/merge array to database: apachesolr_search_page_save($search_page).
- Menu rebuild needed to pick up search path: menu_rebuild().
Comment #2
Bußmeyer commentedI would like to help you and write a patch for this.
Another good starting point could be this post: http://stellapower.net/content/using-chaos-tools-module-create-exportables
What do you think?
Comment #3
nick_vhI'd love to see a patch for this! Please go ahead and try. Together we'll figure it out ;-)
Comment #4
Bußmeyer commentedFirst try. I created a ctools based load and save logic for apachesolr_environments. Do the same for apachesolr_search_page will be the next step.
Comment #5
Bußmeyer commentedComment #6
nick_vhYou're doing great. Let me know when I can start testing :-)
Comment #7
swentel commentedSubscribing, linking from #1386750: Exportables not picked up
I'll come up with another patch which adds the ctools dependency and uses ctools' export ui.
Comment #8
Bußmeyer commentedSwentel, that's great. We should join forces.
I've also been thinking about it. I think we should discuss it. On the one hand, you'll get an administration interface for free. And it'll work and look like many other modules (eg context). That's cool.
On the other hand, there will be a strong dependency between the two modules. It isn't really necessary for the core functionality of the solr module.
Comment #9
nick_vhIf we could make the ctools optional for the apachesolr.module that would be great. I suppose it wouldn't be a big problem for the apachesolr_search module because that is the more visual side of the module. And since this is mostly coupled with facetapi it needs ctools anyway.
So my proposal for dependencies is to check if module exists and, if it does, provide export/import functionality.
Comment #10
swentel commentedIt will be a while before I come up with one - I need to fix other things first in january, so if you want to go further with this patch, feel free to ahead!
Comment #11
becw commentedI think that Apache Solr environment "variables" (
$environment->conf) need to be exported along with the environment, rather than as separate exportables. Additionally, it makes sense to use the Apache Solr module's own CRUD functions rather than relying on CTools exportables CRUD, because it means that environments are always updated the same way, environment variables are maintained, and caches are properly cleared afterwards.Here's a patch that updates environment exportables to include the variables, and implements importing. I've tested this with Features, and the patch doesn't provide a UI for exporting environments other than Features. Also, I suspect that this does not work with previously exported environments/environment variables--which really shouldn't be a big deal, because exports that come from the current implementation can't be diffed or imported.
Comment #12
nick_vhI like that patch! It makes use of the existing functions while adding a bunch of flexibility. Also this reset function was added to the D6 backport so I guess we should make that consistent throughout the whole D6 and D7 branch.
Is there a way that users can test this patch? Export configuration, create a new site and import configuration? Would we be able to make a simpletest for this functionality?
Thanks!
Comment #13
becw commentedThis patch can be tested by using Features to export an Apache Solr environment. There are three things to test:
These should be tested when the feature is installed on the site it was created on, AND when the feature is installed on a site where Apache Solr has not been previously configured.
I'm not sure how to automate this sort of testing in a simpletest--maybe a test module that implements
hook_default_apachesolr_environments(), and checks whether the default environments are present whenapachesolr_load_all_environments()is called? (CTools would be required for this test).Unfortunately, in my testing the feature is immediately reported as "overridden" when it is installed on a fresh site, even though Apache Solr picks up the settings correctly. I'm working on a fix right now.
Comment #14
becw commentedIt looks like the CTools API "default hook" should match the API name. I made this change, but I also reduced the length of the API name--
default_apachesolr_environmentsis fairly long, and Features uses this in a filename.Comment #15
jrbeemanI've reviewed this patch in a couple of different contexts and it appears to work as expected. I generated Features using local Solr configs and verified that these configurations were usable once enabled. I'm receiving a couple of SimpleTest failures, however, so I'm going to queue the latest patch for a re-test.
Comment #16
jrbeeman#14: 1357588-14-apachesolr-ctools_exportables.patch queued for re-testing.
Comment #17
pwolanin commentedThere seems to be some reset cruft in apachesolr_load_all_environments()
Comment #18
pwolanin commentedUsing the ctools bulk exporter I get:
Comment #19
pwolanin commentedComment #20
pwolanin commentedcommitted to 7.x
Comment #21
becw commentedAwesome, thanks!
Comment #22
pwolanin commentedPlease let me know if you see any problems, or if you can explain the failure of the built-in cools exporter. I took a look at the ctools code, but didn't have enough patience to debug.
Comment #23
becw commentedI think that the problem with the built-in ctools exporter was that apachesolr itself only loaded environments from the database, and never from the ctools hooks, and that (before this patch) there were two separate types of exportables for environments and environment variables, instead of exporting all of the relevant configuration in one object. Technically data from two tables can be exported as one object with ctools by adding 'join' information to the hook_schema() 'export' configuration, but IMO it makes more sense to use a consistent load path.
Comment #24
pwolanin commentedSo what I did falls into the "more sense" option?
Comment #25
becw commentedYeah, exactly.
Comment #26
nick_vhCommitted to 6.x-3.x
Comment #27
nick_vh