I haven't found a good reason to keep drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE) in init_theme. Maybe I'm missing something but the way the system is layed out DRUPAL_BOOTSTRAP_DATABASE is already executed before from the drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) in the index.php file. And the way drupal_bootstrap is constructed it loops and executes every phase until the requested phase has completed. So just because DRUPAL_BOOTSTRAP_DATABASE phase is being executed in theme.inc we execute DRUPAL_BOOTSTRAP_CONFIGURATION and DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE twice.
Patch attached.
| Comment | File | Size | Author |
|---|---|---|---|
| remove_drupal_bootstrap_from_init_theme.patch.txt | 486 bytes | Anonymous (not verified) |
Comments
Comment #1
Frando commentedNothing gets executed twice, as drupal_bootstrap is keeping a static array of bootstrap phases, and it will only execute phases that haven't been executed yet. So the overhead caused by this line is ridicolously minimal (think of one integer comparison).
So if we need to have bootstrapped drupal up until DRUPAL_BOOTSTRAP_DATABSE to init the the theme layer, why not call it?
It makes it possible to call init_theme from anywhere without having to worry about wether there is already a database connection available or not.
Comment #2
Frando commentedComment #3
Anonymous (not verified) commentedThe staticness of $phases is just to keep $phases from being initialized more than once. The code executes more than once from what I'm seeing.
And _drupal_bootstrap doesn't prevent the duplicate execution of conf_init and neither does conf_init.
Please correct me.
Comment #4
Anonymous (not verified) commentedI'm correcting myself: the array_shift causes the staticness of $phases to not loop through the arrays again.
Comment #5
RobRoy commented@earnie - Feel free to mark won't fix or by design once an issue is cleared up like this so it keeps the issue queue clean.
Comment #6
Anonymous (not verified) commentedI still think the patch needs applied. Each minuscule piece of irrelevant code speeds up the code by minuscule amounts. Leaving irrelevant code doesn't make since.
Comment #7
Anonymous (not verified) commentedComment #8
RobRoy commentedI think this line "It makes it possible to call init_theme from anywhere without having to worry about whether there is already a database connection available or not." means that it IS relevant. Marking by design, but feel free to re-open if you really want.
I think there are much better issues to focus on like this one: http://drupal.org/node/92630.