diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-14 04:31:02 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-14 04:31:02 +0000 |
commit | 38e91f2b8f4972f5b1e0789aeac22056fe8d5c54 (patch) | |
tree | cf1cd925cb38560c7669e45bb9688176e6c090c9 | |
parent | f2f56bd289aad331634b4e5bfaae8e67795a63f8 (diff) | |
download | elgg-38e91f2b8f4972f5b1e0789aeac22056fe8d5c54.tar.gz elgg-38e91f2b8f4972f5b1e0789aeac22056fe8d5c54.tar.bz2 |
Cache handler won't serve up cached pages if caching is disabled. Refs #2758: Added call to elgg_view_regenerate_simplecache() on cache misses if cache is enabled. Leaving #2758 open in case Cash has a better idea since he's more familiar with the simple cache changes.
git-svn-id: http://code.elgg.org/elgg/trunk@8225 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/handlers/cache_handler.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/engine/handlers/cache_handler.php b/engine/handlers/cache_handler.php index 9377282a4..d41977cb0 100644 --- a/engine/handlers/cache_handler.php +++ b/engine/handlers/cache_handler.php @@ -1,7 +1,7 @@ <?php /** * Cache handler. - * + * * External access to cached CSS and JavaScript views. The cached file URLS * should be of the form: cache/<type>/<view>/<viewtype>/<unique_id> where * type is either css or js, view is the name of the cached view, and @@ -28,23 +28,25 @@ if (!mysql_select_db($CONFIG->dbname, $mysql_dblink)) { exit; } -$query = "select name, value from {$CONFIG->dbprefix}datalists where name = 'dataroot'"; +$query = "select name, value from {$CONFIG->dbprefix}datalists + where name in ('dataroot', 'simplecache_enabled')"; + $result = mysql_query($query, $mysql_dblink); if (!$result) { echo 'Cache error: unable to get the data root'; exit; } -$row = mysql_fetch_object($result); +while ($row = mysql_fetch_object($result)) { + ${$row->name} = $row->value; +} mysql_free_result($result); -$dataroot = $row->value; - $dirty_request = $_GET['request']; // only alphanumeric characters plus /, ., and _ and no '..' $filter = array("options" => array("regexp" => "/^(\.?[_a-zA-Z0-9\/]+)+$/")); $request = filter_var($dirty_request, FILTER_VALIDATE_REGEXP, $filter); -if (!$request) { +if (!$request || !$simplecache_enabled) { echo 'Cache error: bad request'; exit; } @@ -83,6 +85,8 @@ if (file_exists($filename)) { // someone trying to access a non-cached file or a race condition with cache flushing mysql_close($mysql_dblink); require_once(dirname(dirname(__FILE__)) . "/start.php"); + elgg_view_regenerate_simplecache(); + elgg_set_viewtype($viewtype); $contents = elgg_view($view); } |