Bug in pChart library - Piwik 3.0.1 + PHP 7.1.1 Win64

I have installed Piwik version 3.0.1 in a Windows box, running it within Apache 2.4.25 x64 and PHP 7.1.1 VC14 x64 TS.
When downloding a PDF report that contains graphs (i.e. there is some data to report) the browser shows only the following error:
Piwik encoutered an error: Cannot use string offset as an array (which lead to: Cannot use string offset as an array)

I debuged Piwik with xDebug and in the end the error comes from pData.php file (within pChart library) at line 80 that reads
$this->Data[“Axis”][0][“Display”] = AXIS_FORMAT_DEFAULT;
I am guessing the problem is because Data is initialised as “” a few lines above this one. Seems like in PHP 7 that is not allowed anymore. Or probably first $this->Data[“Axis”] must be initialized as an array. I am not a PHP guru, I am only guessing here. I will appriciate if someone can point out the fix for this.

Note that if no graph is to be generated then the report is created correctly.

Thanks in advance!

Thank you! In the German Section of this Forum, there are at least two other users with this problem. Now we know, what it is and how to handle it.
I am sure, there will be a solution soon…

I have the same problem.
IIS8.5, PHP7.1, Piwik 3.0.2
Good to read that I can just switch off the graphics to get the reports out.
Thanks, and waiting for the eventual sollution of course.

I experience the same issue.

Piwik 3.0.2
PHP 7.1 x64
Apache 2.4 x64
Windows 2008 R2

please keep me updated when fix is already available.

Hi everyone
I faced the same issue.
I was digging into the code a little bit and this issue is caused by PHP 7.1 and the changed behavior of type conversion and the unavailability of the empty bracket operator.

Note: As of PHP 7.1.0, applying the empty index operator on a string throws a fatal error. Formerly, the string was silently converted to an array.
(taken from PHP: Arrays - Manual)

Actually, a code change needs to be implemented, which is replacing [] with corresponding array_push calls (ref. PHP: array_push - Manual).
I have tested the implementation in libs\pChart\class\pData.class.php and it helped to fix the error message, but charts haven’t been displayed yet (assuming that other components are involved as well).

#example modification in pData.class.php:
###in construct:
$this->Data = array();
####replace empty bracket operator by array_push:
$this->Data["Series"][$SerieName]["Data"][] = $Value;
array_push($this->Data["Series"][$SerieName]["Data"], $Value);


We will address this issue hopefully in the next version. Please stay tuned/ watch this: Running the archive via cron will result often in errors "Illegal string offset 'XAxisDisplay' 'XAxisFormat' " · Issue #11116 · piwik/piwik · GitHub

and post there any problem you experience that is not yet mentioned. this will help us

1 Like

The bug is killed with update onto 3.0.3.