Commit 434806 by dries
- Patch #818374 by Damien Tournoud, ksenzee, Dave Reid: add a requirements check error if PECL PDO is being used.
--- <a href="http://drupalcode.org/viewvc/drupal/drupal/includes/install.core.inc" title="http://drupalcode.org/viewvc/drupal/drupal/includes/install.core.inc" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/includes/install.core.inc</a> 2010/10/07 03:26:41 1.38
+++ <a href="http://drupalcode.org/viewvc/drupal/drupal/includes/install.core.inc" title="http://drupalcode.org/viewvc/drupal/drupal/includes/install.core.inc" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/includes/install.core.inc</a> 2010/10/12 02:50:03 1.39
@@ -819,7 +819,12 @@
* 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');
}
/**
--- <a href="http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc" title="http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc</a> 2010/10/06 21:51:10 1.76
+++ <a href="http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc" title="http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc</a> 2010/10/12 02:50:03 1.77
@@ -113,16 +113,23 @@
// 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();
}
--- <a href="http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install" title="http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install</a> 2010/10/08 18:19:11 1.517
+++ <a href="http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install" title="http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install</a> 2010/10/12 02:50:03 1.518
@@ -144,19 +144,36 @@
'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');
+++ <a href="http://drupalcode.org/viewvc/drupal/drupal/includes/install.core.inc" title="http://drupalcode.org/viewvc/drupal/drupal/includes/install.core.inc" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/includes/install.core.inc</a> 2010/10/12 02:50:03 1.39
@@ -819,7 +819,12 @@
* 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');
}
/**
--- <a href="http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc" title="http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc</a> 2010/10/06 21:51:10 1.76
+++ <a href="http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc" title="http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/includes/update.inc</a> 2010/10/12 02:50:03 1.77
@@ -113,16 +113,23 @@
// 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();
}
--- <a href="http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install" title="http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install</a> 2010/10/08 18:19:11 1.517
+++ <a href="http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install" title="http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/modules/system/system.install</a> 2010/10/12 02:50:03 1.518
@@ -144,19 +144,36 @@
'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');