PHP Fatal error: Class 'Database' not found in dbtng/dbtng.module on line 788 can occur if a module with a lower weight attempts to use dbtng database functions within hook_boot because the autoloader function for dbtng has not yet been registered. In particular, bakery does this and it causes a fatal error.

CommentFileSizeAuthor
#1 dbtng-update_module_weight-1485646-1.patch577 bytespdrake

Comments

pdrake’s picture

Status: Active » Needs review
StatusFileSize
new577 bytes

This patch sets the module weight to -100 which matches the autoload module.

mikey_p’s picture

Thanks, I'll try to roll this into the next release, should be taking place sometime within the next week or so (I'll be rsyncing with latest D7 code at the same time).

mikey_p’s picture

Assigned: Unassigned » mikey_p

BTW, I'm really surprised to hear that Bakery is using this. I flipped through all the Bakery code on d.o and couldn't find any calls to DBTNG code, is that in special branch, or new patch?

pdrake’s picture

I should have been a little clearer - when bakery's hook_boot runs, if it needs to re-create the chocolate chip cookie, it ends up calling other functions, ultimately resulting in _menu_check_access being called. From there, any of a number of modules could end up using dbtng. In my specific case, the D6 og user access backport uses dbtng. Does that make sense?

marvil07’s picture

I see this error on versioncontrol-6.x-2.x testbot results, i.e. http://qa.drupal.org/pifr/test/63108
Sadly, I can not reproduce it locally, but testbot consistently output this error on that branch.

It would be great to know if this can fix it.

marvil07’s picture

The error I mentioned is because of #1843018: Run hook_boot for installed modules on setUp(), and after reproducing locally, the patch does not fix it(my case which is not the original one, so leaving status).

apotek’s picture

Isn't the answer here to add all the necessary dbtng class files to the files[] array in dbtng.info?

I was having trouble using db_or (Class not found) until I did this:

+ files[] = database/query.inc

Ignore that. I just realized latest code no longer uses autoload.