Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Statistics in sidepanel has stoped working
Hi. can anyone help please?
My statistics has just gone kaput! It followed closely after I I excluded guests from posting replies on the forum yesterday - Guest was the highest poster at that time. Today the statistics has vanished from the sidepanel. I get these error messages when I try to look at mods in the settings panel:
In particular, perhaps someone could explain what does Undefined Index means?
My statistics has just gone kaput! It followed closely after I I excluded guests from posting replies on the forum yesterday - Guest was the highest poster at that time. Today the statistics has vanished from the sidepanel. I get these error messages when I try to look at mods in the settings panel:
In particular, perhaps someone could explain what does Undefined Index means?
The statistics have been successfully reset
Notice: Undefined index: top_posting_user in /home/greenbui/public_html/newforum/extensions/Statistics/default.php on line 117
Notice: Undefined index: top_discussion_starter in /home/greenbui/public_html/newforum/extensions/Statistics/default.php on line 118
Notice: Undefined index: most_active_users in /home/greenbui/public_html/newforum/extensions/Statistics/default.php on line 121
0
This discussion has been closed.
Comments
top_posting_user => 1 => 1 => jimw => 118
top_discussion_starter => 1 => 2 => jimw => 17 => Klaus => 2
most_active_users => 1 => 3 => jimw => 621 => Klaus => 16 => Mohamed => 1
1179487368 => 0
So I re-uploaded the original and it came back on. what do you think caused this then?
Thanks again for your help.
I'm addicted to my statistics panel as it gives such me good feedback of the activity of the forum - how many posts in 24hrs etc.. it looked really dead when statistics was broken.
Thanks Jim.
The extension deletes the statistics file, then creates a new file and writes updated statistics into it. If one page load occurs immediately after another one, its possible that just after the first page load deletes the file, the second one tries to read the statistics and comes up with nothing. In the mean time, the first page load saves valid statistics just in time for the second page to delete it and save bad statistics.
One fix could be to write new statistics to a random file name, then rename the new file as the existing file once its known the new file is successfully written.
function SaveStatistics($Update) { $this->StatisticsFile = ($this->Now+300)."\n"; foreach($this->Statistics AS $key => $data) { if($Update == true) $data[0] = (ForceIncomingString("chkStatistic_".$key, "") == 0) ? "0" : "1"; if($data != $this->Statistics[0] && is_Array($data)) $this->StatisticsFile .= str_replace("\n", "", $key." => ".implode(" => ", $data))."\n"; } /* New code */ $File = $this->Context->Configuration['EXTENSIONS_PATH']."Statistics/options.inc" // write the contents to a temporary file $rand = $this->Context->Configuration['EXTENSIONS_PATH'].'Statistics/' . DefineVerificationKey() . '.tmp'; $temp = @fopen($rand, 'w'); if ($temp) { if (!@fwrite($temp, $this->StatisticsFile)) $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrWriteFile")); } else { $this->Context->WarningCollector->Add(str_replace("//1", $File, $this->Context->GetDefinition("ErrOpenFile"))); } fclose($temp); // If no errors, copy the temporary file over top of the existing file, otherwise delete the temp file. if ($this->Context->WarningCollector->Iif()) { @rename($rand, $File); } else { @unlink($rand); } /* /New code */ @chmod($this->Context->Configuration['EXTENSIONS_PATH']."Statistics/options.inc", 0666); unset($this->StatisticsFile); }
This isn't perfect--if a race condition does occur, the statistics information added by one process could be lost as the second process saves its data and its impossible to know when or how often this happens so your statistics will be skewed. But its much better than throwing out all the data once the race condition occurs.
It seems there is no perfect fix. Google 'php fopen race condition' for more info about this type of bug.