Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This issue was originally a comment on: http://drupal.org/node/914392#comment-3637654
I've moved it here (hopefully the right queue) since the DBTNG issue is fixed.
__
Posted by neclimdul on October 27, 2010 at 12:58pm
applied patch and ran the VersioncontrolAccountStatusTestCase test. Everything passed!
Did get a small exception at the end though:
Exception Uncaught e database.inc 1516
The specified database connection is not defined: default
Looks like maybe we're trying to reset to the default database connection at the end of the test but it isn't working correctly.
Comment | File | Size | Author |
---|---|---|---|
#8 | 0001-bug-955996-by-neclimdul-Fixed-Exception-The-specifie.patch | 943 bytes | marvil07 |
Comments
Comment #1
eliza411 CreditAttribution: eliza411 commentedComment #2
sdboyer CreditAttribution: sdboyer commentedWe'll see if this is still an issue after the tests actually start working. My suspicion is that's either an error related to prefixing that is just a plain ol' DBTNG problem, or could be an error that DBTNG shows when a test throws a fatal error (which the test in question was doing at that time, I believe).
So, marking postponed until we know more.
Comment #3
neclimdulMy guess actually having looked at 0 code from the dbtng module is that its because I just set $db_url as a string not an array. Actually I can probably test this by making it an array. Will report back...
Comment #4
marvil07 CreditAttribution: marvil07 commented#879704: Kill the account status module completely, decide removing first?
Comment #5
neclimdulThis actually happens at the end of every test, sorry. That's just the test I was running to test the other issue and is an artifact of that. Updated title to reflect this.
Comment #6
neclimdulSo, this may very well be a simpletest issue but since its so hard to get fixes in dbtng might just have to work around it. Also, this is actually really important because this exception is a symptom of a bigger problem.
It boils down to this, dbtng_init() sets up the $databases global that's used by the rest of the library for connecting to the database. Since its never called when running simpletests, those tests will always throw this exception as soon as we try to use dbtng. This isn't caught and throws us out of the testing loop. This means any further tests are also not run.
I'm pretty sure this is totally wrong but I put
directly after
global $databases;
in parseConnectionInfo.</psuedopatch>
Comment #7
neclimdulMoving this to dbtng since mikey_p said he could make a patch.
Comment #8
marvil07 CreditAttribution: marvil07 commentedFinally I could run a test(#914392-11: While testing, default prefix is used instead of simpletest prefix by dbtng-driven queries ) with dbtng without versioncontrol! (and I could never reproduce the exception mentioned here :-/)
But I am receiving an array on
$databases
global variable with the db info, but not with the right prefix, that's why I had to remove the conditional.attached as patch to help test.
But this problem seems to be at simpletest, why simpletest module is not calling
hook_init()
?Comment #9
marvil07 CreditAttribution: marvil07 commentedI want to share a conversation I had some minutes ago at #drupal-contribute:
Another solution could be move the code at
hook_init()
tohook_boot()
and ask simpletest module to call manuallyhook_boot()
atDrupalWebTestCase::setUp()
.Comment #10
neclimdulActually, I'm thinking dbtng might have a case for providing its own test type. I don't agree that manually calling dbtng_init is a bad idea in the context of dbtng testing but I do agree that requiring tests do it is less than ideal.
I'm not sure why we can't just lazy load like this though. It means dbtng is more resilient to different uses.
Also, I think the if (empty($databases)) { is a good thing as it keeps $databases from always being rebuilt.
I think this is actually incorrect. It makes sure dbtng knows where the database is and recover in situations where dbtng_init() has not been called like in tests. Custom bootstraps or calls in hook_boot are other places that could have this problem.
Comment #11
mikey_p CreditAttribution: mikey_p commentedI think this is the correct conclusion. neclimdul is right that it's just an issue of hook_init not being called. When I first ported dbtng I figured that was the logical place to put the code to parse the D6 connection string, and that has generally been true, since I was trying to patch the actual files from D7 as little as possible, and it's worked fine most of the time until now. I'll add this check in to make sure that the $database connection info is re-parsed at the last available moment before DBTNG tries to make a connection.
Comment #12
marvil07 CreditAttribution: marvil07 commentedOk, since calling
hook_init()
manually on test seems like a good idea for neclimdul and me, I just have done that from a DBTNGTestCase base class, where I am also removing the connection after each test to avoid problems with prefixes. See #914392-18: While testing, default prefix is used instead of simpletest prefix by dbtng-driven queries for the patch.Not really sure if this issue this original disappears applying that patch, @neclimdul: can you confirm that?
Comment #13
mikey_p CreditAttribution: mikey_p commentedpulling forward to sprint 4
Comment #14
mikey_p CreditAttribution: mikey_p commentedComment #15
mikey_p CreditAttribution: mikey_p commentedThere is no more hook_init, and the database connection info is parsed when needed inside Database::parseConnectionInfo().