Undefined offset: 4 in ArchiveProcessing\Day.php

Found another thread with a similar title, but that had a different offset # and php file associated with it. :frowning:

Was working fine until now; the only difference is that I assigned some custom variables in the tracker (but they weren’t showing any issues before this error showed up).

Notice: Undefined offset: 4 in D:\LCTSites\WebRoot\piwik\core\ArchiveProcessing\Day.php on line 668

Backtrace -->
#0 Piwik_ErrorHandler(…) called at [D:\LCTSites\WebRoot\piwik\core\ArchiveProcessing\Day.php:668]#1 Piwik_ArchiveProcessing_Day->updateInterestStats(…) called at [D:\LCTSites\WebRoot\piwik\plugins\CustomVariables\CustomVariables.php:165]#2 Piwik_CustomVariables->archiveDayAggregate(…) called at [D:\LCTSites\WebRoot\piwik\plugins\CustomVariables\CustomVariables.php:138]#3 Piwik_CustomVariables->archiveDay(…) called at [:]#4 call_user_func_array(…) called at [D:\LCTSites\WebRoot\piwik\libs\Event\Dispatcher.php:284]#5 Event_Dispatcher->postNotification(…) called at [D:\LCTSites\WebRoot\piwik\core\PluginsManager.php:609]#6 Piwik_PostEvent(…) called at [D:\LCTSites\WebRoot\piwik\core\ArchiveProcessing\Day.php:42]#7 Piwik_ArchiveProcessing_Day->compute(…) called at [D:\LCTSites\WebRoot\piwik\core\ArchiveProcessing.php:429]#8 Piwik_ArchiveProcessing->launchArchiving(…) called at [D:\LCTSites\WebRoot\piwik\core\Archive\Single.php:217]#9 Piwik_Archive_Single->prepareArchive(…) called at [D:\LCTSites\WebRoot\piwik\core\Archive\Single.php:246]#10 Piwik_Archive_Single->get(…) called at [D:\LCTSites\WebRoot\piwik\core\Archive\Single.php:492]#11 Piwik_Archive_Single->getDataTable(…) called at [D:\LCTSites\WebRoot\piwik\core\Archive.php:314]#12 Piwik_Archive::getDataTableFromArchive(…) called at [D:\LCTSites\WebRoot\piwik\plugins\CustomVariables\API.php:39]#13 Piwik_CustomVariables_API->getDataTable(…) called at [D:\LCTSites\WebRoot\piwik\plugins\CustomVariables\API.php:50]#14 Piwik_CustomVariables_API->getCustomVariables(…) called at [:]#15 call_user_func_array(…) called at [D:\LCTSites\WebRoot\piwik\core\API\Proxy.php:179]#16 Piwik_API_Proxy->call(…) called at [D:\LCTSites\WebRoot\piwik\core\API\Request.php:121]#17 Piwik_API_Request->process(…) called at [D:\LCTSites\WebRoot\piwik\core\ViewDataTable.php:391]#18 Piwik_ViewDataTable->loadDataTableFromAPI(…) called at [D:\LCTSites\WebRoot\piwik\core\ViewDataTable\HtmlTable.php:75]#19 Piwik_ViewDataTable_HtmlTable->main(…) called at [D:\LCTSites\WebRoot\piwik\core\Controller.php:146]#20 Piwik_Controller->renderView(…) called at [D:\LCTSites\WebRoot\piwik\plugins\CustomVariables\Controller.php:40]#21 Piwik_CustomVariables_Controller->getCustomVariables(…) called at [D:\LCTSites\WebRoot\piwik\plugins\CustomVariables\Controller.php:24]#22 Piwik_CustomVariables_Controller->index(…) called at [:]#23 call_user_func_array(…) called at [D:\LCTSites\WebRoot\piwik\core\FrontController.php:136]#24 Piwik_FrontController->dispatch(…) called at [D:\LCTSites\WebRoot\piwik\index.php:53]

Update to latest Piwik 1.6 before posting bug report please :slight_smile:

Upgraded and still getting the same error. I removed the section calling custom variables, tried again, no dice. Put them back in, still no change. This only happens when the day is set to today. The variables table itself still shows (below the 7 backtraces), but you can’t drill down to each variable. (If there’s a date range and it includes today, it doesn’t throw any errors, athough you still can’t expand the variable.)

New backtrace (repeats 6 times until offset=7):

Notice: Undefined offset: 1 in D:\LCTSites\WebRoot\piwik\core\ArchiveProcessing\Day.php on line 617

Backtrace -->
#0 Piwik_ErrorHandler(…) called at [D:\LCTSites\WebRoot\piwik\core\ArchiveProcessing\Day.php:617]#1 Piwik_ArchiveProcessing_Day->updateInterestStats(…) called at [D:\LCTSites\WebRoot\piwik\plugins\CustomVariables\CustomVariables.php:187]#2 Piwik_CustomVariables->archiveDayAggregate(…) called at [D:\LCTSites\WebRoot\piwik\plugins\CustomVariables\CustomVariables.php:156]#3 Piwik_CustomVariables->archiveDay(…) called at [:]#4 call_user_func_array(…) called at [D:\LCTSites\WebRoot\piwik\libs\Event\Dispatcher.php:284]#5 Event_Dispatcher->postNotification(…) called at [D:\LCTSites\WebRoot\piwik\core\PluginsManager.php:609]#6 Piwik_PostEvent(…) called at [D:\LCTSites\WebRoot\piwik\core\ArchiveProcessing\Day.php:42]#7 Piwik_ArchiveProcessing_Day->compute(…) called at [D:\LCTSites\WebRoot\piwik\core\ArchiveProcessing.php:440]#8 Piwik_ArchiveProcessing->launchArchiving(…) called at [D:\LCTSites\WebRoot\piwik\core\Archive\Single.php:224]#9 Piwik_Archive_Single->prepareArchive(…) called at [D:\LCTSites\WebRoot\piwik\core\Archive\Single.php:253]#10 Piwik_Archive_Single->get(…) called at [D:\LCTSites\WebRoot\piwik\core\Archive\Single.php:499]#11 Piwik_Archive_Single->getDataTable(…) called at [D:\LCTSites\WebRoot\piwik\core\Archive.php:316]#12 Piwik_Archive::getDataTableFromArchive(…) called at [D:\LCTSites\WebRoot\piwik\plugins\CustomVariables\API.php:39]#13 Piwik_CustomVariables_API->getDataTable(…) called at [D:\LCTSites\WebRoot\piwik\plugins\CustomVariables\API.php:50]#14 Piwik_CustomVariables_API->getCustomVariables(…) called at [:]#15 call_user_func_array(…) called at [D:\LCTSites\WebRoot\piwik\core\API\Proxy.php:179]#16 Piwik_API_Proxy->call(…) called at [D:\LCTSites\WebRoot\piwik\core\API\Request.php:121]#17 Piwik_API_Request->process(…) called at [D:\LCTSites\WebRoot\piwik\core\ViewDataTable.php:391]#18 Piwik_ViewDataTable->loadDataTableFromAPI(…) called at [D:\LCTSites\WebRoot\piwik\core\ViewDataTable\HtmlTable.php:75]#19 Piwik_ViewDataTable_HtmlTable->main(…) called at [D:\LCTSites\WebRoot\piwik\core\Controller.php:146]#20 Piwik_Controller->renderView(…) called at [D:\LCTSites\WebRoot\piwik\plugins\CustomVariables\Controller.php:40]#21 Piwik_CustomVariables_Controller->getCustomVariables(…) called at [:]#22 call_user_func_array(…) called at [D:\LCTSites\WebRoot\piwik\core\FrontController.php:132]#23 Piwik_FrontController->dispatch(…) called at [D:\LCTSites\WebRoot\piwik\index.php:53]

Can you please apply the following patch:


Index: plugins/CustomVariables/CustomVariables.php
===================================================================
--- plugins/CustomVariables/CustomVariables.php	(revision 5379)
+++ plugins/CustomVariables/CustomVariables.php	(working copy)
@@ -178,6 +178,7 @@
 			 
 			while($row = $query->fetch() )
 			{
+				var_dump($row);
 				// Handle case custom var value is empty
 				$row[$valueField] = $this->cleanCustomVarValue($row[$valueField]);

Then run archiving., it should output arrays on the screen. please paste the output here. thx!

Well, unfortunately the tracking doesn’t seem to be working… it’s not showing any hits from yesterday at all, let alone the custom variables. (I’m 99.9% sure we had hits yesterday.)

When I view data from last Friday, the visitor tracking is working, but the custom variables aren’t. (It’s on our local MediaWiki install, so I’m trying to count page edits by using “action” and “edit” and “action” and “submit.”) Only some date ranges are showing the custom variables.

/Edited/
Okay, so turns out if a particular custom variable is defined, it doesn’t track ANY data – vistors, page hits, etc… nada. Either that, or it’s breaking when more than one name is assigned to a variable…


piwikTracker.setCustomVariable(1,"action","edit","page");
piwikTracker.setCustomVariable(2,"action,"submit","page");

If I comment out the second line, everything’s peachy. However, I realized I need to track the “submit” action, as a person can go to the edit page but never make a change, yet it’ll still show up as a hit. Am I doing something wrong here?

If you find a bug, please try to produce a small piece of code that reproduces your bug in a new piwik install. Then we will replicate and fix or explain how it works, thanks!

Okay, I tried replicating it on a different MediaWiki site. (We can’t do another Piwik install, the network is pretty locked down here.)

I was able to get the custom variables to work, first variable is piwikTracker.setCustomVariable(1,“action”,“submit”,“page” ); [track page edit submissions]. On a whim, I put in piwikTracker.setCustomVariable(2,“title”,“portal”,“page” ); to see if it’d pick up whenever a portal was visited. (Not exactly accurate as I found that a search for “portal” will trigger a hit. :wink: I then changed the second variable to piwikTracker.setCustomVariable(2,“title”,“Special:UserLogin”,“page” ); to track logins, and that also worked… it shows both the old variable (portal) and new (Special:UserLogin) in the dashboard.

Is there any way I can delete the custom variables from the DB in the site that’s having issues? I’d like to clean them out and retry them… otherwise if I put in more than one variable, it doesn’t track at all.

/*edited to fix auto-smilie correct in code. */

What exact code do you use to track multiple pages, that does not work?

Try to put the same code in an empty HTML page, does it work?

If not, paste it here, thx

Okay, so when I first set up the variables, the tracking code looked like this…


<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://###.###.##/" : "http://###.###.###/" );
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E" ));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
[b]piwikTracker.setCustomVariable(1,"action,"edit","page" );[/b]
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://###.###.###/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>

I then realized the Custom Variable (bolded line) was incorrect, because that was tracking only when a user hit the “edit article.” (for example… from Wikipedia: Henry Karlsen - Wikipediaaction=edit ). However, this wasn’t the right variable to track, as a user can visit this page but not actually edit it. So instead, the name and value should have been from Henry Karlsen - Wikipediaaction=submit, since this is what actually submits the edited page.

I added the line piwikTracker.setCustomVariable(2,"action,“submit”,“page” ); under the first custom variable to see the difference between edit and submit:


...
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.setCustomVariable(1,"action,"edit","page" );
[b]piwikTracker.setCustomVariable(2,"action,"submit","page" );[/b]
piwikTracker.trackPageView();
...

That worked, so I decided to remove the first variable call since it wasn’t worth tracking. I left the index at “2,” and it stopped working entirely. (e.g., all visits stopped being tracked and “There is no data for this report” is displayed.)


...
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
[s]piwikTracker.setCustomVariable(1,"action,"edit","page" );[/s]
[b]piwikTracker.setCustomVariable(2,"action,"submit","page" );[/b]
piwikTracker.trackPageView();
...

After that, I then changed the index to “1” in hopes that it would fix it:


...
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.setCustomVariable(1,"action,"submit","page" );
piwikTracker.trackPageView();
...

Still broken. If I hit 100 different pages, nothing shows up in the page titles, entry pages, visitors – no hits at all. If I add “edit” back in, so it looks like this:


...
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.setCustomVariable(1,"action,"edit","page" );
piwikTracker.setCustomVariable(2,"action,"submit","page" );
piwikTracker.trackPageView();
...

it still doesn’t work. However, if I leave out the variables entirely, or leave “edit” in index 1 and remove the second “action” variable entirely, it’s fine and everything gets tracked.

I wouldn’t mind completely clearing out the existing custom variables stored in the database and starting fresh. How do I do this?

Can you try in a different browser ?

Alternatively, try in a white html page with nothing in it, does it work?

Okay, I ended up deleting the old stats from the DB and starting over… right now it works great, the original bug doesn’t show up and it’s tracking my variables.

One quick question – is there any way to use setCustomVariable with an exact string? I realized when a user logs in, it counts the submit since the URL has “submitlogin” in it… I just want to track “submit.”