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.
When I attempt to expose a taxonomy filter, I receive the following error for every term in the taxonomy:
- Warning: html_entity_decode() expects parameter 1 to be string, object given in decode_entities() (line 429 of /home/patcms/public_html/includes/unicode.inc).
Digging a little deeper, it seems that the decode_entities method is actually receiving something like stdClass->option['{tid}']=>'{term name}'
Comment | File | Size | Author |
---|---|---|---|
#24 | views-taxo-term-lm.txt | 14.5 KB | anou |
#23 | views-articles-lm.txt | 60.88 KB | anou |
#16 | 1464174-by-mjanouch-zhangtaihao-Fix-exposed-select-filter-object-option-warning.patch | 575 bytes | zhangtaihao |
#6 | views-exposed_filter_options-1464174.patch | 651 bytes | mjanouch |
Comments
Comment #1
zabelc CreditAttribution: zabelc commentedI did some additional debugging & testing and was able to get around the error by modifying the prepare_filter_select_options function. Note though that I'm not using optgroups, so this may not resolve the defect for all cases. It does however work for a straight taxonomy & a taxonomy with a hierarchy.
Comment #2
adelka CreditAttribution: adelka commentedsubscribe
Comment #3
joe_pixelrow CreditAttribution: joe_pixelrow commentedI am having this same error on a bulk-edit report where I wish to filter the nodes by taxonomy term.
Can you please post a patch or tell me the file name where I can apply the change manually.
I would be happy to confirm this fix.
Thanks
Comment #4
zabelc CreditAttribution: zabelc commentedI made this change to views_handler_filter.inc...although I believe there is an issue as my list of terms is now repeated twice...
Comment #5
blackandcode CreditAttribution: blackandcode commentedI have the same problem after upgrading to the latest views dev version. I got this error when I'm trying to access the page that has taxonomy exposed filters.
Warning: html_entity_decode() expects parameter 1 to be string, object given in decode_entities() (line 429 of /var/www/vhosts/cdm.bild-studio.me/httpdocs/includes/unicode.inc).
My taxonomy filters are all empty. Here the picture:
Comment #6
mjanouch CreditAttribution: mjanouch commentedQuick fix attached that works for me. But I'm not sure if the options shouldn't be prepared before sanitizing with prepare_filter_select_options() function instead...
Comment #7
blackandcode CreditAttribution: blackandcode commentedWhen will you commit the solution to this bug to dev version?
Comment #8
dawehnerI'm quite confused why this is an object, this shouldn't be the case.
Comment #9
blackandcode CreditAttribution: blackandcode commentedDereine:
I used only default seetup of drupal 7 stable version. Make a view taxonomy exposed filter and again received the same message. If you google the net with this message you will see that a lot of sites has the same error message:
https://www.google.com/search?ix=heb&sourceid=chrome&ie=UTF-8&q=html_ent...()+expects+parameter+1+to+be+string%2C+object+given+in+decode_entities
Comment #10
blackandcode CreditAttribution: blackandcode commentedI definitely going back to stable version until this bug is solved. It is causing too many errors in panels, exposed filters etc...The patch attached here solve one of problem but the error is still there.
Comment #11
wizonesolutionsI couldn't edit my views anymore after applying this patch (tried clearing cache), so I suppose it has some work to go.
The type of exposed filter doesn't really seem to matter. I'm going to be bold and generalize this bug report.
If it helps, this is my
dpm($text);
fromincludes/entities.inc::decode_entities()
.You can basically see that it's the two exposed filters I have. Will try to dig deeper...but I don't have much hope of being able to get my head around this quickly.
Comment #12
wizonesolutionsEhh, going back to stable Views fixes this for now, and, for some reason, I don't get the errors on
drush cc all
that I was before that prompted me to upgrade in the first place. The DB update just changed column size, so not worried about reverting the code for now.(Fix title spelling.)
Comment #13
MurzGot the same problem, rolling back to views 3.3 solves the problem, but views 3.3 have another critical issue: #1450268: Fatal error: Call to undefined function language_fallback_get_candidates().
Patch from #6 solves this issue, and after that I can edit views and at now find none other problems.
Comment #14
ckng#6 works for me
Comment #15
dawehnerIt would be so helpful if someone could explain a way for me to reproduce the issue.
For example provide a view, which tells the actual filter used there.
Comment #16
zhangtaihao CreditAttribution: zhangtaihao commentedSteps to reproduce:
Expected result: When displaying the view (e.g. in the preview), the exposed filter is shown as a select list with terms listed.
Actual result: Each option in the select list is blank. Furthermore, the option values are incorrect (i.e. numeric array indices).
Additionally, here is a reference to the usage of select options as objects:
form_select_options()
. The reasons this isn't a problem in 6.x-3.x are (i) there is noviews_handler_filter::prepare_filter_select_options()
and (ii)views_handler_filter::exposed_translate()
never had to calldecode_entities()
.I have adapted the patch in #6 to emulate the logic in
form_select_options()
.Comment #17
skizzo CreditAttribution: skizzo commentedThe patch works for me (7.x-3.3+45-dev), when applied to a User View (with user account including term reference fields). Thank you...
Comment #18
dawehnerAwesome, just added a small comment about the function in FAPI which is causing that and committed to 7.x-3.x
Comment #19
skizzo CreditAttribution: skizzo commentedPatch does not apply against latest dev (7.x-3.3+122-dev)
Comment #20
dawehner@skizzo
Sure, because it got committed to 7.x-3.x-dev...
Comment #21
mgiffordAny thoughts on the next stable release of views? The last one is from 2012-Feb-22 and it would be good to not have to run the dev version on a production site.
Comment #22
Laura Davila CreditAttribution: Laura Davila commentedThis is true, but I found this discussion because I am running against this same issue on 7.x-3.5. The suggested patch is already in the code. Is there anything else this might be?
Comment #23
anouHello,
Nothing to add, just to confirm that like Laura Davilla, I've got the warning on the 7.x3.5 version. And I'm afraid that I have NO exposed filter at all. So the "warnings" may be cause by something else.
I attach my view to my comment if this is any help. The warnings display on the block_4 display.
Comment #24
anouSorry, I attach the wrong view (I have two on the same page...). After test, the view causing the warnings is the one attached here, forget the previous one :-). Thanks.
EDIT: Trying dev version didn't change nothing, still got the warnings...
Comment #25
anouAfter all, seems to be something with $view->get_title(), for my warnings... I have to say that my view was printed via php (views_get_view()...etc...). After manipulating my php, printing/deleting/doing/undoing the warnings went away. I also left the 7.x-3.5 version. Sorry not to be more precise.
And thanks again.
David
Comment #25.0
anouFixing html
Comment #26
Chris CharltonI'm seeing this error flood my logs. Is this really lingering after >4 years? :(
Comment #27
Chris CharltonBump.
Comment #28
broonMy logs were also flooded by this message and in my case I could track down the error to a custom print template file which called
$view = views_embed_view($view_name, 'block_1', array($node->vid));
Changing it to
$view = views_embed_view($view_name, 'block_1', $node->vid);
(No extra array for third argument)fixed my log flooding.
Comment #29
Chris CharltonGood comment in #28; I'm still hunting for this in my code.
Comment #30
mhmd CreditAttribution: mhmd as a volunteer and commented#28 Fix the issue
Comment #31
DamienMcKennaI wonder if the problem is also caused by some other modules using views_embed_view() incorrectly?
Marking this closed, thank you everyone for working on the fix. Please open a new issue if there is still a related bug in Views itself.