1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-21 16:13:00 +00:00

Make the statistic update system more resilient

This commit is contained in:
Starbeamrainbowlabs 2020-11-20 21:13:31 +00:00
parent 880c9e3796
commit d29b87eb6d
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 4 additions and 2 deletions

View file

@ -16,6 +16,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
## Fixed
- [security] Fixed some potential XSS attacks in the page editor
- Fixed a weird bug in the `stats-update` action causing warnings
## v0.22

View file

@ -130,7 +130,8 @@ register_module([
exit(page_renderer::render_main("Error - Recalculating Statistics - $settings->sitename", "<p>You need to be logged in as a moderator or better to get $settings->sitename to recalculate it's statistics. If you're logged in, try <a href='?action=logout'>logging out</a> and logging in again as a moderator. If you aren't logged in, try <a href='?action=login&returnto=%3Faction%3Dstats-update'>logging in</a>.</p>"));
// Delete the old stats cache
unlink($paths->statsindex);
if(file_exists($paths->statsindex))
unlink($paths->statsindex);
update_statistics(true, ($_GET["force"] ?? "no") == "yes");
header("content-type: application/json");
@ -310,7 +311,7 @@ function update_statistics($update_all = false, $force = false)
if(isset($settings->firstrun_complete) && $settings->firstrun_complete == false)
return;
$stats_mtime = filemtime($paths->statsindex);
$stats_mtime = file_exists($paths->statsindex) ? filemtime($paths->statsindex) : 0;
// Clear the existing statistics if we are asked to recalculate them all
if($force)