context_update_6002

  1. drupal
    1. 6 context.install function
    2. 7 context.install function
Drupal 7 context_update_6002()

Update script for API change in path condition.

File

sites/all/modules/context/context.install, line 134

Code

function context_update_6002() {
  define('CONTEXT_STORAGE_DEFAULT', 0);
  define('CONTEXT_STORAGE_OVERRIDDEN', 1);
  define('CONTEXT_STORAGE_NORMAL', 2);

  // Iterate through all DB-stored contexts and incorporate path
  // wildcards into their path conditions. Any exported/default
  // contexts will need to be updated by hand.
  $contexts = context_enabled_contexts();
  foreach ($contexts as $context) {
    if (($context->type == CONTEXT_STORAGE_NORMAL || $context->type == CONTEXT_STORAGE_OVERRIDDEN) && (!empty($context->path) && is_array($context->path))) {
      $changed = FALSE;
      foreach ($context->path as $k => $v) {
        if ($v != '<front>' && strpos($v, '*') === FALSE) {
          $changed = TRUE;
          $context->path[$k] = "{$v}*";
        }
      }
      if ($changed) {
        context_save_context($context);
      }
    }
  }
  return array();
}