summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2006-07-31 19:24:16 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2006-07-31 19:24:16 +0000
commit90acf993417f3109536f4d95f3acdb12065e1631 (patch)
tree917d2e41bb8797583e2994df0b529333a75eb02e
parent2cc410304d21aec3cd26c0573c3952c36260a188 (diff)
downloadbrdo-90acf993417f3109536f4d95f3acdb12065e1631.tar.gz
brdo-90acf993417f3109536f4d95f3acdb12065e1631.tar.bz2
#75264: Redirect uninstalled default Drupal site to install.php
-rw-r--r--includes/database.mysql.inc7
-rw-r--r--includes/install.inc22
-rw-r--r--install.php18
-rw-r--r--update.php2
4 files changed, 28 insertions, 21 deletions
diff --git a/includes/database.mysql.inc b/includes/database.mysql.inc
index 731107be8..db4610884 100644
--- a/includes/database.mysql.inc
+++ b/includes/database.mysql.inc
@@ -51,6 +51,13 @@ function db_connect($url) {
// (matched) rows, not the number of affected rows.
$connection = @mysql_connect($url['host'], $url['user'], $url['pass'], TRUE, 2);
if (!$connection) {
+ // Redirect to installer if using default DB credentials
+ if ($url['user'] == 'username' && $url['pass'] == 'password') {
+ include_once 'includes/install.inc';
+ install_goto('install.php');
+ }
+
+ // Show error screen otherwise
drupal_maintenance_theme();
drupal_set_title('Unable to connect to database server');
print theme('maintenance_page', '<p>If you still have to install Drupal, proceed to the <a href="'. base_path() .'install.php">installation page</a>.</p>
diff --git a/includes/install.inc b/includes/install.inc
index be8bc8944..d3aa86a4f 100644
--- a/includes/install.inc
+++ b/includes/install.inc
@@ -19,9 +19,10 @@ define('FILE_NOT_READABLE', 32);
define('FILE_NOT_WRITABLE', 64);
define('FILE_NOT_EXECUTABLE', 128);
-// Initialize the update system if necessary
-if (!$install) {
- // Include install files for each installed module.
+/**
+ * Initialize the update system by loading all installed module's .install files.
+ */
+function drupal_load_updates() {
foreach (module_list() as $module) {
$install_file = './'. drupal_get_path('module', $module) .'/'. $module .'.install';
if (is_file($install_file)) {
@@ -30,7 +31,6 @@ if (!$install) {
}
}
-
/**
* Returns an array of available schema versions for a module.
*
@@ -527,6 +527,20 @@ function drupal_install_fix_file($file, $mask, $message = TRUE) {
}
}
+
+/**
+ * Send the user to a different installer page. This issues an on-site HTTP
+ * redirect. Messages (and errors) are erased.
+ *
+ * @param $path
+ * An installer path.
+ */
+function install_goto($path) {
+ global $base_path;
+ header('Location: '. $base_path . $path);
+ exit();
+}
+
/**
* Hardcoded function for doing the equivalent of theme('placeholder')
* when the theme system is not available.
diff --git a/install.php b/install.php
index a37ffa773..4189c22bc 100644
--- a/install.php
+++ b/install.php
@@ -1,7 +1,6 @@
<?php
// $Id$
-$install = TRUE;
require_once './includes/install.inc';
/**
@@ -49,7 +48,7 @@ function install_main() {
$profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']);
}
elseif ($profile = install_select_profile()) {
- _install_goto("install.php?profile=$profile");
+ install_goto("install.php?profile=$profile");
}
else {
_install_no_profile_error();
@@ -291,7 +290,7 @@ function install_settings_submit($form_id, $form_values) {
drupal_rewrite_settings($settings);
// Continue to install profile step
- _install_goto("install.php?profile=$profile");
+ install_goto("install.php?profile=$profile");
}
/**
@@ -401,17 +400,4 @@ function install_complete($profile) {
print theme('maintenance_page', $output);
}
-/**
- * Send the user to a different installer page. This issues an on-site HTTP
- * redirect. Messages (and errors) are erased.
- *
- * @param $path
- * An installer path.
- */
-function _install_goto($path) {
- global $base_path;
- header('Location: '. $base_path . $path);
- exit();
-}
-
install_main();
diff --git a/update.php b/update.php
index 9c0ae27ae..3713d2178 100644
--- a/update.php
+++ b/update.php
@@ -686,8 +686,8 @@ ini_set('display_errors', TRUE);
// Access check:
if (($access_check == FALSE) || ($user->uid == 1)) {
- $install = FALSE;
include_once './includes/install.inc';
+ drupal_load_updates();
update_fix_schema_version();
update_fix_watchdog_115();