The language_default variable is stored in the {variable} table as an array.

However, if this is set per-realm and exported as part of a variable_store Features export, the result is an array:

/**
 * Implements hook_variable_realm_default_variables().
 */
function myfeature_variable_realm_default_variables() {
  $realm_variables = array();
  $realm_variables['domain']['mydomain'] = array(
  'admin_theme' => 'seven',
  'anonymous' => 'Anonymous',
  'date_default_timezone' => 'Europe/London',
  'language_default' => array(
    'language' => 'pt-br',
    'name' => 'Portuguese, Brazil',
    'native' => 'Português',
    'direction' => 0,
    'enabled' => 1,
    'plurals' => 2,
    'formula' => '($n!=1)',
    'domain' => '',
    'prefix' => 'pt-br',
    'weight' => 0,
    'javascript' => 'pEuv3q13tcp6nQ7IbfdMXmPXgPiApU9DSamV9vgR_HY',
  ),

If the feature is then reverted, the value in the variable_store table is set to an array, which then breaks Drupal core's language system: the array is not recognized as a valid language and no multilingual features are available.

The problem is caused by variable_realm_features_export_render() using features_var_export() to write the export code, which in turn casts all objects to arrays:

  if (is_object($var)) {
    $output = method_exists($var, 'export') ? $var->export() : features_var_export((array) $var, '', FALSE, $count+1);
  }

Using ctools_var_export() instead fixes the problem. That adds an unrelated change, as it quotes numeric values, but that won't cause a problem with variable values. I'll file a patch for CTools for that anyway.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

joachim’s picture

Status: Active » Needs review
FileSize
822 bytes

Status: Needs review » Needs work

The last submitted patch, 2: 2576245.variable.language-export-broken.patch, failed testing.

joachim’s picture

Status: Needs work » Needs review

Ah yes, patch goes on top of #2574689: exported Features code is incorrectly indented, and hence won't apply to HEAD.

kenorb’s picture

VitalyM’s picture

It seems that problem not solved yet, we just replicated it in our projects.