Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notice: Undefined index: 2011-08-18 in plugins/API/API.php on line 493 #5168

Closed
mattab opened this issue May 15, 2014 · 7 comments
Closed

Notice: Undefined index: 2011-08-18 in plugins/API/API.php on line 493 #5168

mattab opened this issue May 15, 2014 · 7 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Milestone

Comments

@mattab
Copy link
Member

mattab commented May 15, 2014

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
Copy link
Member

tsteur commented May 21, 2014

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
Copy link
Member Author

mattab commented Jun 2, 2014

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
Copy link
Member Author

mattab commented Jun 20, 2014

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
Copy link
Member Author

mattab commented Jul 1, 2014

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 />
 #0  Piwik\Error::errorHandler(...) called at [/home/piwik-demo/www/demo.piwik.org/plugins/API/API.php:494]<br /> 
#1  Piwik\Plugins\API\API->mergeDataTables(...) called at [/home/piwik-demo/www/demo.piwik.org/plugins/API/API.php:478]<br /> #2  Piwik\Plugins\API\API->get(...) called at [:]<br /> 
#3  call_user_func_array(...) called at [/home/piwik-demo/www/demo.piwik.org/core/API/Proxy.php:209]<br /> 
#4  Piwik\API\Proxy->call(...) called at [/home/piwik-demo/www/demo.piwik.org/core/API/Request.php:215]<br /> 
#5  Piwik\API\Request->process(...) called at [/home/piwik-demo/www/demo.piwik.org/plugins/API/Controller.php:31]<br /> 
#6  Piwik\Plugins\API\Controller->index(...) called at [:]<br />  
#7  call_user_func_array(...) called at [/home/piwik-demo/www/demo.piwik.org/core/FrontController.php:502]<br /> 
#8  Piwik\FrontController->doDispatch(...) called at [/home/piwik-demo/www/demo.piwik.org/core/FrontController.php:83]<br /> 
#9  Piwik\FrontController->dispatch(...) called at [/home/piwik-demo/www/demo.piwik.org/core/dispatch.php:34]<br /> 
#10  require_once(...) called at [/home/piwik-demo/www/demo.piwik.org/index.php:47]<br /> 
#11  require_once(...) called at [/home/piwik-demo/www/demo.piwik.org/core/CliMulti/RequestCommand.php:53]<br /> 
#12  Piwik\CliMulti\RequestCommand->execute(...) called at [/home/piwik-demo/www/demo.piwik.org/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252]<br /> 
#13  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 /> 
#14  Symfony\Component\Console\Application->doRunCommand(...) called at [/home/piwik-demo/www/demo.piwik.org/vendor/symfony/console/Symfony/Component/Console/Application.php:193]<br /> 
#15  Symfony\Component\Console\Application->doRun(...) called at [/home/piwik-demo/www/demo.piwik.org/core/Console.php:64]<br /> 
#16  Piwik\Console->doRun(...) called at [/home/piwik-demo/www/demo.piwik.org/vendor/symfony/console/Symfony/Component/Console/Application.php:124]<br /> 
#17  Symfony\Component\Console\Application->run(...) called at [/home/piwik-demo/www/demo.piwik.org/console:31

@mattab mattab added this to the 2.5.0 - Piwik 2.5.0 milestone Jul 8, 2014
@elpollodiablo
Copy link

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 -->

#0 Piwik\Error::errorHandler(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/plugins/API/API.php:506]
#1 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]
#2 Piwik\Plugins\API\API->get(...) called at [:]
#3 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]
#4 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]
#5 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]
#6 Piwik\Plugins\API\Controller->index(...) called at [:]
#7 call_user_func_array(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/core/FrontController.php:531]
#8 Piwik\FrontController->doDispatch(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/core/FrontController.php:84]
#9 Piwik\FrontController->dispatch(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/core/dispatch.php:34]
#10 require_once(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/index.php:47]
#11 require_once(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/core/CliMulti/RequestCommand.php:53]
#12 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]
#13 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]
#14 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]
#15 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]
#16 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]
#17 Symfony\Component\Console\Application->run(...) called at [/srv/app/piwik-2.4.1_RELEASE_2014-07-12_00.33.13.501466/console:31]

@elpollodiablo
Copy link

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=@facebook.com, daysSinceFirstVisit>=30, daysSinceFirstVisit>=60, daysSinceFirstVisit>=90, referre
rName=@reddit.com, referrerName=@tumblr.com, referrerName=@twitter.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
Copy link
Member Author

mattab commented Aug 2, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Projects
None yet
Development

No branches or pull requests

3 participants