diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index decb911..218b1d8 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -918,7 +918,28 @@ function variable_initialize($conf = array()) { } else { // Proceed with variable rebuild. - $variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed()); + $variables = array(); + // We can run into unparsable values + $err_variables = array(); + $rows = db_query('SELECT name, value FROM {variable}')->fetchAllKeyed(); + foreach ($rows as $name => $db_value) { + // Suppress the notice. + $value = @unserialize($db_value); + // If the unserialize call returned FALSE and the stored value is NOT a + // boolean false, list it in the report. + if ($value === FALSE && $db_value !== serialize(FALSE) && !isset($conf[$name])) { + $err_variables[] = $name; + } + $variables[$name] = $value; + } + // We throw an exception before storing the variables otherwise + // this exception is only thrown once which is bad + if (count($err_variables)) { + $t = get_t(); + $err_vars = join ("', '", $err_variables); + $err_str = "The variable(s) '@err_vars' are unreadable and need to be fixed. Please read UPGRADE.txt on how to resolve this problem."; + throw new Exception($t($err_str, array('@err_vars' => $err_vars))); + } cache_set('variables', $variables, 'cache_bootstrap'); lock_release($name); }