I got a request to include entity bundles, to features export when exporting the environment.
| Comment | File | Size | Author |
|---|---|---|---|
| #52 | apachesolr-exportables-fix-1439564-52.patch | 2.59 KB | bforchhammer |
| #26 | solr-index-bundles-export-1439564.patch | 8.29 KB | neochief |
| #24 | solr-index-bundles-export-1439564.patch | 8.63 KB | neochief |
| #22 | index-bundles-export-1439564.patch | 173.33 KB | neochief |
| #17 | 1439564_17.patch | 7.22 KB | dawehner |
Comments
Comment #1
recidive commentedI started a patch, exporting is working, importing by reverting the feature is not.
Comment #2
youssefr commentedIs this going to integrate the Profile2 entity?
Thanks.
-Youssef
Comment #3
nick_vhWell done recidive. Please keep us updated and if possible also provide an export file so we can test this functionality?
It would be even better if there would be simpletests that can test this functionality.
Comment #4
recidive commentedHello guys, have you seen my other patch related to feature export? Please test it if you have the chance.
#1439492: Features importing of search page not working
Thanks!
Comment #5
pwolanin commentedis this a duplicate?
Comment #6
recidive commented@pwolanin duplicate of what?
The fact is that index bundles aren't being exported/imported with features along with environments. The patch in #1 makes it export, but to make this import, some changes need to be made at how index bundles are retrieved.
I wonder why this setting is under the default index tab, rather than in environment settings?
Comment #7
recidive commentedAdding code to make it load the index bundles when the environment is only in the code, e.g. a feature.
Comment #8
recidive commentedHere's an improved patch making it load everything from ctools when this is available, and directly from the database when not. Also added a hook_features_revert() for deleting the index bundles when reverting the feature. It turned out that due to how index_bundles are store, i.e. there are records for only the ones that are stored. It makes it really difficult to differ from when a. admin disable index for all bundles and b. all index bundles are deleted when reverting the features.
Comment #10
recidive commentedI've changed the hook_features_revert() to load index bundles from code to database instead of just deleting them. Changed another thing here and there to make it work.
The patch should be complete now.
Comment #12
recidive commentedTests was failing due to apachesolr_load_all_environments() being called before the 'apachesolr_index_bundles' table is created, causing a SQL error.
I added a check for the existence of the table to work around this problem.
Comment #13
nick_vhWe all love the testbot ;-)
Can't we solve the apachesolr_load_all_environments problem in a deeper stage? As in : Should we modify the module so it does not call this load all environments if the tables do not exists?
Subrecords? Is there a more descriptive name for this? Subrecords seem very confusing for people that will go through the API/function calls
It also seems that we should be able to do this using the main functions? Looks like duplication
Comment #14
nick_vhComment #15
recidive commentedI don't know where it's calling the apachesolr_load_all_environments() before the table is created, but this looks like a very odd design.
Subrecords came from ctools' 'subrecords callback' from export schema properties. I ended up keeping the name, even though we are not setting this in the schema.
Yeah, we probably can move away and use ctools functions, but in order to make this, apachesolr module should depend on it, which I think was originally not accepted.
Comment #16
nick_vhCorrect, we do not want ctools as a dependency since lots of high-end websites still prefer to have maximum control.
However, nothing stops us from moving forward and build ctools integration (as we are doing). There might come a moment where ctools will be accepted globally (Maybe even part of Drupal 8) and then we can utilise those functions natively.
Let's find out where this call comes from. Afaik I don't see a function call before any of the tables are created.
Comment #17
dawehnerRegarding the ctools issue, i think that nearly all people use ctools in d7 and compared to, for example apachesolr, it's actually a small amount of code if you don't use other plugins then /includes/export.inc.
The current patch did't worked for me because of this code:
This overrides the config settings everytime for index_bundles and conf, because either the value from the db is used: which is fine, or array() is used, which isn't fine, because we want to use the default value in the code.
So i added some additional checks:
Regarding the install table problematic: I guess entity_get_info could be called really early, though some backtrace in the if() didn't got fired.
Comment #18
jbehshad commented#12: 1439564.patch queued for re-testing.
Comment #20
nick_vhI think this is a duplicate of #1498490: Menu paths for custom search pages are broken when exported as features - please correct me if I'm wrong.
The only thing that is not exportable right now is the index bundles I think, would you be so kind and open up a new topic for that?
- Nick
Comment #21
neochief commentedWhy not keep this issue just for Index bundles?
I've tested #17 and it works just fine. As for the code, the apachesolr_environment_features_revert() can be removed in favor of converting all exportable solr things (environments, pages) to objects. This will leverage using standard ctools export functions. I can prepare the patch, if maintainer thinks that this can be potentially commited. This will be pretty huge patch, so I need to be sure before proceeding to avoid wasting of time.
Comment #22
neochief commentedRe-roll of #21 agains current dev version.
Also, included a fix of 2 errors:
Items in #21 are still relevant.
Comment #24
neochief commentedAttached wrong file, sorry. This one is good to go.
Comment #26
neochief commentedAnother re-roll.
Comment #27
nick_vh#26: solr-index-bundles-export-1439564.patch queued for re-testing.
Comment #29
jhedstromThe patch in #26 no longer applies cleanly, and downright fails in one part due to some refactoring done in #1519900: Error in apachesolr_index_get_entities_to_index() function (commit c5bd5c7e1f). Here's a reroll that *skips* this code change:
It seems to work w/o this in my local testing.
Comment #30
nick_vhI had a hard time reviewing this code change because there is some code that is being moved and mainly the subrecords function is a bit strange
I came up with a revert link, similar to the search pages revert link but then for the environments
When you revert an environment, it will delete the DB copy it has and use the code. This now also works for the index bundles. Before, if you reverted it did not correctly override the settings you had in the database.
Only missing part now is when you disable all the indexed bundles, it will revert to the code change since disabling all indexed bundles = removing the database entries.
Comment #31
nick_vhcleaner, the features revert hook was not necessary
Comment #32
nick_vhCommitted to 7.x-1.x-dev.
Thanks to all!
Comment #33
nick_vhHuge patch for Apache Solr 6.x-3.x
- Converted all search pages to objects because of caching troubles and ctools troubles in D6
- Fixed the delete link for more like this blocks
- Search pages can be exported/imported/reverted
- Search Environments + Bundles can be exported/imported/reverted
- Fixed solr index tests for drupal 6
Comment #35
nick_vhComment #36
nick_vhComment #37
pwolanin commentedobviously the main thing is consistency - this needs to be applied to 7.x also?
Comment #38
nick_vhCommitted this to 6.x-3.x dev. Closing this one and continuing in #1702526: apachesolr_search_page_load is quirky
Comment #40
sawtell commentedHi Nick,
Can I ask why the features revert hook was removed? (in comment #31 http://drupal.org/node/1439564#comment-6272474).
I have been having trouble with websites whereby the index bundles would export fine (into features) but never revert correctly on each deployment (causing a complete reindex to be necessary on each deploy).
The features revert hook solves the problem.
Comment #41
nick_vhAs this functionality should leverage standard ctools import/export tools and not features hooks. I prefer not to include features hooks in the module.
What is it that breaks? Could we solve it differently?
Comment #42
bleen commentedSorry to resurrect this issue...
I am having the same issue as described in #40. I havent touched my apachesolr settings and I noticed my_search module (created with features 7.x-2.x) is marked as overridden. So I ran this:
running drush fr my_search does nothing...
The GUI confirms these setting and if I fix it in the gui then I can update the feature and all is well, however this happened again a few weeks later. Again I made no changes to these settings.
Comment #43
artematem commentedI'm not sure is this is related but without the features revert hook, on revert the environment delete callback is called but the environment save callback - not. And after feature revert a have empty both apachesolr_environment and apachesolr_environment_variable table. To fix that I had to add 'apachesolr_environment_features_revert' function in my module and save apachesolr environment there. In this case save callback called, as I'm using it in 'apachesolr_environment_features_revert' function and delete callback is not.
Comment #44
bforchhammer commentedI think I'm experiencing the same issue as described in #40, #42, #43.
Here's what I have observed:
I have a feature in code with an apachesolr environment. There are no overrides initially, so the feature is completely in-code, i.e. the database table `apachesolr_environment_variable` is empty.
Now, when I edit e.g. the environment settings, some variable values are stored in the database table (namely
apachesolr_access_always_add_grants, apachesolr_direct_commit, apachesolr_multilingual_index_settings, apachesolr_read_only, apachesolr_soft_commit). Other variables, e.g. for bias configuration (apachesolr_search_changed_boost, apachesolr_search_comment_boost, apachesolr_search_date_boost, apachesolr_search_promote_boost, apachesolr_search_sticky_boost, apachesolr_search_type_boosts, field_bias) are NOT saved in the database table. The same thing happens vice-versa, when I save bias configuration instead.In either case, my feature now appears overridden, and the values which haven't been saved to the database (e.g. bias configuration) appear as "deleted" even though I didn't touch them.
Now, reverting the feature only works if I edited the environment settings before; if I changed the bias settings instead, the feature also appears as overridden but reverting has no effect. I think this is because "saving bias settings" only actually saves respective "environment variables", but does not insert the "environment" itself into the database, which means that ctools cannot find the exported object in the database, and therefore cannot delete it (=revert it back to code).
The problem with reverting index "index_bundles" (as described in #42) most likely has the very same issue.
I can imagine two solutions to this problem:
a) Make ctools exportables work with having "partial objects" in the database. I'm not sure this is a good idea though, because, e.g., I can't imagine how ctools would be able to distinguish between values which were "not imported" versus deleted ones.
b) Make sure that the exported object is fully saved to the database, before trying to make changes to it or any data related to it. In other words: make sure we don't accidentially get "partial objects" in the database.
I have tried to implemented b) in attached patch; luckily ctools keeps track off whether an objects is entirely "in code only" via a respective flag, so we can simply check for that flag and, if it is set, save the complete environment to the database.
I haven't tested the patch extensively yet, but it does seem to fix the problem for me. One thing I'm not sure about is whether
drupal_merge_array_deep()will work properly in all cases, so more testers would be welcome, I guess :-)Comment #45
bforchhammer commentedComment #46
alcroito commentedTested #44 + the patch found at https://drupal.org/node/1984502#comment-8726587, and it seems I can properly export / revert apachesolr features, to deploy them across environments, thanks!
Comment #47
nick_vhThe only remark I have here is that we're copying the same code 3 times. Can someone make a patch that puts this code in a function so we only need to call a function?
Comment #48
bforchhammer commentedSure, here you go. :)
Comment #49
bforchhammer commentedComment #50
nick_vhMissing the @param parameter. Almost!
Comment #51
nick_vhComment #52
bforchhammer commentedRight, should've thought of that. ;-)
Comment #54
nick_vhCommitted. Please close this if this is impossible to backport to 6.x-3.x but due to the possibility I'm setting it to needs backport.
Thanks for your contribution. It's very much appreciated and I hope you continue to contribute to our issue queue. We can use all the help we can get.