Skip to content

Commit

Permalink
Backport: Cherry-pick from merge commit 9f4f3db
Browse files Browse the repository at this point in the history
Merge pull request #118 from startersclan/fix/bf2sclone-write-page-cache-only-if-ranking-refresh-time-0

Fix (bf2sclone): Write page cache only if `RANKING_REFRESH_TIME > 0`
  • Loading branch information
leojonathanoh committed Feb 2, 2023
1 parent 73e13d8 commit 6fb6dfa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/bf2sclone/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ function intToMins($time)
return $mins = round($time/60, 0);
}

/* CHACHING FUNCTIONS */
/* CACHING FUNCTIONS */

function isCachedEnabled()
{
return RANKING_REFRESH_TIME > 0;
}

function isCached($id)
{
Expand Down
12 changes: 9 additions & 3 deletions src/bf2sclone/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@
include( TEMPLATE_PATH . 'playerstats.php' );

// write cache file
writeCache($PID, trim($template));
if (isCachedEnabled()) {
writeCache($PID, trim($template));
}
$LASTUPDATE = intToTime(0);
$NEXTUPDATE = intToTime(RANKING_REFRESH_TIME);
$template = str_replace('{:LASTUPDATE:}', $LASTUPDATE, $template);
Expand Down Expand Up @@ -148,7 +150,9 @@
include( TEMPLATE_PATH .'current-ranking.php');

// write cache file
writeCache('current-ranking', $template);
if (isCachedEnabled()) {
writeCache('current-ranking', $template);
}
$LASTUPDATE = intToTime(0);
$NEXTUPDATE = intToTime(RANKING_REFRESH_TIME);
}
Expand Down Expand Up @@ -271,7 +275,9 @@
include( TEMPLATE_PATH .'home.php');

// write cache file
writeCache('home', $template);
if (isCachedEnabled()) {
writeCache('home', $template);
}
$LASTUPDATE = intToTime(0);
$NEXTUPDATE = intToTime(RANKING_REFRESH_TIME);
}
Expand Down

0 comments on commit 6fb6dfa

Please sign in to comment.