Today was a fun day. Apparently if permissions are not set up properly on the files you upload to the "downloads" directly then ubercart starts an endless loop of feof, fopen, fread errors that are all being posted to the watchdog table.

Once the permissions are fixed you don't have an issue but the errors still post. Anyway, i recommend making a minor change to the uc_file.pages.inc around line 322ish in ubercart 2.3

CURRENT CODE:

// Open the file and seek to starting byte
  $fp = fopen($file_user->full_path, 'rb');
  fseek($fp, $seek_start);

  // Start buffered download
  while (!feof($fp)) {

    // Reset time limit for large files
    set_time_limit(0);

    // Push the data to the client.
    print(fread($fp, UC_FILE_BYTE_SIZE));
    flush();
    ob_flush();
  }

  // Finished serving the file, close the stream and log the download to the user table
  fclose($fp);

NEW CODE:

// Open the file and seek to starting byte
if($fp = fopen($file_user->full_path, 'rb')) {
		fseek($fp, $seek_start);
	
		// Start buffered download
		while (!feof($fp)) {
	
			// Reset time limit for large files
			set_time_limit(0);
	
			// Push the data to the client.
			print(fread($fp, UC_FILE_BYTE_SIZE));
			flush();
			ob_flush();
		}
	
		// Finished serving the file, close the stream and log the download to the user table
		fclose($fp);
}

a minor change but at least it checks to make sure the file can be opened before the loop starts

Comments

longwave’s picture

tr’s picture

Version: 6.x-2.3 » 7.x-3.x-dev
Status: Active » Needs work

Bumping up to current version of Ubercart for consideration.

Anyone want to write a patch for this?

longwave’s picture

This function should probably be rewritten based on file_transfer() in core: http://api.drupal.org/api/drupal/includes!file.inc/function/file_transfer/6

longwave’s picture

Status: Needs work » Fixed

Fixed in both branches by simply changing is_file() to is_readable() in _uc_file_download_validate().

Status: Fixed » Closed (fixed)

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