Skip to content
Snippets Groups Projects
Commit fa6aa8b7 authored by Daniel Wehner's avatar Daniel Wehner Committed by Tim Plunkett
Browse files

Refactor some code in cache_time to look nicer and fix some undefined variable problems.

parent 7f3fd058
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -83,11 +83,18 @@ function summary_title() { ...@@ -83,11 +83,18 @@ function summary_title() {
foreach ($custom_fields as $field) { foreach ($custom_fields as $field) {
${$field} = $this->options[$field] == 'custom' ? $this->options[$field . '_custom'] : $this->options[$field]; ${$field} = $this->options[$field] == 'custom' ? $this->options[$field . '_custom'] : $this->options[$field];
} }
$results_lifespan = $this->get_lifespan('results');
$output_lifespan = $this->get_lifespan('output');
return format_interval($results_lifespan, 1) . '/' . format_interval($output_lifespan, 1); return format_interval($results_lifespan, 1) . '/' . format_interval($output_lifespan, 1);
} }
function cache_expire($type) { function get_lifespan($type) {
$lifespan = $this->options[$type . '_lifespan'] == 'custom' ? $this->options[$type . '_lifespan_custom'] : $this->options[$type . '_lifespan']; $lifespan = $this->options[$type . '_lifespan'] == 'custom' ? $this->options[$type . '_lifespan_custom'] : $this->options[$type . '_lifespan'];
return $lifespan;
}
function cache_expire($type) {
$lifespan = $this->get_lifespan($type);
if ($lifespan) { if ($lifespan) {
$cutoff = REQUEST_TIME - $lifespan; $cutoff = REQUEST_TIME - $lifespan;
return $cutoff; return $cutoff;
...@@ -98,7 +105,7 @@ function cache_expire($type) { ...@@ -98,7 +105,7 @@ function cache_expire($type) {
} }
function cache_set_expire($type) { function cache_set_expire($type) {
$lifespan = $this->options[$type . '_lifespan'] == 'custom' ? $this->options[$type . '_lifespan_custom'] : $this->options[$type . '_lifespan']; $lifespan = $this->get_lifespan($type);
if ($lifespan) { if ($lifespan) {
return time() + $lifespan; return time() + $lifespan;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment