Sparklines are gone

Ever since upgrading to 1.2, sparklines fail to be generated.
I’m suspecting a permission issue somewhere, but I wasn’t able to pinpoint it.

Which folder needs which permissions for sparklines to work?

From reading the FAQ, it seems one reason they cannot be displayed is if GD doesn’t work anymore, but based on various tests, it seems GD is working just fine.

You can do right click on the sparkline, “view image” and see if there is an error?

View image only works in Firefox and shows this:

The image “https://www.domain.com/subfolder/index.php?module=VisitsSummary&action=getEvolutionGraph&idSite=1&period=week&date=2010-08-30,2011-03-27&viewDataTable=sparkline&columns=nb_visits” cannot be displayed, because it contains errors.

If you save the file and open it with a text editor do you see any message?

In the text editor, I see something that looks like a PNG, but with a lot of extra characters. It’s similar to what you see with a utf-8 conversion gone bad.
It starts with


ʐNG

instead of the usual


‰PNG

Could be Firefox that saved it in a weird way though…
Edit: Similar file when saving with Chrome

Sparklines are generated in the fly. afaik there’s no temporary file.

I’m guessing there’s some on-the-fly compression in your apache/php configuration.

Disabling compression via htaccess makes it worse. Piwik is not able to load assets any more. I get this in Chrome:


Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error.

What was the compression setting you used in .htaccess?

I used this:


php_value zlib.output_compression 0

If you change the zlib.output_compression, you have to delete the files in tmp/assets/.

I deleted both the files in tmp/assets and in tmp/templates_c, but although new files are generated, the browsers still complain about them.
I’ll recompile PHP just to be sure, but this wasn’t happening before 1.2, so I’m trying to figure out what changed besides Piwik.

I’ve just tried with a freshly compiled PHP and cleared tmp folders and got the same result.
Sessions are in memcache and APC is in use.

Closer inspection gave me this:
Resource interpreted as Image but transferred with MIME type text/html

The sparkline library explicitly sets the content-type to image/png.

Can you check your web server error log and see if PHP is logging any notices or warnings?

Indeed, the content-type error was related to another element:
https://www.domain.com/piwik/index.php?module=CoreHome&action=index&date=2011-03-22&period=day&idSite=12

My problem is that there is nothing special in the logs…
All I see is that Apache is complaining about a missing favicon.ico at the root level, but piwik is installed in a folder.

This is the HTML for a broken picture:


<img class="sparkline" alt="" src="?module=VisitsSummary&action=getEvolutionGraph&idSite=12&period=day&date=2011-02-21,2011-03-22&viewDataTable=sparkline&columns=nb_visits" width="100" height="25">

Everything else seems to be working fine (but it’s Flash based) apart from ClickHeat, but it’s a different matter.

It turns out that I introduced a BOM in a plugin I was editing.

If someone runs into a similar problem, you can use this to find the offending files:


grep -rl $'\xEF\xBB\xBF' .

Thank you to vipsoft for finding where the problem came from.

You’re welcome.

p.s. you can lower the number of false positives by adding a caret to the pattern, e.g.,

^\xEF\xBB\xBF

.

Oh, yeah…I had that in my find and replace, but not in this one :smiley:

[quote=Anthon]
You’re welcome.

p.s. you can lower the number of false positives by adding a caret to the pattern, e.g.,

^\xEF\xBB\xBF

.[/quote]

You have to wonder how people figure these little things out. Great tip.

[quote=MadTony]
You have to wonder how people figure these little things out. Great tip.[/quote]
They read nice articles such as this one :slight_smile:
http://www.cyberciti.biz/faq/grep-regular-expressions/