Encountered a very odd bug where the tableExists() was returning TRUE even though the table didn't actually exist. Not exactly sure if it points to a problem higher up with queryRange() not throwing exceptions but the fact is that there could be some better handling inside the tableExists() function itself. What it currently does is perform the SQL inside a try/catch. If it hits the catch statement, return FALSE. If it stays inside the try block, return TRUE no matter what. This should be changed to actually check the result of the SQL statement as well. Possibly we should throw our own exception inside the try block.
Comment | File | Size | Author |
---|---|---|---|
#19 | 818374-19-no-pecl-kthxbai.patch | 5.33 KB | ksenzee |
#16 | 818374-16-no-pecl-kthxbai.patch | 2.65 KB | ksenzee |
#8 | 818374.patch | 3.19 KB | Damien Tournoud |
#7 | 818374.patch | 1.56 KB | Damien Tournoud |
#1 | 818374-table-exists-handling-D7.patch | 1.3 KB | Dave Reid |
Comments
Comment #1
Dave ReidHere's the additional checking added to both tableExists() and fieldExists(). I added a ->fetchField() to actually get the result of the queryRange() call and check if it is not identical to FALSE, which if it did would indicate a failure, so table or field does not exist.
Comment #2
Crell CreditAttribution: Crell commentedSQL--
If we're going to do that, we should see if indexExists() needs similar treatment.
Although, aren't there unit tests already for this? Why aren't they failing? (Or did we forget those?)
Comment #3
Dave ReidI'm wondering if it was an environment problem, although it is unfortunate because the host on which this occurred does not have cURL enabled, so I cannot run the regression tests that include tests for db_table_exists() and db_field_exists().
indexExists() won't need this same treatment since it already uses something similar:
Comment #4
Damien Tournoud CreditAttribution: Damien Tournoud commented-1 here. This is probably a different issue.
By any chance, are you sure that this host is running the real PDO module from 5.2, and not the PDO module from PECL (which doesn't support exceptions)?
Comment #5
Dave ReidUgh, that was it. We need a good requirements check for this.
Comment #6
Dave ReidComment #7
Damien Tournoud CreditAttribution: Damien Tournoud commentedLet's try this.
Comment #8
Damien Tournoud CreditAttribution: Damien Tournoud commentedAdding additional checks in install.core.inc and system.install. This is a mess.
Comment #9
Crell CreditAttribution: Crell commentedIs it possible to move that check into a utility function, so that we're not documenting the same weird thing in 3 places?
Someone with PECL PDO needs to test this, too, to confirm that it gets rejected.
Gah.
Comment #10
Crell CreditAttribution: Crell commentedComment #11
Everett Zufelt CreditAttribution: Everett Zufelt commented#937714: Receiving database exception: DatabaseSchemaObjectExistsException: cache_path does show that using PECL PDO this patch does do proper detection.
I think also that this bug should be Major, since without the patch users receive an error without any direction at all about what might be causing the error.
Comment #12
Everett Zufelt CreditAttribution: Everett Zufelt commentedThe Drupal requirements page http://drupal.org/requirements also appears to be in need of an update, since it refers to PECL PDO.
Comment #13
Damien Tournoud CreditAttribution: Damien Tournoud commentedWe definitely need to fix that. We saw a few users crashing into this already.
Promoting to critical.
Comment #14
shelleyp CreditAttribution: shelleyp commentedThe patch was only partially successful. Following is the reject file contents:
***************
*** 147,153 ****
);
// Test for at least one suitable PDO extension, if PDO is available.
- $database_ok = extension_loaded('pdo');
if ($database_ok) {
$drivers = drupal_detect_database_types();
$database_ok = !empty($drivers);
--- 147,157 ----
);
// Test for at least one suitable PDO extension, if PDO is available.
+ // PDO has been moved to PHP core in 5.2.0, but the old extension (targetting
+ // 5.0 and 5.1) is still available from PECL, and can still be built without
+ // errors. Checking the PDO::ATTR_DEFAULT_FETCH_MODE constant, only available
+ // starting PDO 5.2.0 allow us to verify if the correct version is used.
+ $database_ok = extension_loaded('pdo') && defined('PDO::ATTR_DEFAULT_FETCH_MODE');
if ($database_ok) {
$drivers = drupal_detect_database_types();
$database_ok = !empty($drivers);
~
The reject file was in system.install.rej.
However, when I did try the upgrade following, I did get the appropriate error message.
If you want me to test anything on this, on my system, send me an email. Will be glad to help however I can.
Comment #15
Dave ReidRemoved the instructions about pecl pdo on drupal.org/requirements.
Comment #16
ksenzeeLooks like there was an indent problem with the hunk that didn't apply. I fixed that and trimmed down the comments so we're not documenting the same thing so often.
Comment #17
shelleyp CreditAttribution: shelleyp commentedI have restored the original D7 installation, and tested your patch on my PECL PDO system, and it worked without an error, and Drupal is now providing the correct error message.
I'm not sure if I'm supposed to change the status of this bug, to signify tested by community, so will leave as is.
Comment #18
webchickThis is definitely preferable to giving an error that completely makes no sense and moreover is just WRONG, but there is no recourse for the user on how to redress this problem. We should point them at a handbook page (perhaps http://drupal.org/node/549702?) or at the very least let them know this is something their web host needs to deal with (preferably, along with some keywords so that the host goes "oh, I get it." instead of asking a non-technical end user to elaborate on what they mean).
Comment #19
ksenzeeThis adds a link to http://drupal.org/requirements/pdo#pecl to the error message for both update and install, and splits up the check on install to provide more specific, relevant errors to people who are installing.
Comment #20
Damien Tournoud CreditAttribution: Damien Tournoud commentedPerfect!
Comment #21
Crell CreditAttribution: Crell commentedThis looks OK to me as well on quick visual inspection. For the most part, though, I defer to Damien on this one as he's been following it more closely than I have.
Comment #22
Dries CreditAttribution: Dries commentedLooks great. Committed to CVS HEAD. Thanks.
Comment #23
montesq CreditAttribution: montesq commentedDear All,
I've just tested the new D7beta2 on a shared web hosting and I've got the error: "Your web server seems to have the wrong version of PDO installed..."
According to the phpinfo(), the current PHP version is 5.2.5. I also see a reference to pecl but only in the sections PDF and SQLite (and not in the PDO section).
Is there any means to know whether PDO comes from the core or from pecl?
Thks in advance.
Comment #24
Damien Tournoud CreditAttribution: Damien Tournoud commentedYes, if you get the message, PDO comes from PECL.
Restoring statuses.
Comment #25
Damien Tournoud CreditAttribution: Damien Tournoud commentedComment #27
joemoraca CreditAttribution: joemoraca commentedI have have the same database error as here and http://drupal.org/node/937714. I don't get the PDO version check error message. I am using a multi site setup with 7.0 beta3. First site is a new site it works fine. Second site is converted (started in drupal 5.0) it works fine no problem with the conversion to V6 or V7. Third site is also started from Drupal 5 - converted with no problem to Drupal 6 now I get the database error about index already existing trying to upgrade to D7 - I remove that index and get stuck in a loop of database issues.
I am running PHP 5.2.10-2ubuntu6.5 with apache2.2.12 - pdo_mysql shows 5.1.37 ...
If I do pecl list the only package that shows up is uploadprogress ...
DatabaseSchemaObjectExistsException: Cannot add index system_list to table system: index already exists. in DatabaseSchema_mysql->addIndex() (line 433 of /home/drupal-7.0-beta3/includes/database/mysql/schema.inc).
Comment #28
webchickHm. Joe, could you maybe make a separate issue with details and cross-link it here? This issue was about adding a requirements check during installation for the proper version of PDO, which is effectively done now. What you're describing might be related, but it doesn't sound like quite the same thing.
Comment #29
joemoraca CreditAttribution: joemoraca commentedI just created http://drupal.org/node/982748 with my issue.