Everytime I export a context then try to reimport it as is (after deleting the original context) or by changing certain values in the context.

* warning: Invalid argument supplied for foreach() in /var/www/xxxxx/includes/common.inc on line 924.
* warning: strtr() [function.strtr]: The second argument is not an array in /var/www/xxxxx/includes/common.inc on line 941.

Comments

sirkitree’s picture

Version: 6.x-3.0-beta4 » 6.x-3.0-beta5

I'm not getting an error message, but I am getting nothing imported. I've tried in 3.x-dev, beta4 and beta5

Here's a simple export that isn't working:

$context = new stdClass;
  $context->disabled = FALSE; /* Edit this to true to make a default context disabled initially */
  $context->api_version = 3;
  $context->name = 'admins_home';
  $context->description = '';
  $context->tag = 'Home';
  $context->conditions = array(
    'user' => array(
      'values' => array(
        'Chapter Admin' => 'Chapter Admin',
        'Super Admin' => 'Super Admin',
        'TRA Admin' => 'TRA Admin',
      ),
    ),
  );
  $context->reactions = array(
    'block' => array(
      'blocks' => array(
        'user-1' => array(
          'module' => 'user',
          'delta' => 1,
          'region' => 'sidebar_first',
          'weight' => 0,
        ),
      ),
    ),
  );
  $context->condition_mode = 0;

  $translatables['admins_home'] = array(
    t('Home'),
  );
q0rban’s picture

What version of ctools are you using?

sirkitree’s picture

this was with 1.4

thebuckst0p’s picture

I'm having the same issue: multisite installation with 2 databases on the same core and modules, created a feature in the first with a context, tried to enable the feature on the second, and the context won't import. (Also says the feature is overridden, I try drush features-update on it and it removes the context.) Tried to import the context manually and got the errors described above.
CTools 6.x-1.4, Context 6.x-3.0-beta5 (Context and UI enabled, Context Layout not enabled), Features 6.x-3.0-beta4.

thebuckst0p’s picture

StatusFileSize
new539 bytes

The common.inc errors are caused by a syntax error in context_ui.admin.inc, patch attached. It's trying to drupal_set_message "An error occurred while importing. Please check your context definition." but the syntax error with t() caused the intermediate message.
This doesn't solve the problem, just allows it to be accurately debugged.

thebuckst0p’s picture

StatusFileSize
new726 bytes

The bug is in the import code. eval() creates each variable/object defined in the string, so $context in the eval string will become an object, but $context = eval($import); where $context is set inside $import means the outer $context will override the imported/eval'd one.
This patch fixed both the issue in the previous comment and the larger one, and contexts seem to be importing now.

thebuckst0p’s picture

Status: Active » Needs review
mrtorrent’s picture

The patch from #6 works for me in the regular context import. Reverting contexts from features still does not work, however, but perhaps this is a separate issue.

q0rban’s picture

I would make sure you all are using the latest stable releases of each of these modules, re-create your contexts, and then update your feature.

mrtorrent’s picture

I am and I have. Reverting contexts from features just seems to have no effect

q0rban’s picture

> Reverting contexts from features just seems to have no effect

Just to clarify, did you recreate the context and update the feature first?

mrtorrent’s picture

Yes, that's right. So, for example, this afternoon I created a new context, exported it in a feature, and then deployed (copied and enabled) the feature to another server. On enabling the feature, the context was not created and shows as 'overridden.' Attempting to revert the context from within features has no effect -- there is a success message saying it has been reverted, but it still shows as overridden and does not appear in the contexts admin UI.

mrtorrent’s picture

Turns out it was indeed a Features issue. Patch here fixes it: http://drupal.org/node/814414

mikl’s picture

Status: Needs review » Needs work

I’ve tried the latest dev version of Features that includes the patch from #814414: Exported contexts are overridden and removed, but it does not appear to solve this issue.

mikl’s picture

Status: Needs work » Reviewed & tested by the community

The patch from #6, however, does solve the problem.

yhahn’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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