Posted by Ignigena on May 17, 2012 at 6:08pm
21 followers
| Project: | Hierarchical Select |
| Version: | 7.x-3.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
Issue Summary
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:
<?php
//array_merge($element['#attributes']['class'], $classes);
$element['#attributes']['class'] = implode(',', $classes) . ' ' . implode(' ', $classes);
?>
Comments
#1
That patch makes little sense to me.
Could you do a var_dump of $classes?
#2
I 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.
#3
The 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.
#4
Hi 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.
#5
This patch works fine, thanks.
#6
The patch in #4 works great.
I don't know what I was smoking ... lol
#7
Patch in #4 is perfect. Did that myself too before searching in the issue list.
#8
Scratch that. The patch doesn't apply correctly, because it's created incorrectly. You've created it from your site folder, not the module folder.
diff --git a/modules/contrib/hierarchical_select/includes/theme.inc b/modules/contrib/hierarchical_select/includes/theme.incshould be
diff --git a/includes/theme.inc b/includes/theme.inc#9
Fixed the patch provided in #4 and everything should apply correctly.
#10
Have tested patch #9 and confirm it works using PHP 5.4.7.
Thanks.
#11
And now someone should tell Wim Leers...
#12
+1 for RTBC
#13
Patch from #9 works fine.
#14
I was also able to successfully apply the patch in #9, which fixed the error for me.
#15
@Ignigena It's kind weird though... Why is there a line
array_merge($element['#attributes']['class'], $classes);with nothing else on it? It's useless. So I'm gonna have to unapprove.
#16
Seems fine. RTBC +1
@rudiedirkx, it seems that line simply was a mistake. The patch from #9 fixes this.
#17
No, 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.#18
Oh wow, I am really blind... Wow!
Sorry guys. =) RTBC indeed!
#19
The 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.
#20
#19 Fixes issue for me as well.
#21
#19 Fixes issue fo me, thank you!
#22
I 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!
#23
@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.
#24
@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!
#25
Any reason this cannot be committed to the -dev branch?