It seems that I can export all of my apachesolr settings into a feature module without issue but when enabling or reverting the feature module the apachesolr_environment and apachesolr_environment_variables tables (at least) aren't properly populated with settings. The feature module appears to have export my settings into code but it doesn't result in the data being brought back in. Is this an issue with apachesolr or the features module and what is the recommended way to transfer settings between dev/staging/production?

Comments

ruedu’s picture

I also get this error in the web admin when trying to revert the feature

Notice: Trying to get property of non-object in ctools_component_features_revert() (line 211 of /Users//Sites//public_html/sites/all/modules/contrib/features/includes/features.ctools.inc).

alanmackenzie’s picture

Assigned: Unassigned » alanmackenzie
Status: Active » Needs review
StatusFileSize
new595 bytes

ctools_export_crud_load() called by ctools_component_features_revert() expects the callback supplied by the apachesolr module (apachesolr_environment_load(), see apachesolr.install line 110) to return a ctools object, instead it currently returns an array.

However tools_export_crud_load() will default to fetching a ctools object itself if no callback exists, so the fix is to remove the callback to apachesolr's broken function.

Attached (2 line :)) patch does this, you'll need to clear your cache after applying the patch before it will take effect.

The reader should note that the option of which solr environment configuration is the default is controlled by the persistent variable 'apachesolr_default_environment' and isn't included in the ctools export, though it could be with a little more work. I'll leave the decision of whether this is a bug or not up to the committers but if it is then I'm happy to fix it.

For clarity:

function ctools_export_crud_load($table, $name) {
  $schema = ctools_export_get_schema($table);
  $export = $schema['export'];

  if (!empty($export['load callback']) && function_exists($export['load callback'])) {
    return $export['load callback']($name);
  }
  else {
    $result = ctools_export_load_object($table, 'names', array($name));
    if (isset($result[$name])) {
      return $result[$name];
    }
  }
}
pwolanin’s picture

Is that going to work? It might be missing the 'conf' information that is joined in from a separate table.

scor’s picture

haven't had enough time to dive into the code causing this issue, but just want to report at least that this patch solved the issue for me: as soon as I applied it and cleared the caches, I was finally able to revert the apachesolr_environment component, which would not revert before.

nick_vh’s picture

I think we can assume the issue reporter is correct. Since we don't support the load all and load multiple callback, we should probably also not code our own load single callback if it does not return the proper respons.
The normal export function is defined correctly as "function apachesolr_ctools_environment_export($environment, $indent) {"

I'm going ahead and commit this patch and let this bake a bit. If this is problematic, we can easily add it back

nick_vh’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)

committed to D7

killua99’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new785 bytes

Ported

nick_vh’s picture

Status: Needs review » Needs work

you have a newline problem in the patch :)

killua99’s picture

The original file don't have a empty line. My IDE add this new line at EOF can this be the problem?

scor’s picture

Status: Needs work » Needs review

@Nick_vh his patch is actually fixing a problem in the current version of apachesolr.install! The red newline would be at the very bottom of the patch if it was a problem with the patch.

nick_vh’s picture

ah, good to know :)

I'll do another commit spree for 6.x-3.x very soonish

killua99’s picture

Good to ear that :)

nick_vh’s picture

Committed! Thanks all that helped!

nick_vh’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

Nick Robillard’s picture

Version: 6.x-3.x-dev » 7.x-1.x-dev
Issue summary: View changes
StatusFileSize
new1.96 KB

I'm honestly a bit confused by this thread. In 7.x-1.6 (as well as 7.x-1.6+3-dev), I've observed feature reverting/importing NOT restoring any settings inside $environment->conf. (apachesolr_search_sticky_boost, apachesolr_search_promote_boost, apachesolr_search_date_boost, apachesolr_search_comment_boost, apachesolr_search_changed_boost, apachesolr_search_type_boosts, field_bias)

I've found that adding a "load callback" to the ctools export block and doing an apachesolr_environment_variable_set() on each of the $environment->conf values fixes this. I've attached a patch against 7.x-1.6+3-dev. This patch makes feature reverting work as expected.

Ok scratch that. Ignore this patch. Using the "load callback" still didn't address the problem of feature reverting never reverting settings inside "conf". And I found that the variable sets were not needed there at all.

I've simplified my approach by adding back hook_features_revert() and inside that, deleting the environment manually, so that "conf" gets reverted. Patch below.

Nick Robillard’s picture

Status: Closed (fixed) » Needs work
StatusFileSize
new1.19 KB

This patch solves the problem where conf settings are never reverted via Features revert. I've added back hook_features_revert (same one that was there before) that deletes the environment. This may be a bit brute force and I suspect there is be a better way to handle this. But this seems to do the job.

nick_vh’s picture

Status: Needs work » Closed (duplicate)

Forgive me if I'm wrong but I think #1439564: Index bundles Export/Import and #1984502: Don't include time dependent configuration and state in ctools exports already tackle this. I'm closing this until you can show me why this is needed on top of those two patches.

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.