Hi, and thank you for this module :)! I'm running it succesfully on many sites, it's been very usefull.

Yesterday I downloaded the 1.0 version, since I noticed support for private file systems was added recently. My intra site was using public file system, but I converted it to private. I created a separate "public" -folder for advagg.

I did encounter some problems during the process, which I was able to fix eventually. But I also noticed a small but annoying bug in advagg.module.
Basically I got this error for all or most of my files:

Warning: filesize() [function.filesize]: stat failed for somefolder/somefile.jpg in advagg_file_download() (line 3275 of /my_path/sites/default/modules/contrib/advagg/advagg.module).

This continued on pretty much all pages with attachments.

I looked at the function (which I think was added recently?):

/**
 * Implementation of hook_file_download().
 *
 * Return the correct headers for advagg bundles.
 */
function advagg_file_download($file, $type = '') {
  if (strpos($file, '/advagg_') !== 0) {
    $return = array(
      'Content-Length: ' . filesize($file),
      'Cache-Control: ' . 'max-age=31556926, public',
    );
 ...

.. and the culprit was clear: "strpos($file, '/advagg_') !== 0" is always true (..except, you know when). Meaning filesize() was run for all files, even those that were located elsewhere.

What you must have intented was:
... if (strpos($file, '/advagg_') !== false) { ...
Right?

I changed the "0" to "false" on my site, and my errors disappeared.

Sorry for the lack of patch, but this oneliner is probably easier to fix by hand :)

CommentFileSizeAuthor
#1 advagg-1193176-1.patch953 bytesmikeytown2

Comments

mikeytown2’s picture

Status: Needs work » Fixed
StatusFileSize
new953 bytes

committed this code, let me know if this doesn't fix it for you.

gg4’s picture

Echoing the :: Thanks :: and subscribing.

bibo’s picture

Thanks mikeytown2, works well :)

Peter Bowey’s picture

Refer #1

Working as expected, many thanks!

aschiwi’s picture

Worked for me too, thanks!

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