I'm implement an application that heavily uses Strongarm and Context to apply a dynamic logic on configuration. But the cache cause me many problems, I need a proper way to re-instalize the configuration array. When you call strongarm_set_conf() more than two times, the variables are not reset correctly. The main problem is on the 2nd called, $conf array is mixed with previous cache variables

The implementation should be:

function strongarm_set_conf($reset = FALSE) {
  $varcache = cache_get('variables', 'cache');
  $cache = cache_get('strongarm', 'cache');
  // The > comparison here is cautious but ensures that the strongarm cache
  // actually was populated after the variable cache. It is possible with
  // >= for the var cache to be populated again during the same stale second.
  if (!$reset && ($cache && $varcache && $cache->created > $varcache->created)) {
    $var_conf = $cache->data;
  }
  else {
    // Ensure that the schema cache is not stale when we init.
    $schema = drupal_get_schema('variable');
    if (!isset($schema['export'])) {
      drupal_get_schema('variable', TRUE);
    }

    $var_conf = array();
    ctools_include('export');
    foreach (ctools_export_load_object('variable') as $var) {
      $var_conf[$var->name] = $var->value;
    }
    cache_set('strongarm', $var_conf);
  }
  global $conf,$org_conf;

  if (empty($org_conf)) {
    $org_conf = $conf;
  }

  $conf = array_merge($var_conf, $org_conf);
}
CommentFileSizeAuthor
#2 strongarm_reset.patch697 bytesnquocbao
#1 strongarm_reset.patch444 bytesnquocbao

Comments

nquocbao’s picture

StatusFileSize
new444 bytes
nquocbao’s picture

StatusFileSize
new697 bytes

Add ctools_object_export reset for reset. This one is also related to #762206: _ctools_export_get_defaults is not resetable

yhahn’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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