Hi,
Thank you for the wonderful file download capability.
Everything is great, and user is able to download the file from user/%/purchased-files
When the user navigates to any other page after download error appears:
Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/sites/all/modules/ubercart/uc_file/uc_file.pages.inc:397) in drupal_send_headers() (line 1225 of /home/public_html/includes/bootstrap.inc).
and have found reference to this error, but all for D6.
Looking forward to any suggestion.
Comments
Comment #1
tr commentedThe "headers already sent" error in Drupal is usually caused by a theme template or custom module having whitespace or a ?> tag at the end. First thing to try is to switch to the default Bartik theme and see if you still get the error.
Comment #2
tr commentedComment #3
longwaveNo feedback, closing.
Comment #4
kennethdd2 commentedIssue is still present RC4. Tested with clean install of both Drupal 7.1 and the latest dev Drupal release using ubercart-7.x-3.0-rc4.tar.gz
Tested with bartik and with pixture_reloaded, same error.
Warning occurs after download of file via ubercart when user is changing/leaving account page or simply refreshing the page..
Appears to be related to output buffers.
I am checking files for ?> and white space
Specific message returned: (domain changed in message below to ...)
"Warning: Cannot modify header information - headers already sent by
(output started at /home/.../public_html/sites/all/modules/ubercart/uc_file/uc_file.pages.inc:396) in drupal_send_headers() (line 1225 of /home/.../public_html/includes/bootstrap.inc)."
Any tests or suggestions welcome.
Aside: I Cannot register/login at ubercart to post to their forums as their site cannot send email and I cannot contact maintainers via ubercart.org
Comment #5
longwaveCannot reproduce this on a fresh install. If this isn't theme related I think it must be due to a custom or contrib module that has whitespace after the closing ?> tag.
See http://drupal.org/node/1424 for more info on diagnosing this for your site.
Comment #6
kennethdd2 commentedThank you for the quick response. Checked the two files in question and no issues with php ?> oe white space.
Also tested with output buffering =0 and an apache restart and output buffering = off same results.
On your advice I will endeavor to identify which module(s) are causing the issue and follow up with results.
Comment #7
longwaveNo further info provided, closing.
Comment #8
kennethdd2 commentedIssue was finally resolved. Drupal 7, all modules, all themes actually work properly. Issue was related to VPS php configuration, php 5.3.8 and whm cpanel. The hosting company had locked down the configuration with output_buffering set to off and made it virtually impossible for the vps owners to turn it on. Once that was resolved the headers sent error went away.
Comment #9
jsheffers commentedI have this issue. I turned output buffering ON and it gets rid of the error, but it stops the file from being downloaded. Any ideas?
Comment #10
amateljan commentedI was also getting this error. It seemed to be resending the download headers on refresh or navigating to another page. If you downloaded two files in succession before refreshing/navigating elsewhere, you would get two errors. Looking at the file_transfer function in includes/file.inc led me to add a drupal_exit() call to the end of the _uc_file_download function in uc_file.pages.inc - which has solved the issue for me.
Comment #11
creatile commentedI have the same error message if you download a file and refresh the page user/2/purchased-files page
I have tested amateljan solution and added drupal_exit() on lien 226 in uc_file.page.inc
I t works now for me
Comment #12
Nicolas Pham-Dinh commentedSame exact error. I am trying to apply amateljan's solution but have no php knowledge yet. Do I just add 'drupal_exit()' on line 226? I assume not since I am getting a syntax error when attempting to access a user's file download page if I do so. Would ayone be kindly give more details on how this solution works? Thanks in advance!
Edit: Never mind. I figured it out by trial and error. Should look like this:
Comment #13
milovan commentedJust to confirm, drupal_exit() fix works. It should be included in next UC release IMO.
Comment #14
milovan commentedCan we open this and commit the change? Because the fix obviously works and so far it made no problems at all.
To remind, fix was:
Comment #15
milovan commentedComment #16
longwaveFix committed in http://drupalcode.org/project/ubercart.git/commitdiff/0a5db10
There is no point calling _uc_file_download_redirect() if a file was actually transferred, so I also moved that inside the else block that deals with error conditions.
Comment #17
milovan commentedThanks a lot!