| Project: | Panels |
| Version: | 7.x-3.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
If I activate panels simple cache with arguments my site will display an exception.
I checked this with a debugger and in this case Panels Everywhere delivers an object as args but the simple caches foreach() and needs an array.
panels/plugins/cache/simple.inc line 98
<?php
case 'args':
foreach ($args as $arg) {
$id .= ':' . $arg;
}
break;
?>panels_everywhere/theme/theme.inc line 18
<?php
$content = new stdClass();
$content->title = drupal_get_title();
if (!empty($page['content'])) {
$content->content = $page['content'];
}
else {
$content->content = " ";
}
$args = array($content);
$contexts = ctools_context_handler_get_task_contexts($task, '', $args);
?>My debugger showed that args contains various things. Most times it is some id probably the nid but sometimes it does contain objects.
I have no clue what panels is doing with the args as I don't know the API that far. And it seems panels has no problems with args being an object. But the caching will fail.
I could do a patch that could get us a crc32 or something key from the object so we can use that for caching. Would that make sense?
Comments
#1
Okay I made a patch. I use serialize() and md5() to create the cache id. This should never fail but maybe we need an empty check before as I am not sure how serialize() will behave.
And I added arg() to be used as caching context as well. In my special case we use the nice menu module. It normally shows the active path but with context or arguments cache it won't change and always behave like we are currently seeing the homepage. If I use arg() for the cid it will react normally but will reside in cache. I extended the comment but think my english sounds stupid.
So what do you think about it?
Can we use md5(serialize()) as cid base?
Is it good to add arg() as cache context as well?
#2
Won't this break the code that tries to clear old entries from the cache when a panel is updated?
#3
Yes thats true. I write an hook_update() to delete the old entries than.