Similar in nature to http://drupal.org/node/704024...

When I try and revert some features, I get the following:

Parse error: syntax error, unexpected ')' in /home/tom/workspace/concern6/sites/concern.net/modules/contrib/features/features.export.inc(591) : eval()'d code on line 5

Call Stack:
    0.0005     195952   1. {main}() /home/tom/bin/drush/drush.php:0
    0.0090    1971904   2. drush_main() /home/tom/bin/drush/drush.php:41
    0.4638    6114904   3. drush_dispatch() /home/tom/bin/drush/drush.php:91
    0.4640    6118456   4. call_user_func_array() /home/tom/bin/drush/includes/drush.inc:51
    0.4640    6119232   5. drush_command() /home/tom/bin/drush/includes/drush.inc:0
    0.4641    6120792   6. call_user_func_array() /home/tom/bin/drush/includes/command.inc:378
    0.4641    6121152   7. drush_invoke() /home/tom/bin/drush/includes/command.inc:0
    0.4650    6146368   8. call_user_func_array() /home/tom/bin/drush/includes/command.inc:327
    0.4650    6147168   9. drush_core_updatedb_batch_process() /home/tom/bin/drush/includes/command.inc:0
    0.4662    6364000  10. _update_batch_command() /home/tom/bin/drush/commands/core/core.drush.inc:541
    3.1867   80934792  11. drush_batch_command() /home/tom/bin/drush/commands/core/drupal/update_6.inc:472
    3.1875   81002880  12. _drush_batch_command() /home/tom/bin/drush/includes/batch.inc:68
    3.1880   81125488  13. _drush_batch_worker() /home/tom/bin/drush/commands/core/drupal/batch_6.inc:69
    3.9494   82041376  14. call_user_func_array() /home/tom/bin/drush/commands/core/drupal/batch_6.inc:103
    3.9494   82041744  15. _update_do_one() /home/tom/bin/drush/commands/core/drupal/batch_6.inc:0
    3.9494   82044424  16. concern_net_update_6101() /home/tom/bin/drush/commands/core/drupal/update_6.inc:454
   25.0294  141234408  17. update_api_features_revert() /home/tom/workspace/concern6/sites/concern.net/modules/custom/concern_net/concern_net.install:82
   76.7220  203624792  18. features_detect_overrides() /home/tom/workspace/concern6/sites/concern.net/modules/contrib/update_api/contrib/features.inc:75
   76.9152  208321288  19. features_get_component_states() /home/tom/workspace/concern6/sites/concern.net/modules/contrib/features/features.export.inc:279
   76.9381  208345432  20. features_get_signature() /home/tom/workspace/concern6/sites/concern.net/modules/contrib/features/features.export.inc:649
   76.9381  208345960  21. features_get_normal() /home/tom/workspace/concern6/sites/concern.net/modules/contrib/features/features.export.inc:527

Sticking var_dump($code); in features.export.inc at line 591, I can see that this is probably the cause of the problem:

$args = func_get_args();
  $module = array_shift($args);
  $api = array_shift($args);
  if ($module == "" && $api == "") {
    return array("version" => );
  }

I'm not sure where that is coming from though... I can't see that code in my feature anywhere.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mrfelton’s picture

In my feature, What I see is:

/**
 * Helper to implementation of hook_ctools_plugin_api().
 */
function _concern_homepages_ctools_plugin_api() {
  $args = func_get_args();
  $module = array_shift($args);
  $api = array_shift($args);
  if ($module == "strongarm" && $api == "strongarm") {
    return array("version" => 1);
  }
}
mrfelton’s picture

Status: Active » Needs review
FileSize
490 bytes

Ok, think I got it.

Basically I'm using hook_update_n() to install some features and revert them to their default state (The functionality of these features already exists on the site, but I'm 'featurising' them), and in the process of doing so, I'm making some changes to the features. So, I need to install and then revert the features. My hook_hopate looks a little like this (some of these cache clears can probably be removed - they were added as part of debugging this problem).

  module_rebuild_cache();
  drupal_flush_all_caches();
  $modules = array(
    'features',
    'strongarm',
  );
  drupal_install_modules($modules);

  // Install the new features
  $features = array(
    'test_feature',
  );
  features_install_modules($features);
  
  //Revert the features to get them to the default state.
  module_rebuild_cache();
  drupal_flush_all_caches();
  update_api_features_revert($ret, $features);

Now, the problem seems to be that ctools_component_features_revert() calls _ctools_features_get_info(), which isn't including details of the strongarm feature (that provides variable exports). And essentially the reason is that features_get_info() in turn calls ctools_export_get_schemas(), which uses drupal_get_schema() to get details of schemas. However this information is cached, and drupal_flush_all_caches() doesn't clear that cache. The only way I can find to clear the schema cache is to alter ctools_export_get_schemas() so that drupal_get_schema(NULL, TRUE) is called with the second parameter as true. This ensures that when features asks ctools for a list schemas that support exports, the schema cache is refreshed and the new schema alterations made by the strongarm module are picked up, and so updated details of the schema for the variable table (modified by strongarm) are included in the result, which ensures that the erroneous code that is executed in eval():

$args = func_get_args();
  $module = array_shift($args);
  $api = array_shift($args);
  if ($module == "" && $api == "") {
    return array("version" => );
  }

comes out looking like:

$args = func_get_args();
  $module = array_shift($args);
  $api = array_shift($args);
  if ($module == "strongarm" && $api == "strongarm") {
    return array("version" => 1);
  }

Which fixes the error and ensures that the feature can revert properly! :)

So, the fix that I employed was actually in ctools, not features (patch attached). But, maybe you can find a way to invalidate the schema cache from within features instead?

yhahn’s picture

Title: Reverting feature finds and complains about bad evel code » Unclearable static cache in ctools_export_get_schemas()
Project: Features » Chaos Tool Suite (ctools)
Version: 6.x-1.0-beta6 » 6.x-1.x-dev
Status: Needs review » Needs work

I think your patch to CTools export.inc is the right solution but it needs work. Using drupal_get_schema(NULL, TRUE) on every call to ctools_export_get_schemas() is far too aggressive. You should use ctools_static() instead and add a CTools export cache clearing function similar to ctools_export_load_object_reset().

neochief’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs work » Needs review
FileSize
596 bytes

I just came to the same issue in my installation profile, installed from Drush. If you install several features and one of them gets installed before Strongarm (who modifies the schema), you'll loose all of the features with variables exports until you manually revert features on site. This however breaks all the automation.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed and pushed.

Status: Fixed » Closed (fixed)

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