Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Getting the following error under PHP 5.4
NOTICE: ARRAY TO STRING CONVERSION IN THEME_HIERARCHICAL_SELECT() (LINE 87 OF /SITES/ALL/MODULES/HIERARCHICAL_SELECT/INCLUDES/THEME.INC)
This doesn't appear to break functionality but it does cause the warning to be displayed when editing or saving any node with a Hierarchical Selection field.
I've found that modifying lines 86 and 87 to the following suppresses the error:
//array_merge($element['#attributes']['class'], $classes);
$element['#attributes']['class'] = implode(',', $classes) . ' ' . implode(' ', $classes);
Comment | File | Size | Author |
---|---|---|---|
#31 | fixed-classes-1587570-31.patch | 766 bytes | RoSk0 |
#29 | hierarchical_select-php_54-1587570-29.patch | 812 bytes | yannickoo |
#22 | linux_patch_fail.jpg | 30.91 KB | dueron |
#19 | hierarchical_select-remove-array-to-string-error.patch | 843 bytes | RobKoberg |
#9 | hierarchical_select-array_merge_bug-1587570-4-fixed.patch | 812 bytes | Ignigena |
Comments
Comment #1
Wim LeersThat patch makes little sense to me.
Could you do a var_dump of $classes?
Comment #2
tregeagle CreditAttribution: tregeagle commentedI can confirm this error under PHP 5.4
To clarify, when I use the Hierarchical Select widget to select a taxonomy item in the form I get the following error,
Notice: Array to string conversion in theme_hierarchical_select() (line 87 of /var/www/sites/default/modules/contrib/hierarchical_select/includes/theme.inc).
Here is the result of a $classes var_dump:
array(4) { [0]=> string(27) "hierarchical-select-wrapper" [1]=> string(43) "hierarchical-select-level-labels-style-none" [2]=> string(60) "hierarchical-select-wrapper-for-name-edit-field-category-und" [3]=> string(49) "hierarchical-select-wrapper-for-config-taxonomy-4" }
Thanks @Ignigena your patch fixed the issue for me.
Comment #3
Wim LeersThe patch is imploding with two different concatenators and with the exact same values. That doesn't make any sense.
Sorry, but I really can't commit this.
Comment #4
tregeagle CreditAttribution: tregeagle commentedHi Wim,
I know this is a very minor issue but I am learning so I asked a more savvy friend to help me work this out. @Ignigena's patch did not make sense to Matthew either so he suggested the attached patch.
Thanks Wim, for all your work on this neat module.
Comment #5
kurtzhong CreditAttribution: kurtzhong commentedThis patch works fine, thanks.
Comment #6
Ignigena CreditAttribution: Ignigena commentedThe patch in #4 works great.
I don't know what I was smoking ... lol
Comment #7
rudiedirkx CreditAttribution: rudiedirkx commentedPatch in #4 is perfect. Did that myself too before searching in the issue list.
Comment #8
rudiedirkx CreditAttribution: rudiedirkx commentedScratch that. The patch doesn't apply correctly, because it's created incorrectly. You've created it from your site folder, not the module folder.
should be
Comment #9
Ignigena CreditAttribution: Ignigena commentedFixed the patch provided in #4 and everything should apply correctly.
Comment #10
Tim Jones Toronto CreditAttribution: Tim Jones Toronto commentedHave tested patch #9 and confirm it works using PHP 5.4.7.
Thanks.
Comment #11
rudiedirkx CreditAttribution: rudiedirkx commentedAnd now someone should tell Wim Leers...
Comment #12
jibran+1 for RTBC
Comment #13
yannickooPatch from #9 works fine.
Comment #14
ptmkenny CreditAttribution: ptmkenny commentedI was also able to successfully apply the patch in #9, which fixed the error for me.
Comment #15
rudiedirkx CreditAttribution: rudiedirkx commented@Ignigena It's kind weird though... Why is there a line
with nothing else on it? It's useless. So I'm gonna have to unapprove.
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedSeems fine. RTBC +1
@rudiedirkx, it seems that line simply was a mistake. The patch from #9 fixes this.
Comment #17
rudiedirkx CreditAttribution: rudiedirkx commentedNo, it doesn't. That line is still in there and it shouldn't be, because it's useless and confusing.The patch in #9 (and this issue) is not ready.Comment #18
rudiedirkx CreditAttribution: rudiedirkx commentedOh wow, I am really blind... Wow!
Sorry guys. =) RTBC indeed!
Comment #19
RobKoberg CreditAttribution: RobKoberg commentedThe patch in #9 is no longer valid as the line numbers have changed. Attached is a new patch. Why hasn't this been done yet? Seems like an appropriate fix.
Comment #20
kenianbei CreditAttribution: kenianbei commented#19 Fixes issue for me as well.
Comment #21
giupenni CreditAttribution: giupenni commented#19 Fixes issue fo me, thank you!
Comment #22
dueron CreditAttribution: dueron commentedI have also been wrestling with this issue for several days. I get the same unsightly error after turning on PHP 5.4 globally at 1and1 hosting.
I don't wish to revert back to PHP 5.2, and I would like to use this module. Am considering "Simple Hierarchical Select." instead.
I tried the patch in #19, but was not able to make it work with my elementary coding skills. (see attached screenshot)
I would be very grateful if anyone might tell me what I might do to fix this, or help me learn to properly run this patch. Thx!
Comment #23
ptmkenny CreditAttribution: ptmkenny commented@dueron Documentation on how to apply a patch can be found here: http://drupal.org/patch/apply
That said, if you haven't committed to a specific module, at this point in time (early 2013) "Simple Hierarchical Select" is seeing more development activity than this module, so if it does what you want, you might switch to that.
Comment #24
dueron CreditAttribution: dueron commented@ptmkenny, Thanks for the reference and insight! I did read that instruction article previously, yet was not able to format the patch file properly using bbedit.
Regarding "Simple H S," I have been switching between the two modules with limited success, and trying to decide. I can't seem to make either one work very well when I move from Devel. to Production Host server.
"H S" works GREAT (and looks so nice) in my development environment, using PHP 5.3 or lower. However, when I move it to 1and1 (which only offers the choices: PHP 5.2, 5.4 & "5 dev" Simple HS doesn't even display, when I move to the online server host.
I would like to start using the "Course" module, which requires PHP 5.4. I am slowly learning that learning that Drupal development is constant series of prioritizing choices. (like life, I guess). Thx again!
Comment #25
Taxoman CreditAttribution: Taxoman commentedAny reason this cannot be committed to the -dev branch?
Comment #26
mmilano CreditAttribution: mmilano commented+1 RTBC for #19.
A work around in the mean time for those not wanting to patch would be to override the theme function in your theme's template.php file. I commented in caps the only change to the original.
Comment #27
dshields CreditAttribution: dshields commentedPatch in #19 solves the problem for me
Comment #28
djroshi CreditAttribution: djroshi commentedI can also confirm that #19 fixes the issue
Comment #29
yannickooI applied the patch an re-created it with
git diff
which looks more like a git patch (looks like #9 now :D ).Comment #30
mpgeek CreditAttribution: mpgeek commented#29 Worked for me. Gracias.
Comment #31
RoSk0Patch from #29 works, but code could be prettier
$element['#attributes']['class'] += $classes;
. Patch attached.+1 to RTBC.
Comment #32
rudiedirkx CreditAttribution: rudiedirkx commented@RoSk0 That's not how array addition works.
will output
[a, b]
not[a, b, c, d]
.For assoc arrays, that's the wanted behavior. Not for numeric arrays.
Comment #33
RoSk0@rudiedirkx thanks for the comment!
That means that patch from #29 is the one to commit.
Comment #34
rv0 CreditAttribution: rv0 commented+1 for #29
Comment #35
jorgemontoyab CreditAttribution: jorgemontoyab commented# 19 works fine. Thanks
Comment #36
vlad.leo CreditAttribution: vlad.leo commentedSory patch hierarchical_select-php_54-1587570-29.patch do not solve problem
Comment #37
kingfisher64 CreditAttribution: kingfisher64 commentedpatch #29 works fine.
Any chance of a new release as the latest dev is a year old and reads +9 dev not including any patches to be committed like this.
Comment #38
Wim LeersThanks, committed #29!
http://drupalcode.org/project/hierarchical_select.git/commit/98add9d986f...