Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

Status: Active » Needs review

Correct status

amitaibu’s picture

This patch is still needed ;)

merlinofchaos’s picture

Status: Needs review » Fixed

I like this more than the (object) cast being used in an earlier patch, so committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jweowu’s picture

Status: Closed (fixed) » Active

This patch has introduced a couple of undesirable side-effects:

1) the empty content for these panes (which may potentially have been expensive to generate) is not cached.

2) modules do not have any opportunity to manipulate the content with hook_panels_pane_content_alter.

The object cast approach did not cause these problems.

git revert 2e6370ce36b82e3019a7dd73e65eb6b09deecc08 ?

jweowu’s picture

Uploading the revert patch so that I can reference it.

das-peter’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
2.04 KB

Here's a slightly updated patch:

  • Removed pointless variable priming with FALSE
  • Removed skipping of caching if content is empty
  • No casting of return of ctools_content_render(). ctools_content_render() returns nothing or an object. (At least as far as I understand the code)
  • Added condition to skip css handling if the content is empty.
japerry’s picture

japerry’s picture

Status: Needs review » Fixed
jweowu’s picture

The object casting originated in #1241064: In panels_renderer_standard::render_pane_content(), the return value of ctools_content_render() should be cast to an object. (commit 8b9c1ce39d9358be2a62356a0e98ea4c791c7869 )

Are we causing a regression here?

Unrelatedly, the comment "Pass long the css_id" seen in this patch makes no sense. I imagine it was supposed to be "pass along..." ?

das-peter’s picture

Are we causing a regression here?

I don't think so because the issue described there related to the "css configuration code". And the patch from #7 encapsulates that part as a whole into a condition that checks if $content is not empty.
Thus the code that caused the other issue won't be executed if there's no object.
For concerns about returning content that isn't empty and isn't an object I just can say that ctools_content_render() deals with an object too. So we would hit an issue there before panels_renderer_standard::render_pane_content() is executed.

jweowu’s picture

Right, I think I concur with that. panels_renderer_standard::render_pane_content() is only called by panels_renderer_standard::render_pane() which is diligent in not making assumptions about the return value.

The only pitfall I can see is that the implementations of hook_panels_pane_content_alter I can see (there are a couple in my current codebase) are assuming that $content is an object. However they're also assuming it's an object with a content property, and casting NULL to an object isn't going to magically add one of those, so I think it's entirely reasonable to call those bugs in the implementations and expect them to verify their assumptions!

Call this a post-commit RTBC :)

jweowu’s picture

FileSize
937 bytes

A patch for that typo I noticed.

maximpodorov’s picture

Every module implementing hook_panels_pane_content_alter() must be ready that $content can be NULL, right?

jweowu’s picture

maximpodorov: yes, I believe so.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

  • Commit 2e6370c on 7.x-3.x, 7.x-3.x-i18n, 8.x-3.x by merlinofchaos:
    Issue #1079792 by Amitaibu: Exit render early if $content is NULL.
    
    
  • Commit 692ad30 on 7.x-3.x, 8.x-3.x by japerry:
    Issue #1079792 by das-peter, jweowu, japerry: Move empty content pane...