Affecting all versions of DRUPAL!
(Patch is for HEAD)

When e.g drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH) is called twice (e.g by statistic and by another custom module) _drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) is also executed.

It took me 4 hours to find this bug:I got "Cannot modify header information -..." at loading pages from cache. It turned out that after serving cached pages DRUPAL_BOOTSTRAP_FULL was also executed.

Although it affects all version of drupal, it affects few users, since not many contrib modules calls drupal_bootstrap() with a $phase smaller than DRUPAL_BOOTSTRAP_FULL.

CommentFileSizeAuthor
#8 bootstrap_26.patch986 byteskeve
#6 bootstrap_25.patch1012 byteskeve
#4 bootstrap_24.patch1012 byteskeve
bootstrap_22.patch987 byteskeve

Comments

keve’s picture

Any opinions?

Delete Me-1’s picture

bump....

ChrisKennedy’s picture

Status: Needs work » Needs review

Yep, the bootstrap handling needs a bit of work. This is a good step. I have a few minor suggestions - take em or leave em.

I think the comment would be clearer if it read: "// Stop early if $phase was already executed."

It might also be clearer to change the IF logic to something like: if (empty($phases) || ($phase < min($phases)))

Then the comment might be best as "// Stop early if no phases are remaining or if $phase was already executed."

keve’s picture

StatusFileSize
new1012 bytes

I included your suggestions. Rerolled to head.

ChrisKennedy’s picture

That IF statement needs to be || instead of && so that it short circuits the min() - otherwise it will give an error.

keve’s picture

StatusFileSize
new1012 bytes

Woops. You are right. - Where was my mind? ;)

chx’s picture

Status: Needs review » Needs work

i do not like the implementation. Checking for emptiness is pointless, while will nicely FALSE . that min() defies the point of constants. Why not an in_array() ?

keve’s picture

Status: Needs work » Needs review
StatusFileSize
new986 bytes
mfer’s picture

I like this patch. If early phases have been executed you can still execute later ones. Yet, it returns when it's called into a phase that's already done.

Looks good to me and works.

ChrisKennedy’s picture

Status: Needs review » Reviewed & tested by the community
gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Patch looks good, committed!

Anonymous’s picture

Status: Fixed » Closed (fixed)