I've got some questions related to latest version of your mod.
First of all, do you know that installation package contains some unnecessary files like ._mod_http_guest_cache.php and ._acp_mod_http_guest_cache.php? I don't know what are the files, suppose it is something from your MacOS. Apple likes to add trash anywhere.
Next one from functions.php.
Code: Select all
if ($_SID == '' && $session_id === false && empty($_EXTRA_URL) && !$params_is_array && !$anchor/* BEGIN mod_http_guest_cache */ && (!isset($mod_http_guest_cache) || !$mod_http_guest_cache->is_cacheable())/* END mod_http_guest_cache */)
Code: Select all
if ($_SID == '' && $session_id === false && empty($_EXTRA_URL) && !$params_is_array && !$anchor
/* BEGIN mod_http_guest_cache */
&& (!isset($mod_http_guest_cache) || !$mod_http_guest_cache->is_cacheable())
/* END mod_http_guest_cache */)
Really, in some cases using of additional variables is unnecessary. See your code below:
Code: Select all
static $mod_http_guest_cache_param = null, $mod_http_guest_cache_param_val = null;
if ($mod_http_guest_cache_param === null)
{
$mod_http_guest_cache_param = $mod_http_guest_cache->get_param();
$mod_http_guest_cache_param_val = $mod_http_guest_cache->get_param_val();
if (is_null($mod_http_guest_cache_param_val))
{
$mod_http_guest_cache_param_val = 1;
}
So, you can re-factor it in the following way. Move your "configurations" variables (like $mod_http_guest_cache_param) into class private fields, initialize its in class constructor, return values from get_param() like you does it right now. So, anytime these properties will have correct values (calculated from settings or from their default values). So, your get_param() method will be simplified to the following:
Code: Select all
public function get_param()
{
return $this->_cache_param;
}
Code: Select all
$params .= $mod_http_guest_cache->get_param() . '=' . $mod_http_guest_cache->get_param_val();
Code: Select all
$params .= "$mod_http_guest_cache_param=$mod_http_guest_cache_param_val";
I can't understand some workarounds from the following method (and other similar methods):
Code: Select all
function get_param_val()
{
static $param_val = 'null';
if ($param_val === 'null')
{
$param_val = request_var($this->get_param(), -1);
$param_val = ($param_val === -1) ? null : $param_val != 0;
}
return $param_val;
}
Why 'null' instead of null and isset() check, which is much faster than string comparison?
Why you've set value, but on next line inspects it (if ($param_val === 'null'))?
At a glance this method easy simplified to the following:
Code: Select all
function get_param_val()
{
$param_val = request_var($this->get_param(), null);
return isset($param_val) ? (bool) $param_val : null;
}
Also you've checked cron by analyzing $run_cron variable. Not sure that it is correct, because it means that cron will work for registered users only. I did this check by the following:
Code: Select all
if (!isset($cron_type) || !$cron_type)