Posted by bigjim on March 7, 2012 at 3:08am
3 followers
| Project: | Views |
| Version: | 6.x-3.x-dev |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | patch (to be ported) |
Issue Summary
Attached is a patch to allow users to set a custom time length for a cache to expire (ie 3 minutes, 1.5 days, etc...). The patch adds a "custom" option to the time drop down select. When "custom" is chosen for either output or results cache's then a text field appears where someone can enter a number of seconds for the cache to last for.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| custom-cach-time.patch | 4.09 KB | Idle | PASSED: [[SimpleTest]]: [MySQL] 1,311 pass(es). | View details | Re-test |
Comments
#1
+++ b/plugins/views_plugin_cache_time.incundefined@@ -17,6 +19,7 @@ class views_plugin_cache_time extends views_plugin_cache {
$options = array(-1 => t('Never cache')) + $options;
+ $options += array('custom' => t('Custom'));
These lines could probably be combined.
+++ b/plugins/views_plugin_cache_time.incundefined@@ -25,6 +28,18 @@ class views_plugin_cache_time extends views_plugin_cache {
+ '#description' => 'Length of time in seconds raw query results should be cached',
wrap in t()
+++ b/plugins/views_plugin_cache_time.incundefined@@ -32,14 +47,40 @@ class views_plugin_cache_time extends views_plugin_cache {
+ '#description' => 'Length of time in seconds rendered HTML output should be cached',
wrap in t()
+++ b/plugins/views_plugin_cache_time.incundefined@@ -32,14 +47,40 @@ class views_plugin_cache_time extends views_plugin_cache {
+ $custom_fields = array('output_lifespan','results_lifespan');
missing space after comma
+++ b/plugins/views_plugin_cache_time.incundefined@@ -32,14 +47,40 @@ class views_plugin_cache_time extends views_plugin_cache {
+ if ($form_state['values']['cache_options'][$field] == 'custom' && !is_numeric($form_state['values']['cache_options'][$field . '_custom'])) {
would this need an isset() to prevent notices?
+++ b/plugins/views_plugin_cache_time.incundefined@@ -32,14 +47,40 @@ class views_plugin_cache_time extends views_plugin_cache {
+ $custom_fields = array('output_lifespan','results_lifespan');
missing space after comma
#2
All except the isset() re-rolled here. On the isset() question I believe it's not needed as event the "never cache" options returns a -1 for the first condition of the if() so there is always a value.
#3
Rerolled for git credit for @jalama, and adding full stops to the end of a string. I don't think this needs tests, since its really a UI thing.
The validate works, it gets exported properly, and the UI works.
#4
Thanks! Committed to 7.x-3.x