Closed (fixed)
Project:
ThemeKey
Version:
6.x-1.1
Component:
Modules
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
15 Apr 2009 at 10:51 UTC
Updated:
29 Sep 2009 at 15:56 UTC
Jump to comment: Most recent file
The function _themekey_property_field($value, $path) contains a cast to array that destroys the actual value here.
function _themekey_property_field($value, $path) {
//
$parts = explode('/', $path);
foreach ($parts as $part) {
if (is_array($value) && isset($value[$part])) {
$value = (array)$value[$part];
}
else {
return NULL;
}
}
return is_array($value) ? array_keys($value) : $value;
}
If I, say, had a path of "node:nid" and the (scalar) value of "14" as actual nid then the cast to array would result in array(0 => "14").
The is_array() in the return statement is then true, of course, and as a result what is returned is an array with just the keys, which means an array with a single element: array(0 => 0). The actual data is lost.
If I remove the cast to array the code works for me:
$value = $value[$part];
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 434242_non_array_properties.patch | 9.15 KB | mkalkbrenner |
| #2 | themekey_array_fix.patch | 659 bytes | mkalkbrenner |
Comments
Comment #1
cspitzlayIs there anyone else experiencing this?
I.e. defined rules for nid or hostname not working?
Comment #2
mkalkbrennerThis issue was already mentioned at http://drupal.org/node/369065#comment-1252638 but wasn't fixed.
I confirm that the bug still exists in Release 6.x-1.1 2009-Mar-29.
Here's a patch to fix it.
Comment #3
muhleder commentedWorks for me too, was seeing the same issue and tracked down the bug to the same place independently.
Comment #4
mkalkbrennerComment #5
davemybes commentedGreat catch! I noticed that the theme wasn't changing on book:bid and I was happy to see a patch out already for this bug. By adding the patch, the theme changes as expected, and if I remove it, theme switching stops. Bumping to critical as things simply don't work properly without it.
Comment #6
mkalkbrennerDue to the fact that ThemeKey currently seems to be unmaintained (see #552994: Maintenance? ThemeKey appears to be abandoned) you can download a patched version of ThemeKey 6.x-1.1 from
http://drupal.cocomore.com/de/project/themekey
that fixes these critical issues:
Comment #7
mkalkbrennerComment #8
sinasalek commentedI see that you're the maintainer of this module, is this comment still valid?
Comment #9
mkalkbrennerI'm currently reviewing my own patch from #2 again if it breaks any other feature within ThemeKey I'm currently nor aware of.
This part of the code seems to be written for paths initially. But now it's also used for properties.
@sinasalek #8:
You can still download a patched version from the link provided at #6 until ThemeKey 6.x-1.2 is released. This version seems to work for some users better than the unpatched one. I'll remove the external package as soon as ThemeKey 6.x-1.2 is released.
I'm maintaining this module for two days now. So it will take some time until I'm familiar with all the code.
Comment #10
sinasalek commentedGreat, wish you luck.
Comment #11
mkalkbrennerUnfortunately the patch wasn't as easy as expected in comment #2.
The main issue was that all properties where handled as objects because
isset($object)always returned true:But to fix it completely a lot of additional stuff was required ...
Comment #12
mkalkbrennerreleased as 6.x-1.2-alpha1