I'm currently running 7.x-2.0-beta2+16-dev with Authcache Panels by Page Manager running. Everything is working fine except on the pages with a panel that is set to use Authcache per user / per page with "Never Cache" set. I am doing this with the Node Links so my flags react instantly when a user "favorites" a node.
When I view any node setup this way as authenticated there are no errors. When I view the node as anonymous user I see the following error:
Notice: Trying to get property of non-object in authcache_panels_panels_pane_content_alter() (line 61 of /var/www/sites/all/modules/authcache/modules/authcache_panels/authcache_panels.module).
When I disable the Authcache caching on the panel in question, flush the cache and view as anonymous user again, the error goes away.
For reference here is the code in the file being called. I have marked what is line 61 where the problem is coming from below.
/**
* Implements hook_panels_pane_content_alter().
*/
function authcache_panels_panels_pane_content_alter($content, $pane, $args, $context, $renderer, $display) {
if (authcache_page_is_cacheable() && authcache_panels_pane_fragment_enabled($pane)) {
$config = _authcache_panels_pane_get_options($pane);
$fragment = array(
'#theme' => 'authcache_p13n_fragment',
'#fragment' => authcache_panels_pane_fragment_id($pane),
'#clients' => $config['clients'],
'#fallback' => $config['fallback'],
);
$element = array('#markup' => $content->content); <----- LINE 61
authcache_p13n_attach($element, $fragment);
$content->content = render($element);
}
}
Comment | File | Size | Author |
---|---|---|---|
#5 | 2237659-prevent-error-when-rendering-empty-pane-5.diff | 6.28 KB | znerol |
#5 | 2237659-TEST-ONLY-prevent-error-when-rendering-empty-pane-5.diff | 5.12 KB | znerol |
#4 | 2237659-prevent-error-when-rendering-empty-pane.diff | 666 bytes | znerol |
Comments
Comment #1
Ravenight CreditAttribution: Ravenight commentedComment #2
Ravenight CreditAttribution: Ravenight commentedI added a workaround for this with the following addition to check if the $content variable is available or not.
So far everything seems to be okay.
Comment #3
Ravenight CreditAttribution: Ravenight commentedEdit title to something shorter
Comment #4
znerol CreditAttribution: znerol commentedThank you very much @Ravenight for the detailed report and the proposed solution. I think we should attach the fragment loader even when the content is empty though. Consider the following example:
A panel pane contains a per-user list (e.g. a view) of favorite content (or even line items in a shopping cart).
Therefore I think we should attach the fragment loader even when there is no content.
Comment #5
znerol CreditAttribution: znerol commentedOk, just dugg a bit deeper into that problem. Apparently the panels sometimes passes
NULL
into the$content
parameter ofhook_panels_pane_content_alter()
, especially when a ctools block (e.g. a panels pane) did not return anything. We cannot possibly attach the loader code when$content
isNULL
, so we also need to cater for that.Please note:
Comment #8
znerol CreditAttribution: znerol commented