Some "variables" are used before the variable system is actually initialized, which means that they can never be set with variable_set, they need to be defined in $conf in settings.php. A typical issue with that.. variable_init() -> cache_get() -> variable_get(). With #145164: DX: Use hook_variable_info to declare variables and defaults, it gets even worser, variable_get() will then call variable_default() which calls cache_get() again... See attached screenshot.

That mix doesn't really make sense imho, so I thought about splitting them up. What I'm proposing:

- Introduce conf_get() and conf_set() which can be used to load/store data in $conf. storing is only temporary, and can for example be used to flush the cache. See http://api.drupal.org/api/function/cache_get/7
- Either save the variables in global $variables, or use drupal_static() to share it between variable_*

These are the variables that currently have to be initalized in variable_default (again, #145164: DX: Use hook_variable_info to declare variables and defaults) because they are used too early in the game, I assume that most of them should be/are configuration settings.

    $defaults['cache_inc'] = './includes/cache.inc';
    $defaults['page_cache_fastpath'] = FALSE;
    $defaults['blocked_ips'] = NULL;
    $defaults['session_inc'] = './includes/session.inc';
    $defaults['dev_query'] = 0;
    $defaults['reverse_proxy'] = 0;
    $defaults['reverse_proxy_addresses'] = array();
    $defaults['cache'] = CACHE_DISABLED;
    $defaults['cache_flush'] = 0;
    $defaults['language_count'] = 1;
    $defaults['session_write_interval'] = 180;
    $defaults['site_frontpage'] = 'node';
    $defaults['install_profile_modules'] = array();
    $defaults['install_locale_batch_components'] = array();
    $defaults['password_inc'] = './includes/password.inc';
    $defaults['field_storage_module'] = 'field_sql_storage';
    $defaults['language_default'] = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
CommentFileSizeAuthor
variable_init.png45.11 KBBerdir
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

franz’s picture

Version: 7.x-dev » 8.x-dev
Status: Active » Postponed

see http://drupal.org/node/145164#comment-4852482

I think this is postponed until the new system to handle configuration is shaped up.

Berdir’s picture

Status: Postponed » Active

The same problem applies for CMI, even more so as it is unable to handle these early things. I do think there are duplicates of this issue, but I can't find them, so re-activating for the moment. At least the list of affected variables might be helpful, although probably outdated.

Berdir’s picture

Status: Active » Closed (duplicate)