Download & Extend

image on site front page disappears when upgrading from 6.x-2.0 to 6.x-2.1

Project:Strongarm
Version:6.x-2.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

An image on my site's front page disappears when I upgrade from Strongarm 2.0 to 2.1. The key difference seems to be the code in strongarm.module that provided a "workaround for the very early check of the 'site_frontpage' variable in the Drupal bootstrap process," which was removed in 2.1. Upgrading to 2.1 results in this error:

404: Unable to find sites/default/files/category_pictures/generic_city.jpg

Here's the code that was removed:

/**
* Implementation of hook_init().
*/
function strongarm_init() {
  strongarm_set_conf();

  // This is a workaround for the very early check of the 'site_frontpage'
  // variable in the Drupal bootstrap process. The workaround re-runs
  // drupal_init_path() to ensure the strongarm'ed version of
  // 'site_frontpage' is used. Note that this may be too late if other modules
  // weighted even lower than strongarm (which is a superlightweight -1000)
  // rely on $_GET['q'] or 'site_frontpage' in hook_init().
  $_GET['q'] = isset($_REQUEST['q']) ? strongarm_language_strip($_REQUEST['q']) : NULL;
  drupal_init_path();
}

/**
* Retrieve variable configuration from the cache.
*/
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 {
    $var_conf = array();
    foreach (strongarm_vars_load(FALSE, TRUE) as $var) {
      $var_conf[$var->name] = $var->value;
    }
    cache_set('strongarm', $var_conf);
  }
  global $conf;

  // Store the original variable values. This allows additional calls to
  // strongarm_set_conf() to properly set Strongarm values.
  static $original_conf;
  if (!isset($original_conf)) {
    $original_conf = $conf;
  }

  $conf = array_merge($var_conf, $original_conf);
}

/**
* Remove the language prefix for a given path.
* Strongarm implements this itself as language_initialize() directly affects
* $_GET['q'] and cannot be reused.
*/
function strongarm_language_strip($path) {
  // Configured presentation language mode.
  $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);

  // Get a list of enabled languages.
  $languages = language_list('enabled');
  $languages = $languages[1];

  if (in_array($mode, array(LANGUAGE_NEGOTIATION_PATH_DEFAULT, LANGUAGE_NEGOTIATION_PATH))) {
    $args = explode('/', $path);
    $prefix = array_shift($args);
    // Search prefix within enabled languages.
    foreach ($languages as $language) {
      if (!empty($language->prefix) && $language->prefix == $prefix) {
        return implode('/', $args);
      }
    }
  }
  return $path;
}