summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-10-12 02:50:03 +0000
committerDries Buytaert <dries@buytaert.net>2010-10-12 02:50:03 +0000
commit738367593558ba170cb6d65dda35ec9230654bc3 (patch)
tree4a8025e4e16aba7be4aeee0ae179e6866cd12d94
parent563c673ea3b8977e9f739f7979acb62abcd78310 (diff)
downloadbrdo-738367593558ba170cb6d65dda35ec9230654bc3.tar.gz
brdo-738367593558ba170cb6d65dda35ec9230654bc3.tar.bz2
- Patch #818374 by Damien Tournoud, ksenzee, Dave Reid: add a requirements check error if PECL PDO is being used.
-rw-r--r--includes/install.core.inc7
-rw-r--r--includes/update.inc11
-rw-r--r--modules/system/system.install29
3 files changed, 38 insertions, 9 deletions
diff --git a/includes/install.core.inc b/includes/install.core.inc
index f162bebce..db0951338 100644
--- a/includes/install.core.inc
+++ b/includes/install.core.inc
@@ -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');
}
/**
diff --git a/includes/update.inc b/includes/update.inc
index 492f62756..459dc0a54 100644
--- a/includes/update.inc
+++ b/includes/update.inc
@@ -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();
}
diff --git a/modules/system/system.install b/modules/system/system.install
index 9c9bc2d8c..e37b7b5e2 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -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');