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

tr’s picture

The "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.

tr’s picture

Status: Active » Postponed (maintainer needs more info)
longwave’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No feedback, closing.

kennethdd2’s picture

Version: 7.x-3.0-rc3 » 7.x-3.0-rc4
Status: Closed (cannot reproduce) » Active

Issue 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

longwave’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

Cannot 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.

kennethdd2’s picture

Thank 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.

longwave’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No further info provided, closing.

kennethdd2’s picture

Issue 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.

jsheffers’s picture

I 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?

amateljan’s picture

I 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.

creatile’s picture

I 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

Nicolas Pham-Dinh’s picture

Same 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:

  // Kick 'em to the curb. >:)
  _uc_file_download_redirect($user->uid);

  drupal_exit();
}
milovan’s picture

Just to confirm, drupal_exit() fix works. It should be included in next UC release IMO.

milovan’s picture

Can 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:

Fix in: ubercart/uc_file/uc_file.pages.inc
Line: 225
Add: drupal_exit();
After:
// Kick 'em to the curb. >:)
_uc_file_download_redirect($user->uid);
milovan’s picture

Status: Closed (cannot reproduce) » Needs review
longwave’s picture

Category: support » bug
Status: Needs review » Fixed

Fix 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.

milovan’s picture

Thanks a lot!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.