The panels_renderer_standard::add_meta()
method uses the path_to_theme()
function to check if the active theme defines a CSS file for the layout to render. This allows themes to use their own CSS for a given layout instead of the one that comes with Panels module.
But when the layout render operation occurs while a theme process is happening, the path_to_theme()
function may return a wrong path if the theme hook defines a value for the "theme path"
key (@see hook_theme API).
In such edge cases, the theme CSS if not used as expected.
Steps to reproduce this bug:
- enable the Panels and Views modules,
- enable a theme that has a CSS file called "twocol.css" in its root folder (you may add a dummy rule like
body { background: red; }
, - create a new view that uses panels fields (use the simple twocols layout),
- add a page display,
- go to the newly created page.
What we don't see:
You will not see the expected red background, because the path_to_theme()
function returns sites/all/modules/views
instead of the active theme path.
What we should see:
The red background.
Comment | File | Size | Author |
---|---|---|---|
#12 | panels-n2056701-12.patch | 1.7 KB | DamienMcKenna |
Comments
Comment #1
B-Prod CreditAttribution: B-Prod commentedThe patch below fixes this.
Comment #1.0
B-Prod CreditAttribution: B-Prod commentedFix a typo
Comment #2
Peacog CreditAttribution: Peacog commentedThanks for this patch. The use of path_to_theme() was throwing
open_basedir restriction in effect
warnings for me. path_to_theme() would return "modules/system" and the resulting css path, which was of the form "modules/system/../../../css/layouts/my-panels-layout/my-panels-layout.layout.css" was triggering the open_basedir warning.I've rerolled the patch for the latest 7.x-3.x-dev
Comment #4
B-Prod CreditAttribution: B-Prod commentedCould this be committed?
Comment #6
mrjmd CreditAttribution: mrjmd commentedComment #7
japerrySomethings not right here...
Why are we calling this within the foreach? This could potentially add the same file over and over again.
Comment #8
DamienMcKennaI've moved the $theme_path definition outside of the loop, and fixed formatting of the two foreach() loops in that method.
Comment #9
DamienMcKennaComment #10
mglamanApplies, works as expected. I like that we can bypass straight to the theme (even discussed as first comment on path_to_theme() documentation.)
Comment #11
japerryI'm still a bit worried about this one.
This is being looped over and over again as well. If I'm following the code correctly, I believe the if statement is trying to make sure that if there is a theme implementation of a css file, use it. otherwise fall back. But I don't think the if statement actually does it. Haven't given enough time to test and try a patch on it, but this code looks suspect to me still.
Comment #12
DamienMcKennaAh, one of the variables needed to be updated. How's about this?
Comment #13
mglamanMarking for review for updated patch
Comment #14
japerryyah, that looks better! committed.