#728702: redirect to install.php on an empty database.

From: Damien Tournoud <damien@commerceguys.com>


---
 bootstrap.inc |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git includes/bootstrap.inc includes/bootstrap.inc
index 1eb92da..69aba13 100644
--- includes/bootstrap.inc
+++ includes/bootstrap.inc
@@ -736,7 +736,14 @@ function variable_initialize($conf = array()) {
     $variables = $cached->data;
   }
   else {
-    // Cache miss. Avoid a stampede.
+    // The variable cache was not available. It might mean that we are running
+    // on an empty database. In that case, just redirect the user to install.php.
+    if (!db_table_exists('variable') && !defined('MAINTENANCE_MODE')) {
+      include_once DRUPAL_ROOT . '/includes/install.inc';
+      install_goto('install.php');
+    }
+
+    // Avoid a stampede.
     $name = 'variable_init';
     if (!lock_acquire($name, 1)) {
       // Another request is building the variable cache.
