Commit 73836759 authored by Dries's avatar Dries

- Patch #818374 by Damien Tournoud, ksenzee, Dave Reid: add a requirements...

- Patch #818374 by Damien Tournoud, ksenzee, Dave Reid: add a requirements check error if PECL PDO is being used.
parent 563c673e
......@@ -819,7 +819,12 @@ function install_verify_settings() {
* Verify PDO library.
*/
function install_verify_pdo() {
return extension_loaded('pdo');
// PDO was moved to PHP core in 5.2.0, but the old extension (targeting 5.0
// and 5.1) is still available from PECL, and can still be built without
// errors. To verify that the correct version is in use, we check the
// PDO::ATTR_DEFAULT_FETCH_MODE constant, which is not available in the
// PECL extension.
return extension_loaded('pdo') && defined('PDO::ATTR_DEFAULT_FETCH_MODE');
}
/**
......
......@@ -113,16 +113,23 @@ function update_prepare_d7_bootstrap() {
// loaded. Bootstrapping to DRUPAL_BOOTSTRAP_DATABASE will result in a fatal
// error otherwise.
$message = '';
$pdo_link = 'http://drupal.org/requirements/pdo';
// Check that PDO is loaded.
if (!extension_loaded('pdo')) {
$message = '<h2>PDO is required!</h2><p>Drupal 7 requires PHP ' . DRUPAL_MINIMUM_PHP . ' or higher with the PHP Data Objects (PDO) extension enabled.</p>';
}
// The PDO::ATTR_DEFAULT_FETCH_MODE constant is not available in the PECL
// version of PDO.
elseif (!defined('PDO::ATTR_DEFAULT_FETCH_MODE')) {
$message = '<h2>The wrong version of PDO is installed!</h2><p>Drupal 7 requires the PHP Data Objects (PDO) extension from PHP core to be enabled. This system has the older PECL version installed.';
$pdo_link = 'http://drupal.org/requirements/pdo#pecl';
}
// Check that the correct driver is loaded for the database being updated.
elseif (!in_array($databases['default']['default']['driver'], PDO::getAvailableDrivers())) {
$message = '<h2>A PDO database driver is required!</h2><p>You need to enable the PDO_' . strtoupper($databases['default']['default']['driver']) . ' database driver for PHP ' . DRUPAL_MINIMUM_PHP . ' or higher so that Drupal 7 can access the database.</p>';
$message = '<h2>A PDO database driver is required!</h2><p>You need to enable the PDO_' . strtoupper($databases['default']['default']['driver']) . ' database driver for PHP ' . DRUPAL_MINIMUM_PHP . ' or higher so that Drupal 7 can access the database.</p>';
}
if ($message) {
print $message . '<p>See the <a href="http://drupal.org/requirements">system requirements page</a> for more information.</p>';
print $message . '<p>See the <a href="' . $pdo_link . '">system requirements page</a> for more information.</p>';
exit();
}
......
......@@ -144,19 +144,36 @@ function system_requirements($phase) {
'title' => $t('Database support'),
);
// Test for at least one suitable PDO extension, if PDO is available.
// Make sure PDO is available.
$database_ok = extension_loaded('pdo');
if ($database_ok) {
if (!$database_ok) {
$pdo_message = $t('Your web server does not appear to support PDO (PHP Data Objects). Ask your hosting provider if they support the native PDO extension. See the <a href="@link">system requirements</a> page for more information.', array(
'@link' => 'http://drupal.org/requirements/pdo',
));
}
else {
// Make sure at least one supported database driver exists.
$drivers = drupal_detect_database_types();
$database_ok = !empty($drivers);
if (empty($drivers)) {
$database_ok = FALSE;
$pdo_message = $t('Your web server does not appear to support any common PDO database extensions. Check with your hosting provider to see if they support PDO (PHP Data Objects) and offer any databases that <a href="@drupal-databases">Drupal supports</a>.', array(
'@drupal-databases' => 'http://drupal.org/node/270#database',
));
}
// Make sure the native PDO extension is available, not the older PEAR
// version. (See install_verify_pdo() for details.)
if (!defined('PDO::ATTR_DEFAULT_FETCH_MODE')) {
$database_ok = FALSE;
$pdo_message = $t('Your web server seems to have the wrong version of PDO installed. Drupal 7 requires the PDO extension from PHP core. This system has the older PECL version. See the <a href="@link">system requirements</a> page for more information.', array(
'@link' => 'http://drupal.org/requirements/pdo#pecl',
));
}
}
if (!$database_ok) {
$requirements['database_extensions']['value'] = $t('Disabled');
$requirements['database_extensions']['severity'] = REQUIREMENT_ERROR;
$requirements['database_extensions']['description'] = $t('Your web server does not appear to support any common PDO database extensions. Check with your hosting provider to see if they support PDO (PHP Data Objects) and offer any databases that <a href="@drupal-databases">Drupal supports</a>.', array(
'@drupal-databases' => 'http://drupal.org/node/270#database',
));
$requirements['database_extensions']['description'] = $pdo_message;
}
else {
$requirements['database_extensions']['value'] = $t('Enabled');
......
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