summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2006-09-01 08:44:53 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2006-09-01 08:44:53 +0000
commitdd4f143df621bb926934335c4fdf44f8267f6039 (patch)
tree24cecf862de66f9dd6bd7b272ae8fe00c349c834 /includes
parent246334f30d63a468dcb564703b4ca27a4c22d3d3 (diff)
downloadbrdo-dd4f143df621bb926934335c4fdf44f8267f6039.tar.gz
brdo-dd4f143df621bb926934335c4fdf44f8267f6039.tar.bz2
#75002: Install-time and run-time requirements checking + status report page
Diffstat (limited to 'includes')
-rw-r--r--includes/bootstrap.inc12
-rw-r--r--includes/database.mysql.inc22
-rw-r--r--includes/database.mysqli.inc21
-rw-r--r--includes/database.pgsql.inc25
-rw-r--r--includes/install.inc81
-rw-r--r--includes/theme.inc8
-rw-r--r--includes/unicode.inc68
7 files changed, 194 insertions, 43 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index a666c6c4d..d0deec608 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -781,3 +781,15 @@ function drupal_maintenance_theme() {
drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'core');
$theme = '';
}
+
+/**
+ * Return the name of the localisation function. Use in code that needs to
+ * run both during installation and normal operation.
+ */
+function get_t() {
+ static $t;
+ if (is_null($t)) {
+ $t = function_exists('install_main') ? 'st' : 't';
+ }
+ return $t;
+}
diff --git a/includes/database.mysql.inc b/includes/database.mysql.inc
index db4610884..4f856a83b 100644
--- a/includes/database.mysql.inc
+++ b/includes/database.mysql.inc
@@ -11,6 +11,28 @@
* @{
*/
+
+/**
+ * Report database status.
+ */
+function db_status_report($phase) {
+ $t = get_t();
+
+ $info = mysql_get_server_info();
+ $form['mysql'] = array(
+ 'title' => $t('MySQL database'),
+ 'value' => ($phase == 'runtime') ? l($info, 'admin/logs/status/sql') : $info,
+ );
+
+ // Extract version number
+ list($version) = explode('-', $info);
+ if (version_compare($version, DRUPAL_MINIMUM_MYSQL) < 0) {
+ $form['mysql']['severity'] = REQUIREMENT_ERROR;
+ $form['mysql']['description'] = $t('Your MySQL Server is too old. Drupal requires at least MySQL %version.', array('%version' => DRUPAL_MINIMUM_MYSQL));
+ }
+ return $form;
+}
+
/**
* Initialize a database connection.
*
diff --git a/includes/database.mysqli.inc b/includes/database.mysqli.inc
index f15f7cf01..ced8c4e9e 100644
--- a/includes/database.mysqli.inc
+++ b/includes/database.mysqli.inc
@@ -16,6 +16,27 @@
*/
/**
+ * Report database status.
+ */
+function db_status_report() {
+ $t = get_t();
+
+ $info = mysqli_get_server_info($connection);
+ $form['mysql'] = array(
+ 'title' => $t('MySQL database'),
+ 'value' => ($phase == 'runtime') ? l($info, 'admin/logs/status/sql') : $info,
+ );
+
+ // Extract version number
+ list($version) = explode('-', mysqli_get_server_info($connection));
+ if (version_compare($version, DRUPAL_MINIMUM_MYSQL) < 0) {
+ $form['mysql']['severity'] = REQUIREMENT_ERROR;
+ $form['mysql']['description'] = $t('Your MySQL Server is too old. Drupal requires at least MySQL %version.', array('%version' => DRUPAL_MINIMUM_MYSQL));
+ }
+ return $form;
+}
+
+/**
* Initialise a database connection.
*
* Note that mysqli does not support persistent connections.
diff --git a/includes/database.pgsql.inc b/includes/database.pgsql.inc
index c1e6d5d6e..01140e133 100644
--- a/includes/database.pgsql.inc
+++ b/includes/database.pgsql.inc
@@ -12,6 +12,31 @@
*/
/**
+ * Report database status.
+ */
+function db_status_report() {
+ $t = get_t().dli;
+
+ $form['pgsql'] = array();
+
+ if (function_exists('pg_version')) {
+ $version = pg_version();
+ if (version_compare($version['server'], DRUPAL_MINIMUM_PGSQL) < 0) {
+ $form['pgsql']['severity'] = REQUIREMENT_ERROR;
+ $form['pgsql']['description'] = $t('Your PostgreSQL Server is too old. Drupal requires at least PostgreSQL %version.', array('%version' => DRUPAL_MINIMUM_PGSQL));
+ }
+ }
+ else {
+ $version = array('server' => t('Unknown'));
+ }
+
+ $form['pgsql']['title'] = $t('PostgreSQL database');
+ $form['pgsql']['value'] = $version['server'];
+
+ return $form;
+}
+
+/**
* Initialize a database connection.
*
* Note that you can change the pg_connect() call to pg_pconnect() if you
diff --git a/includes/install.inc b/includes/install.inc
index 9b19cf665..1c0608a63 100644
--- a/includes/install.inc
+++ b/includes/install.inc
@@ -4,11 +4,9 @@
define('SCHEMA_UNINSTALLED', -1);
define('SCHEMA_INSTALLED', 0);
-define('DRUPAL_MINIMUM_PHP', '4.3.3');
-define('DRUPAL_MINIMUM_MEMORY', '8M');
-define('DRUPAL_MINIMUM_MYSQL', '3.23.17'); // If using MySQL
-define('DRUPAL_MINIMUM_PGSQL', '7.3'); // If using PostgreSQL
-define('DRUPAL_MINIMUM_APACHE', '1.3'); // If using Apache
+define('REQUIREMENT_OK', 0);
+define('REQUIREMENT_WARNING', 1);
+define('REQUIREMENT_ERROR', 2);
define('FILE_EXIST', 1);
define('FILE_READABLE', 2);
@@ -128,7 +126,7 @@ function drupal_detect_baseurl($file = 'install.php') {
$proto = $_SERVER['HTTPS'] ? 'https://' : 'http://';
$host = $_SERVER['SERVER_NAME'];
$port = ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'. $_SERVER['SERVER_PORT']);
- $uri = str_replace("?profile=$profile", '', $_SERVER['REQUEST_URI']);
+ $uri = preg_replace("/\?.*/", '', $_SERVER['REQUEST_URI']);
$dir = str_replace("/$file", '', $uri);
return "$proto$host$port$dir";
@@ -602,3 +600,74 @@ function _st(&$value, $key) {
case '!':
}
}
+
+
+/**
+ * Check a profile's requirements.
+ *
+ * @param profile
+ * Name of profile to check.
+ */
+function drupal_check_profile($profile) {
+ include_once './includes/file.inc';
+
+ $profile_file = "./profiles/$profile/$profile.profile";
+
+ if (!isset($profile) || !file_exists($profile_file)) {
+ install_no_profile_error();
+ }
+
+ require_once($profile_file);
+
+ // Get a list of modules required by this profile.
+ $function = $profile .'_profile_modules';
+ $module_list = array_unique(array_merge(array('system'), $function()));
+
+ // Get a list of all .install files.
+ $installs = drupal_get_install_files($module_list);
+
+ // Collect requirement testing results
+ $requirements = array();
+ foreach ($installs as $install) {
+ require_once $install->filename;
+ $requirements = array_merge($requirements, module_invoke($install->name, 'requirements', 'install'));
+ }
+ return $requirements;
+}
+
+/**
+ * Extract highest severity from requirements array.
+ */
+function drupal_requirements_severity(&$requirements) {
+ $severity = REQUIREMENT_OK;
+ foreach ($requirements as $requirement) {
+ if (isset($requirement['severity'])) {
+ $severity = max($severity, $requirement['severity']);
+ }
+ }
+ return $severity;
+}
+
+/**
+ * Check a module's requirements.
+ */
+function drupal_check_module($module) {
+ // Include install file
+ $install = drupal_get_install_files(array($module));
+ if (isset($install[$module])) {
+ require_once $install[$module]->filename;
+
+ // Check requirements
+ $requirements = module_invoke($module, 'requirements', 'install');
+ if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
+ // Print any error messages
+ foreach ($requirements as $requirement) {
+ if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
+ drupal_set_message($requirement['description'] .' ('. t('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) .')', 'error');
+ }
+ }
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
diff --git a/includes/theme.inc b/includes/theme.inc
index 10478d195..8c53e8461 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -450,16 +450,16 @@ function theme_install_page($content) {
$output .= theme('status_messages', 'error');
}
- $output .= "\n<!-- begin content -->\n";
- $output .= $content;
- $output .= "\n<!-- end content -->\n";
-
if (isset($messages['status'])) {
$warnings = count($messages['status']) > 1 ? 'warnings' : 'warning';
$output .= "<h4>The following installation $warnings should be carefully reviewed, but in most cases may be safely ignored:</h4>";
$output .= theme('status_messages', 'status');
}
+ $output .= "\n<!-- begin content -->\n";
+ $output .= $content;
+ $output .= "\n<!-- end content -->\n";
+
$output .= '</body></html>';
return $output;
diff --git a/includes/unicode.inc b/includes/unicode.inc
index 81fe2ffeb..5134dc609 100644
--- a/includes/unicode.inc
+++ b/includes/unicode.inc
@@ -9,7 +9,7 @@ define('UNICODE_MULTIBYTE', 1);
* Wrapper around _unicode_check().
*/
function unicode_check() {
- $GLOBALS['multibyte'] = _unicode_check();
+ list($GLOBALS['multibyte']) = _unicode_check();
}
/**
@@ -23,68 +23,70 @@ function unicode_check() {
* @param $errors
* Whether to report any fatal errors with form_set_error().
*/
-function _unicode_check($errors = FALSE) {
+function _unicode_check() {
+ // Ensure translations don't break at install time
+ $t = get_t();
+
// Set the standard C locale to ensure consistent, ASCII-only string handling.
setlocale(LC_CTYPE, 'C');
// Check for outdated PCRE library
// Note: we check if U+E2 is in the range U+E0 - U+E1. This test returns TRUE on old PCRE versions.
if (preg_match('/[à-á]/u', 'â')) {
- if ($errors) {
- form_set_error('unicode', t('The PCRE library in your PHP installation is outdated. This will cause problems when handling Unicode text. If you are running PHP 4.3.3 or higher, make sure you are using the PCRE library supplied by PHP. Please refer to the <a href="@url">PHP PCRE documentation</a> for more information.', array('@url' => 'http://www.php.net/pcre')));
- }
- return UNICODE_ERROR;
+ return array(UNICODE_ERROR, $t('The PCRE library in your PHP installation is outdated. This will cause problems when handling Unicode text. If you are running PHP 4.3.3 or higher, make sure you are using the PCRE library supplied by PHP. Please refer to the <a href="@url">PHP PCRE documentation</a> for more information.', array('@url' => 'http://www.php.net/pcre')), REQUIREMENT_ERROR);
}
// Check for mbstring extension
if (!function_exists('mb_strlen')) {
- return UNICODE_SINGLEBYTE;
+ return array(UNICODE_SINGLEBYTE, $t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="@url">PHP mbstring extension</a> for improved Unicode support.', array('@url' => 'http://www.php.net/mbstring')), REQUIREMENT_WARNING);
}
// Check mbstring configuration
if (ini_get('mbstring.func_overload') != 0) {
- if ($errors) {
- form_set_error('unicode', t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
- }
- return UNICODE_ERROR;
+ return array(UNICODE_ERROR, $t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')), REQUIREMENT_ERROR);
}
if (ini_get('mbstring.encoding_translation') != 0) {
- if ($errors) {
- form_set_error('unicode', t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
- }
- return UNICODE_ERROR;
+ return array(UNICODE_ERROR, $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')), REQUIREMENT_ERROR);
}
if (ini_get('mbstring.http_input') != 'pass') {
- if ($errors) {
- form_set_error('unicode', t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
- }
- return UNICODE_ERROR;
+ return array(UNICODE_ERROR, $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')), REQUIREMENT_ERROR);
}
if (ini_get('mbstring.http_output') != 'pass') {
- if ($errors) {
- form_set_error('unicode', t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
- }
- return UNICODE_ERROR;
+ return array(UNICODE_ERROR, $t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')), REQUIREMENT_ERROR);
}
// Set appropriate configuration
mb_internal_encoding('utf-8');
mb_language('uni');
- return UNICODE_MULTIBYTE;
+ return array(UNICODE_MULTIBYTE);
}
/**
- * Return the required Unicode status and errors for admin/settings.
+ * Return Unicode library status and errors.
*/
-function unicode_settings() {
- $status = _unicode_check(TRUE);
- $options = array(UNICODE_SINGLEBYTE => t('Standard PHP: operations on Unicode strings are emulated on a best-effort basis. Install the <a href="@url">PHP mbstring extension</a> for improved Unicode support.', array('@url' => 'http://www.php.net/mbstring')),
- UNICODE_MULTIBYTE => t('Multi-byte: operations on Unicode strings are supported through the <a href="@url">PHP mbstring extension</a>.', array('@url' => 'http://www.php.net/mbstring')),
- UNICODE_ERROR => t('Invalid: the current configuration is incompatible with Drupal.'));
- $form['settings'] = array('#type' => 'item', '#title' => t('String handling method'), '#value' => $options[$status]);
- return $form;
+function unicode_requirements() {
+ // Ensure translations don't break at install time
+ $t = function_exists('install_main') ? 'st' : 't';
+
+ $libraries = array(
+ UNICODE_SINGLEBYTE => $t('Standard PHP'),
+ UNICODE_MULTIBYTE => $t('PHP Mbstring Extension'),
+ UNICODE_ERROR => $t('Error'),
+ );
+ list($library, $description, $severity) = _unicode_check();
+
+ $requirements['unicode'] = array(
+ 'title' => $t('Unicode library'),
+ 'value' => $libraries[$library],
+ );
+ if ($description) {
+ $requirements['unicode']['description'] = $description;
+ $requirements['unicode']['severity'] = $severity;
+ }
+
+ return $requirements;
}
-
+
/**
* Prepare a new XML parser.
*