summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2013-02-01 19:14:58 (GMT)
committer Earl Miles2013-02-01 19:14:58 (GMT)
commiteac315873403712fdc1709cab678b2dcdef91b03 (patch)
tree561b682a38e4e4d809ab84fb021ad099ea3de4d8
parent9846b92bfb5452c97ece7306d5dd2554551b4cef (diff)
Issue #1613402: Panel nodes improperly handle cache causing repeated use of IPE to fail.
-rw-r--r--panels_node/panels_node.module48
1 files changed, 48 insertions, 0 deletions
diff --git a/panels_node/panels_node.module b/panels_node/panels_node.module
index 4044c5a..5b59b63 100644
--- a/panels_node/panels_node.module
+++ b/panels_node/panels_node.module
@@ -339,6 +339,7 @@ function panels_node_hook_view($node, $view_mode) {
$display->css_id = $node->panels_node['css_id'];
// TODO: Find a way to make sure this can't node_view.
$display->context = panels_node_get_context($node);
+ $display->cache_key = 'panels_node:' . $node->nid;
$renderer = panels_get_renderer($node->panels_node['pipeline'], $display);
$node->content['body'] = array(
'#markup' => panels_render_display($display, $renderer),
@@ -429,3 +430,50 @@ function panels_node_panels_dashboard_blocks(&$vars) {
'weight' => -1,
);
}
+
+// ---------------------------------------------------------------------------
+// Callbacks for panel caching.
+
+/**
+ * Get display edit cache for a panel node being edited.
+ *
+ * The key is the second half of the key in this form:
+ * panels_node:NID;
+ */
+function panels_node_panels_cache_get($nid) {
+ ctools_include('object-cache');
+ $cache = ctools_object_cache_get('panels_node_display_cache', $nid);
+ if (empty($cache)) {
+ $cache = new stdClass();
+ $node = node_load($nid);
+ if (empty($node)) {
+ return;
+ }
+
+ ctools_include('common', 'panels');
+ $cache->display = panels_load_display($node->panels_node['did']);
+ $cache->display->css_id = $node->panels_node['css_id'];
+ $cache->display->context = panels_node_get_context($node);
+ $cache->display->cache_key = 'panels_node:' . $node->nid;
+ $cache->content_types = panels_common_get_allowed_types('panels_node', $cache->display->context);
+ $cache->allwed_layouts = panels_common_get_allowed_layouts('panels_node');
+ }
+
+ return $cache;
+}
+
+/**
+ * Store a display edit in progress in the page cache.
+ */
+function panels_node_panels_cache_set($nid, $cache) {
+ ctools_include('object-cache');
+ ctools_object_cache_set('panels_node_display_cache', $nid, $cache);
+}
+
+/**
+ * Save all changes made to a display using the Page Manager page cache.
+ */
+function panels_node_panels_cache_clear($nid, $cache) {
+ ctools_include('object-cache');
+ ctools_object_cache_clear('panels_node_display_cache', $nid);
+}