Commit 3649f452 authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian

#234390 - Test that site is not installed in a subdirectory before installation

parent 327f7c25
......@@ -17,9 +17,14 @@ function provision_install() {
}
/**
* Implementation of hook_requirements
*
* Make sure that the POSIX library is available, and that we are not running on a windows based host.
* Make sure that site is not installed in a subdirectory, but that the DocumentRoot directive points at
* the installation.
*/
function provision_requirements($phase) {
global $base_path;
$t = get_t();
$has_posix = function_exists('posix_uname');
......@@ -31,5 +36,16 @@ function provision_requirements($phase) {
$t("<p><strong>This library is not available on Windows based hosts</strong>, and you will not be able to install this system.</p>");
$requirements['posix']['severity'] = REQUIREMENT_ERROR;
}
$is_in_docroot = $base_path == '/';
$docroot = $_SERVER['DOCUMENT_ROOT'];
$requirements['docroot']['title'] = $t("Document root");
$requirements['docroot']['value'] = ($is_in_docroot) ? $t('Correct') :
$t("Installed in the @subdir sub directory of @root", array('@root' => rtrim($docroot,'/'), '@subdir' => trim($base_path, '/')));
if (!$is_in_docroot) {
$requirements['docroot']['value'] = $t("Drupal has been installed in a subdirectory.
You will need to modify your virtual host configuration to point a ServerName directly at the installation path.");
$requirements['docroot']['severity'] = REQUIREMENT_ERROR;
}
return $requirements;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment