Skip to content

Commit

Permalink
fixed new logs lists template caching
Browse files Browse the repository at this point in the history
  • Loading branch information
following5 committed Sep 6, 2015
1 parent a8fd694 commit de4c22e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions htdocs/lib2/OcSmarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class OcSmarty extends Smarty
var $main_template = 'sys_main';
var $bench = null;
var $compile_id = null;
var $cache_id = null;
var $cache_id = null; // This is a smarty caching ID, not a caches.cache_id.
var $title = '';
var $menuitem = null;
var $nowpsearch = false;
Expand Down Expand Up @@ -377,7 +377,12 @@ function is_cached($dummy1=null, $dummy2=null, $dummy3=null)
function get_cache_id()
{
global $opt;
return $this->name . '|' . $this->cache_id;

// $cache_id can be directly supplied from unverified user input (URL params).
// Probably this is no safety or stability issue, but to be sure we restrict
// the ID to a reasonable set of characters:

return $this->name . '|' . mb_ereg_replace('/[^A-Za-z0-9_\|\-\.]/', '', $this->cache_id);
}

function get_compile_id()
Expand Down
6 changes: 4 additions & 2 deletions htdocs/newlogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@
}
elseif (@$newlogs_rest)
{
// latest logs for all countries but Germany
// latest logs for all countries but the site's main country
$tpl->name = 'newlogsrest';
$tpl->menuitem = MNU_START_NEWLOGS;
$country = $login->getUserCountry();
$exclude_country = $opt['page']['main_country'];
$include_country = '%';
// As nearly all logs are from Germany, retrieving non-German logs is
// As most logs are from the main country, retrieving the other logs is
// expensive -> longer cache lifetime.
$tpl->caching = true;
$tpl->cache_lifetime = 900;
$tpl->cache_id = $exclude_country;
$logcount = 250;
$paging = false; // paging would have poor performance for all logs
$orderByDate = '';
Expand All @@ -75,6 +76,7 @@
}
$tpl->caching = true;
$tpl->cache_lifetime = 300;
$tpl->cache_id = $country;
$logcount = 250;
$paging = false; // paging would have poor performance for all logs
$orderByDate = '';
Expand Down

0 comments on commit de4c22e

Please sign in to comment.