Update 1.6 to 1.7 API fatal error


#1

Hi,

i am using Piwik on a server for several websites and i recently
updated it from version 1.6 to 1.7.

I used the build-in update functionality and no error messages showed up during the update.

But since i updated, the page with the API does not work.
( Link to page: index.php?module=API&action=listAllAPI )
It shows the following error message:

Fatal error: Cannot access self:: when no class scope is active in /…/core/API/Proxy.php on line 326

I already searched for the error, but it seems i am the only one having this problem. So if anyone knows the answer or has an idea what could be wrong please post here.

Thank you in advance!


(Peterbo) #2

Hi,

Please download Piwik and upload it again to your server. I think there must have been an issue while the update was running. Make sure, you upload the files in binary-mode. If this does not solve the issue, please report back here.


#3

Hi everybody.

Same problem here after an upgrade. So I downloaded piwik 1.7, extract it (and overwrite the previous 1.7). Same problem.

PHP 5.1.6 (php-5.1.6-27.el5_7.5.rpm)

Any Idea ?


(Matthieu Aubry) #4

There is no “self::” in line 326 in the PRoxy.php file in 1.7 — what is this line in your version of the file on your server?


#5

Hi,

for me the message is
"Fatal error: Cannot access self:: when no class scope is active in /var/www/html_piwik/core/API/Proxy.php on line 326"
when I try to create a pdf report.

and the line is :

[root@applisdsi ~]# cat -n /var/www/html_piwik/core/API/Proxy.php|grep 326 -A2 -B2
324 if($parameter->isDefaultValueAvailable())
325 {
326 $defaultValue = $parameter->getDefaultValue();
327 }
328


(Matthieu Aubry) #6

Sorry I don’t know how to fix this error in this case. Can you try: var_dump($parameter); at line 325 ?

To fix this issue, I suggest upgrading PHP to a newer version. I think it might be a PHP bug with your version.


(vipsoft) #7

If you have some opcode caching, you may have to restart the web server.


#8

here it is :

object(ReflectionParameter)#170 (1) { [“name”]=> string(7) “emailMe” } object(ReflectionParameter)#171 (1) { [“name”]=> string(16) “additionalEmails” } object(ReflectionParameter)#164 (1) { [“name”]=> string(7) “emailMe” } object(ReflectionParameter)#172 (1) { [“name”]=> string(16) “additionalEmails” } object(ReflectionParameter)#172 (1) { [“name”]=> string(6) “idSite” } object(ReflectionParameter)#164 (1) { [“name”]=> string(6) “period” } object(ReflectionParameter)#165 (1) { [“name”]=> string(8) “idReport” } object(ReflectionParameter)#166 (1) { [“name”]=> string(37) “ifSuperUserReturnOnlySuperUserReports” } object(ReflectionParameter)#164 (1) { [“name”]=> string(6) “idSite” } object(ReflectionParameter)#172 (1) { [“name”]=> string(8) “language” } object(ReflectionParameter)#167 (1) { [“name”]=> string(10) “outputType” } object(ReflectionParameter)#168 (1) { [“name”]=> string(6) “period” } object(ReflectionParameter)#169 (1) { [“name”]=> string(12) “reportFormat” } object(ReflectionParameter)#170 (1) { [“name”]=> string(22) “aggregateReportsFormat” } object(ReflectionParameter)#168 (1) { [“name”]=> string(6) “period” } object(ReflectionParameter)#167 (1) { [“name”]=> string(4) “date” } object(ReflectionParameter)#173 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#178 (1) { [“name”]=> string(7) “columns” } object(ReflectionParameter)#166 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#178 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#166 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#178 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#166 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#178 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#166 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#178 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#190 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#183 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#189 (1) { [“name”]=> string(24) “hideFutureHoursWhenToday” } object(ReflectionParameter)#252 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#255 (1) { [“name”]=> string(7) “columns” } object(ReflectionParameter)#250 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#251 (1) { [“name”]=> string(8) “expanded” } object(ReflectionParameter)#254 (1) { [“name”]=> string(10) “idSubtable” } object(ReflectionParameter)#253 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#252 (1) { [“name”]=> string(8) “expanded” } object(ReflectionParameter)#255 (1) { [“name”]=> string(10) “idSubtable” } object(ReflectionParameter)#250 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#251 (1) { [“name”]=> string(8) “expanded” } object(ReflectionParameter)#254 (1) { [“name”]=> string(10) “idSubtable” } object(ReflectionParameter)#252 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#251 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#254 (1) { [“name”]=> string(8) “expanded” } object(ReflectionParameter)#255 (1) { [“name”]=> string(10) “idSubtable” } object(ReflectionParameter)#253 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#254 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#255 (1) { [“name”]=> string(8) “expanded” } object(ReflectionParameter)#252 (1) { [“name”]=> string(10) “idSubtable” } object(ReflectionParameter)#250 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#255 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#252 (1) { [“name”]=> string(8) “expanded” } object(ReflectionParameter)#253 (1) { [“name”]=> string(10) “idSubtable” } object(ReflectionParameter)#251 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#347 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#350 (1) { [“name”]=> string(11) “typeReferer” } object(ReflectionParameter)#345 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#346 (1) { [“name”]=> string(8) “expanded” } object(ReflectionParameter)#350 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#345 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#346 (1) { [“name”]=> string(8) “expanded” } object(ReflectionParameter)#350 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#345 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#346 (1) { [“name”]=> string(8) “expanded” } object(ReflectionParameter)#350 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#345 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#346 (1) { [“name”]=> string(8) “expanded” } object(ReflectionParameter)#350 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#345 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#350 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#345 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#350 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#345 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#490 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#481 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#490 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#632 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#629 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#632 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#629 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#622 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#681 (1) { [“name”]=> string(7) “columns” } object(ReflectionParameter)#681 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#718 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#720 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#718 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#720 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#718 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#720 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#718 (1) { [“name”]=> string(7) “segment” } object(ReflectionParameter)#1131 (1) { [“name”]=> string(9) “graphType” } object(ReflectionParameter)#1130 (1) { [“name”]=> string(10) “outputType” }


#9

httpd restart has been done… No changes. No e-accelerator, or any other accelerator installed.


#10

So,

i found the problem.

I have also PHP 5.1.6 installed and can not debug with it, that’s why it took me some time.

In my Piwik installation the problem was the declaration of one function in the class Piwik_ImageGraph_API.
In the following function you see two default parameters with “self::” in it. These two parameters cause the error.

public function get($idSite, $period, $date, $apiModule, $apiAction, $graphType = false,
$outputType = self::GRAPH_OUTPUT_INLINE,
$column = false, $showMetricTitle = true, $width = false, $height = false,
$fontSize = self:: DEFAULT_FONT_SIZE,
$aliasedGraph = true, $colors = false)

I bypassed the error with a change of the Proxy.php File ( /…/core/API/Proxy.php ).
I know that it is not a nice solution, but it works for me. So if you are interested here is the code:

$defaultValue = $this->noDefaultValue;
if($parameter->isDefaultValueAvailable())
{
if( $class == “Piwik_ImageGraph_API” && $method->getName() == “get” ) {
if( $parameter->getName() == “outputType” ) {
$defaultValue = Piwik_ImageGraph_API::GRAPH_OUTPUT_INLINE;
} elseif( $parameter->getName() == “fontSize” ) {
$defaultValue = Piwik_ImageGraph_API:: DEFAULT_FONT_SIZE;
} else {
$defaultValue = $parameter->getDefaultValue();
}
} else {

$defaultValue = $parameter->getDefaultValue();
}
}

This Code is a fragment from the function loadMethodMetadata. The changes i made are in bolt.
With the changes the API Page in my Piwik installation is working.

Also thank you all for your answers!


(Matthieu Aubry) #11

Thank you for the report and finding the fix.
I have committed a “better” fix than yours - can you please revert yours and try this one instead? http://dev.piwik.org/trac/changeset/5868

please confirm here or in the ticket that this fix works. Thanks!


#12

Fine !!!
It works.

Thanks.


#13

@matt

I also tried your fix and it works.

You are right your fix is better and easier!