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.
When calling drupal_access_denied in the flow of a page callback, you can get "headers already sent" type errors.
This was flooding my watchdog table bigtime (because of unfriendly bots)
Similar issues have been fixed in core recently: http://drupalcode.org/project/drupal.git/commit/257fac8
note, this is not a duplicate for #1399636: Warning: Cannot modify header information - headers already sent em drupal_send_headers() ...
Patch will follow
Comment | File | Size | Author |
---|---|---|---|
#8 | print-2257075-8.patch | 1.26 KB | SpadXIII |
Comments
Comment #1
rv0 CreditAttribution: rv0 commentedPatch seems to fix it, based on the similar fixes in core (see above)
Comment #2
rudiedirkx CreditAttribution: rudiedirkx commentedAlmost, but not quite.
_print_generate_path()
does the same. It checks forMENU_NOT_FOUND
andMENU_ACCESS_DENIED
, but doesn't handle it well:I did the same there and that works: replace
return FALSE
withdrupal_exit()
.It's very strange that
_print_generate_path()
even callsdrupal_not_found()
... This is a helper function that should be callable from anywhere, it shouldn't alter the request. But since it does that anyway, I think this is the solution.Comment #3
rudiedirkx CreditAttribution: rudiedirkx commentedSince 2.x is the active branch, and it's still a bug in 2.0.
Comment #4
rudiedirkx CreditAttribution: rudiedirkx commentedAnd the patch against 2.x-dev
Comment #5
rudiedirkx CreditAttribution: rudiedirkx commentedComment #6
interdruper CreditAttribution: interdruper commented#4 works for me. Thx!
Comment #7
alcroito CreditAttribution: alcroito commentedProviding a more complete patch for 1.x version of the module, in case anyone needs it.
Comment #8
SpadXIII CreditAttribution: SpadXIII commentedAdded another set of drupal_exit()'s in _print_generate_node() where the same not_found/access_denied were triggered to the patch in #4.
Other than that, works as expected!
Comment #9
joewhitsitt#8 works for me. thank you!
Comment #10
rudiedirkx CreditAttribution: rudiedirkx commentedAnyone, please commit!
Comment #11
rjacobs CreditAttribution: rjacobs commentedI'm hiding all but the most recent patch in hopes that speeds-up the review.
Also, as annoying as the bug is I'm not sure it qualifies as "critical" as I don't think it leads to instability or data loss. So "major" may be most appropriate. That's probably splitting hairs though. Either way hopefully a maintainer can have a look here.
Comment #12
webservant316 CreditAttribution: webservant316 commented#8 works for me. thanks! yes lets get this committed!
Comment #13
rv0 CreditAttribution: rv0 at Coworks.be commentedbump #8
Comment #14
Rob_Feature CreditAttribution: Rob_Feature commentedyup, all good on my end with the patch in #8. I messaged the maintainer to see if we can get this committed.
Comment #16
jcnventura CreditAttribution: jcnventura commentedThanks!
Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commentedWill this be backported to 7.x-1.3?
Comment #18
jcnventura CreditAttribution: jcnventura commentedIt probably makes some sense to port it back to 7.x-1.x.. But you should really move away from that branch.
Comment #19
Anonymous (not verified) CreditAttribution: Anonymous commentedHere's a fix for 7.x-1.x. node/2012852
Comment #20
jcnventura CreditAttribution: jcnventura commentedI've deprecated the 7.x-1.x-dev branch.