The problem:

When you override template_preprocess_panels_pane() in your own theme, weirdness ensues when you just copy/paste and start altering anything which uses the $content variable within the provided function body. i.e. adding a another variation to the theme_hook_suggestions array.

How to reproduce

1. Install Drupal and Panels
2. Create a new theme
3. Override template_preprocess_panels_pane() in your own template.php
4. Verbatim copy/paste the function body from panels.module
5. Add a variation to the theme_hook_suggestions array: i.e. $vars['theme_hook_suggestions'][] = $base . $delimiter . $content->type . -'test';
6. Create new template called panels-pane--custom-test.tpl.php in your theme and add some test html (or the contents from panels-pane.tpl.php)
7. Create a new custom page and add a custom content panel
8. Clear your caches
9. Notice how the region in your custom page will appear empty.

Expected behaviour: you should see the output piped through the panels-pane--custom-test.tpl.php template.

How come?

The body of the template_preprocess_panels_pane() starts and ends with:

$content = &$vars['content'];
$vars['content'] = !empty($content->content) ? $content->content : ''; (line 1298 in panels.module)

The original $content variable within the panels.module context is an object with a few properties like 'type', 'subtype', 'title' and 'content'. At the end of the execution of the original function, the $vars['content'] gets overwritten with the 'content' property.

Overriding in template.php doesn't mean that the original template_preprocess_* won't be executed. It will be executed followed by the execution of the specific function in template.php passing $vars by reference to allow final tweaking. Since $vars['content'] is overwritten when the theme() function enters template.php, we only get a "lousy string" instead of a nice object.

Possible solution

Remove the assign at line 1298 fixes the issue and passes $vars['content'] as a nice object to possible preprocess overrides instead of a non-flexible string.


Changing the $content variable mid-stream would probably change people's templates, and that would lead to problems. So I don't think we can actually do that.

We can possibly rename the original $content variable so that it is preserved.

You *can* override the original template preprocess. In hook_theme, you can set this:

'override preprocess functions' => TRUE. Your theme can actually implement hook_theme() and set that for that and then NO preprocess functions except the theme's get called. (You can, then, if you like, call back to whichever ones you wish to use).

I'm not sure that Panels is likely to change anything here.