diff -urpN drupal-6.x-dev-200708091623/includes/bootstrap.inc prepatch/includes/bootstrap.inc --- drupal-6.x-dev-200708091623/includes/bootstrap.inc 2007-08-07 16:41:24.000000000 +0800 +++ prepatch/includes/bootstrap.inc 2007-08-10 03:19:52.000000000 +0800 @@ -331,6 +331,10 @@ function conf_init() { ini_set('session.cookie_domain', $cookie_domain); } session_name('SESS'. md5($session_name)); + + if (!function_exists('variable_get')) { + require_once './includes/variable.inc'; + } } /** @@ -430,61 +434,6 @@ function variable_init($conf = array()) } /** - * Return a persistent variable. - * - * @param $name - * The name of the variable to return. - * @param $default - * The default value to use if this variable has never been set. - * @return - * The value of the variable. - */ -function variable_get($name, $default) { - global $conf; - - return isset($conf[$name]) ? $conf[$name] : $default; -} - -/** - * Set a persistent variable. - * - * @param $name - * The name of the variable to set. - * @param $value - * The value to set. This can be any PHP data type; these functions take care - * of serialization as necessary. - */ -function variable_set($name, $value) { - global $conf; - - $serialized_value = serialize($value); - db_query("UPDATE {variable} SET value = '%s' WHERE name = '%s'", $serialized_value, $name); - if (!db_affected_rows()) { - @db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $serialized_value); - } - - cache_clear_all('variables', 'cache'); - - $conf[$name] = $value; -} - -/** - * Unset a persistent variable. - * - * @param $name - * The name of the variable to undefine. - */ -function variable_del($name) { - global $conf; - - db_query("DELETE FROM {variable} WHERE name = '%s'", $name); - cache_clear_all('variables', 'cache'); - - unset($conf[$name]); -} - - -/** * Retrieve the current page from the cache. * * Note: we do not serve cached pages when status messages are waiting (from diff -urpN drupal-6.x-dev-200708091623/includes/variable.inc prepatch/includes/variable.inc --- drupal-6.x-dev-200708091623/includes/variable.inc 1970-01-01 08:00:00.000000000 +0800 +++ prepatch/includes/variable.inc 2007-08-10 02:03:59.000000000 +0800 @@ -0,0 +1,56 @@ + $item) { + $serialized_value = serialize($item); + db_query("UPDATE {variable} SET value = '%s' WHERE name = '%s'", $serialized_value, $name); + if (!db_affected_rows()) { + @db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $serialized_value); + } + } + } + + $conf[$name] = $value; +} + +function variable_del($name) { + global $conf; + + if (db_table_exists('variable')) { + db_query("DELETE FROM {variable} WHERE name = '%s'", $name); + cache_clear_all('variables', 'cache'); + } + + unset($conf[$name]); +} diff -urpN drupal-6.x-dev-200708091623/install.php prepatch/install.php --- drupal-6.x-dev-200708091623/install.php 2007-07-26 01:35:47.000000000 +0800 +++ prepatch/install.php 2007-08-10 03:19:43.000000000 +0800 @@ -16,6 +16,13 @@ require_once './includes/install.inc'; */ function install_main() { global $profile, $install_locale, $conf; + + // Since maybe no persistent storage is available yet, and functions that + // check for variables will fail, we temporarily replace the normal + // variable system with a stubbed-out version that cache variables until + // storage exists. + require_once './includes/variable-install.inc'; + require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);