From fa6aa8b7dd705a5702373e169cb17335340a78a7 Mon Sep 17 00:00:00 2001
From: Daniel Wehner <daniel.wehner@erdfisch.de>
Date: Sat, 9 Jun 2012 00:27:17 +0200
Subject: [PATCH] Refactor some code in cache_time to look nicer and fix some
 undefined variable problems.

---
 plugins/views_plugin_cache_time.inc | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/plugins/views_plugin_cache_time.inc b/plugins/views_plugin_cache_time.inc
index 8a28108dad4f..d6db2024c4fc 100644
--- a/plugins/views_plugin_cache_time.inc
+++ b/plugins/views_plugin_cache_time.inc
@@ -83,11 +83,18 @@ function summary_title() {
     foreach ($custom_fields as $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);
   }
 
-  function cache_expire($type) {
+  function get_lifespan($type) {
     $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) {
       $cutoff = REQUEST_TIME - $lifespan;
       return $cutoff;
@@ -98,7 +105,7 @@ function cache_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) {
       return time() + $lifespan;
     }
-- 
GitLab