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

edited July 2007 in Vanilla 1.0 Help
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?

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

Comments

  • Look in the options.inc file that is in the Statistics directory. It contains all of the current information. See what it has for each of those indices that are in the errors.
  • It has this Jim. Not sure what it means though but i had not changed it over the time it stopped working. top_posting_user => 1 => 1 => 0 top_discussion_starter => 1 => 2 => 0 most_active_users => 1 => 3 => 0
  • My entries look like. It has the username for each item. Yours doesn't. Maybe when you excluded guests posting, the data got screwed up. Try disabling that add-on.

    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
  • Hey Jim Sorry. That was in my local file. i then looked at the remote file that the server is using and this is all that was in it.

    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.
  • Does everything look fine now even after excluding guests from posting? Did you click on the option to reset the statistics?
  • Yes it is all OK now and yes I did try to reset the statistics using the button in the settings area.as an effort to try to resolve the problem but somehow the options file on the server must have gotten corrupted, perhaps after removing the guestpost extension which i did just before it went wrong.

    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.
  • I'm glad to hear that it's running fine now :D
  • It went clunk again without any good reason. Fixed it again by just uploading the options file again. it must have some sort of built in self-destruct???
  • I guess the problem might arise if 2 page refreshes at the same time kill it? Just like with settings.php?
  • Thats exactly what is probably happening. (Man, that is a contradictory sentence.)

    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.
  • Whatever it is it has started happening about every two or three days now. Is it fixable Wallphone?
  • You could try replacing the existing SaveStatistics with this: (untested) 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.
This discussion has been closed.