@mattab opened this Issue on May 15th 2014 Member

This was a bug reported in the Piwik forums.

from API request: index.php?module=API&method=API.get&idSite=1&period=day&date=last1000&format=php&token_auth=<token>&trigger=archivephp. Response was '

Notice: Undefined index: 2011-08-18 in /var/www/vhosts/piwik.harrison.neadwerx.com/piwik/plugins/API/API.php on line 493

@tsteur commented on May 21st 2014 Member

Tried to reproduce but couldn't. Tried with different dates, different formats, different idSites,... I could add a simple check whether the key exists and continue if not (as it does not make sense to merge tables when there is no second table). But then we don't know why there is no matching key in the second table at all which could be actually a bug. Will unassign me again.

+                if (!array_key_exists($index, $subTables2)) {
+                    continue;
+                }
@mattab commented on June 2nd 2014 Member

Bug was reproduced on demo, so hopefully we can find out the original cause, on this piwik instance! Increasing priority (because it fails the crontab script)

@mattab commented on June 20th 2014 Member

Maybe this bug only occurs at the end of the month? Somehow it didn't happen again. It happened only once on the demo on May 31st.

@mattab commented on July 1st 2014 Member

happened again today on demo, here is the log:

Notice:</strong> <em>Undefined index: 2014-05</em> in <strong>/home/piwik-demo/www/demo.piwik.org/plugins/API/API.php</strong> on line <strong>494</strong> <br /><br />Backtrace --&gt;<div style="font-family:Courier;font-size:10pt"><br />
 <a href='/0'>#0</a>  Piwik\Error::errorHandler(...) called at [/home/piwik-demo/www/demo.piwik.org/plugins/API/API.php:494]<br /> 
<a href='/1'>#1</a>  Piwik\Plugins\API\API->mergeDataTables(...) called at [/home/piwik-demo/www/demo.piwik.org/plugins/API/API.php:478]<br /> <a href='/2'>#2</a>  Piwik\Plugins\API\API->get(...) called at [:]<br /> 
<a href='/3'>#3</a>  call_user_func_array(...) called at [/home/piwik-demo/www/demo.piwik.org/core/API/Proxy.php:209]<br /> 
<a href='/4'>#4</a>  Piwik\API\Proxy->call(...) called at [/home/piwik-demo/www/demo.piwik.org/core/API/Request.php:215]<br /> 
<a href='/5'>#5</a>  Piwik\API\Request->process(...) called at [/home/piwik-demo/www/demo.piwik.org/plugins/API/Controller.php:31]<br /> 
<a href='/6'>#6</a>  Piwik\Plugins\API\Controller->index(...) called at [:]<br />  
<a href='/7'>#7</a>  call_user_func_array(...) called at [/home/piwik-demo/www/demo.piwik.org/core/FrontController.php:502]<br /> 
<a href='/8'>#8</a>  Piwik\FrontController->doDispatch(...) called at [/home/piwik-demo/www/demo.piwik.org/core/FrontController.php:83]<br /> 
<a href='/9'>#9</a>  Piwik\FrontController->dispatch(...) called at [/home/piwik-demo/www/demo.piwik.org/core/dispatch.php:34]<br /> 
<a href='/10'>#10</a>  require_once(...) called at [/home/piwik-demo/www/demo.piwik.org/index.php:47]<br /> 
<a href='/11'>#11</a>  require_once(...) called at [/home/piwik-demo/www/demo.piwik.org/core/CliMulti/RequestCommand.php:53]<br /> 
<a href='/12'>#12</a>  Piwik\CliMulti\RequestCommand->execute(...) called at [/home/piwik-demo/www/demo.piwik.org/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252]<br /> 
<a href='/13'>#13</a>  Symfony\Component\Console\Command\Command->run(...) called at [/home/piwik-demo/www/demo.piwik.org/vendor/symfony/console/Symfony/Component/Console/Application.php:887]<br /> 
<a href='/14'>#14</a>  Symfony\Component\Console\Application->doRunCommand(...) called at [/home/piwik-demo/www/demo.piwik.org/vendor/symfony/console/Symfony/Component/Console/Application.php:193]<br /> 
<a href='/15'>#15</a>  Symfony\Component\Console\Application->doRun(...) called at [/home/piwik-demo/www/demo.piwik.org/core/Console.php:64]<br /> 
<a href='/16'>#16</a>  Piwik\Console->doRun(...) called at [/home/piwik-demo/www/demo.piwik.org/vendor/symfony/console/Symfony/Component/Console/Application.php:124]<br /> 
<a href='/17'>#17</a>  Symfony\Component\Console\Application->run(...) called at [/home/piwik-demo/www/demo.piwik.org/console:31
@elpollodiablo commented on July 13th 2014

It happened again for me today with 2.4.1

edit: log:

Notice: Undefined index: 2013-07-13 in /srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/plugins/API/API.php on line 506 

Backtrace -->

<a href='/0'>#0</a> Piwik\Error::errorHandler(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/plugins/API/API.php:506]
<a href='/1'>#1</a> Piwik\Plugins\API\API->mergeDataTables(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/plugins/API/API.php:490]
<a href='/2'>#2</a> Piwik\Plugins\API\API->get(...) called at [:]
<a href='/3'>#3</a> call_user_func_array(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/core/API/Proxy.php:209]
<a href='/4'>#4</a> Piwik\API\Proxy->call(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/core/API/Request.php:215]
<a href='/5'>#5</a> Piwik\API\Request->process(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/plugins/API/Controller.php:31]
<a href='/6'>#6</a> Piwik\Plugins\API\Controller->index(...) called at [:]
<a href='/7'>#7</a> call_user_func_array(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/core/FrontController.php:531]
<a href='/8'>#8</a> Piwik\FrontController->doDispatch(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/core/FrontController.php:84]
<a href='/9'>#9</a> Piwik\FrontController->dispatch(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/core/dispatch.php:34]
<a href='/10'>#10</a> require_once(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/index.php:47]
<a href='/11'>#11</a> require_once(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/core/CliMulti/RequestCommand.php:53]
<a href='/12'>#12</a> Piwik\CliMulti\RequestCommand->execute(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252]
<a href='/13'>#13</a> Symfony\Component\Console\Command\Command->run(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/vendor/symfony/console/Symfony/Component/Console/Application.php:887]
<a href='/14'>#14</a> Symfony\Component\Console\Application->doRunCommand(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/vendor/symfony/console/Symfony/Component/Console/Application.php:193]
<a href='/15'>#15</a> Symfony\Component\Console\Application->doRun(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/core/Console.php:64]
<a href='/16'>#16</a> Piwik\Console->doRun(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/vendor/symfony/console/Symfony/Component/Console/Application.php:124]
<a href='/17'>#17</a> Symfony\Component\Console\Application->run(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/console:31]
@elpollodiablo commented on July 14th 2014

Ok, got it again, this time in the segment processing. But I noticed something. Yesterday, when it broke during the normal reports archiving, it crossed a date change:

INFO CoreConsole[2014-07-12 21:53:54] [f2dfb] Starting Piwik reports archiving...
ERROR CoreConsole[2014-07-13 06:59:13] [f2dfb] Got invalid response from API request: 

then when I started it again yesterday, the normal reports archiving executed, but the segments didn't:

INFO CoreConsole[2014-07-13 12:13:05] [52324] Starting Piwik reports archiving...
INFO CoreConsole[2014-07-13 21:20:45] [52324] Will pre-process the following 11 Segments for this website (id = 1): pageUrl=@%2Feveryone%2Ftv, pageUrl=@%2Ffof
, pageUrl=@%2Ffriends%2Ftv, visitDuration>=600, referrerName=<a class='mention' href='https://github.com/facebook'>@facebook</a>.com, daysSinceFirstVisit>=30, daysSinceFirstVisit>=60, daysSinceFirstVisit>=90, referre
rName=<a class='mention' href='https://github.com/reddit'>@reddit</a>.com, referrerName=<a class='mention' href='https://github.com/tumblr'>@tumblr</a>.com, referrerName=<a class='mention' href='https://github.com/twitter'>@twitter</a>.com
ERROR CoreConsole[2014-07-14 21:01:57] [52324] Got invalid response from API request:
...
Notice: Undefined index: 2013-07-14 in /srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/plugins/API/API.php

again, crossing the date. Funny thing: the notice in the segment processing did not stop the archiving process. The during the normal reports archiving did.

I'd venture a guess that there's some "now() - 365" being used somewhere that changes with a date change and leads to unexpected results. My php fu isn't good enough though to debug this situation properly :/

@mattab commented on August 2nd 2014 Member

The bug occurs when the archive processing starts on a given day, and the process takes long time, and overlaps on to the next day. Then in the code date() functions are called on this new day. But the datatable processed didn't contain this day yet (since it started yesterday). the datatable key for "today" is undefined. I think in this case it's fine to simply put a check as @tsteur suggested.

This Issue was closed on August 2nd 2014
Powered by GitHub Issue Mirror