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.
According to the documentation for hook_block_view, the 'content' element returned..
may be a renderable array (preferable) or a string containing rendered HTML content.
However, in ctools_block_content_type_admin_info() it does the following:
if (!empty($block->content)) {
$block->content = filter_xss_admin($block->content);
}
Unfortunately, if a renderable array is returned by hook_block_view then filter_xss_admin() is passed in an array instead of a string and you end up with the following errors:
Notice: Array to string conversion in drupal_validate_utf8() (line 1573 of includes/bootstrap.inc).
Warning: preg_match() expects parameter 2 to be string, array given in drupal_validate_utf8() (line 1579 of includes/bootstrap.inc).
So, in short, ctools_block_content_type_admin_info() needs to be updated to handle renderable arrays.
Comment | File | Size | Author |
---|---|---|---|
#61 | ctools-1925018-61.patch | 1.08 KB | tim.plunkett |
Comments
Comment #1
DamienMcKennaFYI this is the problem that leads to errors when adding beans to Panels pages: #1925008: Errors when displaying beans in Panels
Comment #2
DamienMcKennaThis does a quick check to ensure that $block->content is a string, though it's worth discussing whether it should render() the $block->content if it's anything else.
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedThere is another patch that does a render, but doesn't actually do the string check, though I'm having trouble finding it. I saw the patch recently, though. Too much traffic. :(
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedAha. I can't find it because it's not a patch: #1922044: Latest dev breaks Quicktabs (Panels)
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedAnd yes, if it's not a string, we need to do a drupal_render there, because obviously you can't filter_xss on an array.
Alternatively, we could add a #theme_wrapper which does that, maybe. Seems kind of overkill, though.
Comment #6
DamienMcKennaThis version uses drupal_render().
Comment #7
berdyshev CreditAttribution: berdyshev commentedI don't sure we should use drupal_render(), it will be rendered later any way. So, for me the patch in #2 is better.
Comment #8
berdyshev CreditAttribution: berdyshev commentedAlso, if block has empty subject, block content won't be displayed in admin UI of page manager. But maybe this issue is new one and doesn't relate to this one.
So, in total, the patch from #2 and fix for this issue will look like this
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedPlease bear in mind that this content is only for administrative information, and not a true rendering of the block. There are no penalties to running drupal_render, but there *are* penalties to not running the xss filter, so #2 is a nogo for me, IMO.
Comment #10
merlinofchaos CreditAttribution: merlinofchaos commentedAlso, since it's for administrative purposes, I think we need to use something like t('No title') rather than '' to ensure that the portlet can be clicked on.
Comment #11
DamienMcKenna@merlinofchaos: In that case would something like this work better?
Comment #12
DamienMcKennaTypoo, sorry.
Comment #13
berdyshev CreditAttribution: berdyshev commentedI don't sure. What if someone wants to alter admin info and to display block content in some other way?
If title will be empty, the 'No title' will be set up later (I think, by the page manager). So we can leave this string empty.
Comment #14
dagomar CreditAttribution: dagomar commented#12 works for me.
Comment #15
das-peter CreditAttribution: das-peter commented#12 works for me too and I think that's a viable approach.
Regarding #13: How about using the delta when no title is set? That gives at least a hint what you're dealing with in the admin-UI.
Comment #16
saltednut#12 is working for me.
Regarding #13 I'd rather see the delta than 'No Title' - at least that's something people can use.
Comment #17
merlinofchaos CreditAttribution: merlinofchaos commentedIt's an administrative view of the data. It's not really for 'use', it's just a convenience. I don't think putting the delta there is right, as it's supposed to be showing you what will be rendered, in that case.
Comment #18
saltednut@merlinofchaos - Ok I see what you are saying. Can we settle #12 is RTBC then?
Comment #19
merlinofchaos CreditAttribution: merlinofchaos commentedYeah, #12 looks good.
Comment #20
berdyshev CreditAttribution: berdyshev commented@merlinofchaos, can it be committed?
Comment #21
rei CreditAttribution: rei commentedstill no commit ?
Comment #22
merlinofchaos CreditAttribution: merlinofchaos commentedYes, it can be committed. No I haven't gotten to committing it yet. I'm sorry but I am not working the CTools queue every day or even consistently. Unfortunately this isn't a paid job, so I get to it when I can get to it.
Comment #23
gmclelland CreditAttribution: gmclelland commentedThe patch in #12 fixed the problem were I was getting ajax errors when trying to add a view to a mini panel.
Here is the errors I was getting:
I also was seeing these errors whenever I tried to edit any mini-panel
Warning: strlen() expects parameter 1 to be string, array given in /srv/bindings/9f0b8cccd3d54a24ad76303384bf2336/code/includes/bootstrap.inc on line 1598
Notice: Array to string conversion in /srv/bindings/9f0b8cccd3d54a24ad76303384bf2336/code/includes/common.inc on line 1434
After the patch the problems are gone. Yay
Comment #24
Anonymous (not verified) CreditAttribution: Anonymous commented*really* looking forward to a commit here, am working on a site that uses quicktabs within panels. THANKS!
Comment #25
babyduck CreditAttribution: babyduck commented#12 work for me too.
Comment #26
Sinovchi CreditAttribution: Sinovchi commented# 12 is working as expected.
Comment #27
vikramy CreditAttribution: vikramy commented#12 works as expected.
Comment #28
deepbluesolutions CreditAttribution: deepbluesolutions commented#12 works as expected on two sites im seeing the problem,
Comment #29
ehalber CreditAttribution: ehalber commentedI second #24, but #12 has saved the day.
Comment #30
sivapattabhiram CreditAttribution: sivapattabhiram commented#12 works fine for me. I just started building something using panels and ran into this problem immediately while adding some blocks to it - thanks for the patch.
Comment #31
algazaras CreditAttribution: algazaras commentedHi there,
I had the same error, and #12 kind of solved it... In the log I don't see it anymore. However, it hasn't solved the problem in some of my panels UI. I attach an image so you can see what's happening to me.
Any help would be much appreciated
Comment #32
DamienMcKenna@algazaras: Would you mind explaining what part of UI in the screenshot is not working the way you would expect?
Comment #33
algazaras CreditAttribution: algazaras commented@DamienMcKenna
Thanks for your fast response. Well, the thing is I can't change the panes, because they show some of the info inside, but they don't display the corner cog to change their settings.
So, I'm stuck
Comment #34
DamienMcKenna@algazaras: Now that is weird :-\ Are there any JavaScript errors reported in your browser? Can you please install the devel module and change the code to the following:
(i.e. comment out the block content)
That will help identify the block that is causing the problems, there might be some extra JS or CSS passed through that are breaking it.
Comment #35
imoreno CreditAttribution: imoreno commented#12 saved my site... working as expected.
Comment #36
algazaras CreditAttribution: algazaras commented@DamienMcKenna
Thanks for your response. I am a newbie in debugging matters, so bear with me..
I have found these errors in the Javascript console:
Uncaught TypeError: Cannot call method 'height' of undefined
(anonymous function)
Drupal.tableHeader.eventhandlerRecalculateStickyHeader js_3GlTOfVt0gm93DcA0I4L0vKEQDuTDdlSk-lqQCMHZqs.js:439
c jquery.min.js:16
d.event.handle jquery.min.js:16
k.handle.m jquery.min.js:16
d.event.trigger jquery.min.js:16
d.fn.extend.triggerHandler jquery.min.js:16
Drupal.tableHeader js_3GlTOfVt0gm93DcA0I4L0vKEQDuTDdlSk-lqQCMHZqs.js:421
(anonymous function) js_3GlTOfVt0gm93DcA0I4L0vKEQDuTDdlSk-lqQCMHZqs.js:369
d.extend.each jquery.min.js:16
d.fn.d.each jquery.min.js:16
$.fn.once js_IkgOrrVZK1UTp2HktvFi5vo1g7b25Muyr5GoySikuic.js:55
Drupal.behaviors.tableHeader.attach js_3GlTOfVt0gm93DcA0I4L0vKEQDuTDdlSk-lqQCMHZqs.js:368
(anonymous function) js_IkgOrrVZK1UTp2HktvFi5vo1g7b25Muyr5GoySikuic.js:156
d.extend.each jquery.min.js:16
Drupal.attachBehaviors js_IkgOrrVZK1UTp2HktvFi5vo1g7b25Muyr5GoySikuic.js:154
Drupal.theme.placeholder js_IkgOrrVZK1UTp2HktvFi5vo1g7b25Muyr5GoySikuic.js:492
f.resolveWith jquery.min.js:16
d.extend.ready jquery.min.js:16
c.addEventListener.y jquery.min.js:16
3
Uncaught TypeError: Cannot call method 'height' of undefined
(anonymous function)
Drupal.tableHeader.eventhandlerRecalculateStickyHeader js_3GlTOfVt0gm93DcA0I4L0vKEQDuTDdlSk-lqQCMHZqs.js:439
c jquery.min.js:16
d.event.handle jquery.min.js:16
k.handle.m
Also, I have installed Devel, but I don´t know how to change the code as you suggest. Should I install XHProf extension as well?
Thanks a lot for your help
Comment #37
DamienMcKenna@algazaras: You don't need to install xhprof, you just need a text editor to change the lines in plugins/content_types/block/block.inc to match what I listed above.
Comment #38
algazaras CreditAttribution: algazaras commentedThis image is what I get after doing that change, but the panes are still broken
Comment #39
DamienMcKenna@algazaras: Hrm. What module is being used to generate the menu bar block? I wonder if rendering the block is causing a module to insert other JS that's then breaking the display?
Comment #40
algazaras CreditAttribution: algazaras commented@DamienMcKenna
Wow!
I just deactivated the "Administration menu Toolbar style" module and the panes came back.
I wonder, should I revert the block.inc file to its original form?
Thanks a lot. You spared me a lot of time
Comment #41
DamienMcKenna@algazaras: Thanks for the update, but I'm still interested to know if you were using any custom modules to display the "menu inferior" menu? And you're sure the problem didn't happen until after you applied the patch?
Comment #42
Exploratus CreditAttribution: Exploratus commented#12 works for me.
Comment #43
algazaras CreditAttribution: algazaras commented@DamienMcKenna
I arrived to this page because I had the problem with the UI, and my log showed this notice:
Notice: Array to string conversion in drupal_validate_utf8() (line 1573 of includes/bootstrap.inc).
So, after I applied the patch the advice was gone but not the problem with the UI.
Regarding the "menu inferior", this is quite strange. I was using it as a regular pane. As I told you, I deactivated the "Administration menu Toolbar style", and now I don't see the pane in the node page manager. However I do see the menu in the node.
I am quite confused..
Comment #44
Rajab Natshah CreditAttribution: Rajab Natshah commented#12 works .. Thanks DamienMcKenna
Comment #45
Scott M. Sanders CreditAttribution: Scott M. Sanders commented#12 works for me too, just the errors remained on all admin pages until I logged out and back in. (Yes I did flush caches first.)
And it seems that now when I edit a mini panel's content, all the text in the admin UI is bold..? But it works again.
Comment #46
Anonymous (not verified) CreditAttribution: Anonymous commentedJust another vote for patch in #12, fixed this vexing problem and I can now access "admin/config/people/accounts/display". Thanks DamienMcKenna! Hope this patch is committed as soon as possible.
Comment #47
Khun CreditAttribution: Khun commentedHi! #12 did not work for me. It eliminated the error message when i open the panel for edition, but i still can´t add views in to the panels, and the view that i had already add now its gone. What can i do? im kind of new in this thing.
I added an image of the panel look.
Comment #48
Anonymous (not verified) CreditAttribution: Anonymous commentedHi Khun:
I think you are experiencing a different problem. This is a very specific problem with displaying content in the Admin UI. You seem to be having a general problem with a view displaying on a panel. If you have any more details go ahead an post and I will take a look, but I suspect your problem is not related to this topic.
Comment #49
j3ann0t CreditAttribution: j3ann0t commented#12 worked perfect for me too. Fixed everything regarding warnings with Views/mini-pannels and Ctools (of the type described in #1003188: Warning: strlen() expects parameter 1 to be string in drupal_validate_utf8(), line 1503 /includes/bootstrap.inc ).
Tx.
Comment #50
kenorb CreditAttribution: kenorb commentedComment #51
DamienMcKenna@kenorb: Any particular reason to change the status?
Comment #52
kenorb CreditAttribution: kenorb commentedThe reason is that the patch should be committed. Sorry, maybe I misunderstood the status to be ported.
Patch is available from February 24 and was tested by several people and by me, as I've the same errors when using with Panels.
Any plans of committing the patch?
Comment #53
DamienMcKenna@kenorb: RTBC is for when the patch has been tested and approved by others; "Patch (to be ported)" is for when an existing patch in the issue needs to be ported to another branch of the module, e.g. from D6 to D7, etc. At this point we're just waiting for one of the module's maintainers to have the time to commit the patch.
Comment #54
kenorb CreditAttribution: kenorb commentedBacktrace:
Comment #55
kenorb CreditAttribution: kenorb commented@DamienMcKenna:
Thank you for the info and for explaining the status, it makes more clearer.
Comment #56
galooph CreditAttribution: galooph commented#12 has worked for me too.
Comment #57
Khun CreditAttribution: Khun commentedHi! i think that i have multiple errors with this. I had the error related to this post and solved with the patch, but i have other errors related to the panopoly distribution. Cant create the personalized content in the panels and all the content related to type of content page was erased with this instalation. Im opening a particular issue in the panopoly distribution hoping for help.
Thanks!
Comment #58
RaulMuroc CreditAttribution: RaulMuroc commentedApplied the patch in comment #12 to latest stable Ctools 7.x-1.3 but the error persists:
I get it in:
I have all the modules to the latest stable release: panels, views, ctools, cck, location, entity api, etc....
Attached image.
Comment #59
saltednut@RaulMuroc - did you try applying the patch to the latest HEAD? (dev)
Comment #60
GrahamAIT CreditAttribution: GrahamAIT commentedUpdating to 1.3 caused this error for us but the patch in comment #12 fixed everything.
Comment #61
tim.plunkettI hit this today, but have a slightly more streamlined solution. render() wraps drupal_render() and does that check for us.
If someone can test this, I'll commit it once its RTBC again.
Comment #62
saltednut#61 applies cleanly and I'm not seeing any errors.
Comment #63
DamienMcKenna+1. Thanks for taking the time to look at this, Tim.
Comment #64
GrahamAIT CreditAttribution: GrahamAIT commentedPatch in #61 solves the problem for us as well.
Comment #65
mcfilms CreditAttribution: mcfilms commentedI just applied this patch and it solved my errors. The site appears to be functioning normally. I was going to switch the status to RTBC, but I see it is already there. I would say Tim's #61 patch is good to go for the next cTools update.
Comment #66
tim.plunkettThanks everyone!
Committed http://drupalcode.org/project/ctools.git/commitdiff/280ccd0
There will not be a new CTools release for this bug, but you can either continue using this patch against the stable version, or update to the new dev release that should appear in the next 12 hours.
Comment #67
Triumphent CreditAttribution: Triumphent commented#12 fixed it for me. Thanks! :)
Comment #68
Countzero CreditAttribution: Countzero commentedLatest dev fixes it. Thanks guys.
Comment #70
mcfilms CreditAttribution: mcfilms commentedI'm confused because I am getting this error again.
Several weeks back I applied this patch and it fixed this error. Today I was notified of a newer version of cTools, so I updated it. Now I get this error again. Was this patch not actually committed to the actual release and is still only in the dev?
Comment #71
merlinofchaos CreditAttribution: merlinofchaos commentedThis was committed to -dev, but after the last release. I think at this moment it is the only patch that's committed and not in a release. Either apply the patch or update to the -dev, for now.
Comment #72
rwoldezghi CreditAttribution: rwoldezghi commented#61 works! Thanks!
Comment #73
Triumphent CreditAttribution: Triumphent commented*Smiles*
:)
Comment #74
Anonymous (not verified) CreditAttribution: Anonymous commented#12 worked perfect for me.
Other notice disappears too.
Thk!
Comment #75
millionleaves CreditAttribution: millionleaves commentedLatest -dev version (+3) worked for me, as per #71. Thanks.
Comment #76
dublutz CreditAttribution: dublutz commented#61 patch worked for me. Thanks!
Comment #77
LeviThomason CreditAttribution: LeviThomason commented7.x-1.3+3-dev works!
Comment #78
aliciagh CreditAttribution: aliciagh commented#61 works perfect for me. Thanks!
Comment #79
jatorresdev CreditAttribution: jatorresdev commented#61 patch worked for me. Thanks
Comment #80
drupov CreditAttribution: drupov commented7.x-1.3+3-dev works too!
Comment #81
Anonymouse CreditAttribution: Anonymouse commentedAfter a clean install of drupal (intl--Dutch) the 7.x-1.3 version of ctools, the error as described above is appearing.
Error::
Warning: strlen() expects parameter 1 to be string, array given in drupal_validate_utf8() (regel 1587 van C:\Programs\xampp\htdocs\snelnieuws.nu\includes\bootstrap.inc).
Notice: Array to string conversion in filter_xss() (regel 1442 van C:\Programs\xampp\htdocs\snelnieuws.nu\includes\common.inc).
Notice: Array to string conversion in filter_xss() (regel 1442 van C:\Programs\xampp\htdocs\snelnieuws.nu\includes\common.inc).
Notice: Array to string conversion in filter_xss() (regel 1442 van C:\Programs\xampp\htdocs\snelnieuws.nu\includes\common.inc).
Notice: Array to string conversion in filter_xss() (regel 1442 van C:\Programs\xampp\htdocs\snelnieuws.nu\includes\common.inc).
And more of the same.
It would be nice to have this fixed.
Kind regards.
Comment #82
hass CreditAttribution: hass commentedComment #83
hass CreditAttribution: hass commentedComment #84
mcfilms CreditAttribution: mcfilms commented@Anonymouse Hass is, I believe, indicating that this IS fixed in the development branch, to please install that one and give it a try.
Comment #85
kiff CreditAttribution: kiff commented#61 works!
Comment #86
kenorb CreditAttribution: kenorb commentedHow about:
instead of:
?
Comment #87
DamienMcKennaThis issue was already fixed, there's no need to RTBC it anymore, if you want the fix either apply the most recent patch above or grab the latest -dev release.
Comment #88
jenlamptonpatch still applies cleanly to latest stable release.
Comment #89
Exploratus CreditAttribution: Exploratus commentedCan we get this committed?
Comment #90
DamienMcKenna@Exploratus: It was, see comment #66 from Tim Plunkett, who's a CTools co-maintainer.
Comment #91
talpageo CreditAttribution: talpageo commentedpatch #61 [ctools-1925018-61.patch] worked for me
Comment #92
das-peter CreditAttribution: das-peter commentedQuoting DamienMcKenna - with highlights:
Comment #93
DamienMcKennaCan someone please lock this issue? There's no benefit to be gained by any further comments.
Comment #94
ferdienandp CreditAttribution: ferdienandp commentedThanks Tim.
#66 - Fixed my issue.
my case was, right after i upgraded from 7.22 to 7.23. All panels were inaccessible. Thou the panel pages are view-able but i can't edit them nor add new panels.
please note that I chose ver 7.x-1.3 in compliance only but the drupal core version that i use is : 7.2.3
Comment #95
hass CreditAttribution: hass commentedBetter than locking a case would be tagging a new release. What is the problem in tagging a new release?
Comment #97
reyshk CreditAttribution: reyshk commented12: ctools-n1925018-12.patch queued for re-testing.
Comment #99
DamienMcKennaDo not change this issues status - the fix ha already been committed to git, just grab the -dev release or apply the most recent patch to fix your site.
Comment #100
Bizio CreditAttribution: Bizio commented#61 works fine for me: Core 7.23, Ctools 7x-1.3, Panel 7x-3.3
Thanks :)
Comment #101
Ted51 CreditAttribution: Ted51 commented12: ctools-n1925018-12.patch queued for re-testing.
Comment #103
DamienMcKennaOnce again, stop messing with this issue. We don't need any more comments, we don't need the tests ran again.
As a reminder, if your site is experiencing this bug you have two choices:
Comment #104
dadderley CreditAttribution: dadderley commentedThank you for fixing this in the dev release.
My scenario has Quicktabs in a panel page. When going to edit the panel I was getting a WSOD and in the error log I saw this.
I can edit the panel now and the error is gone.
Comment #105
dkane CreditAttribution: dkane commentedThe latest .dev release solved this issue for me. Thank you very much everyone for your work on this!
Comment #106
RaulMuroc CreditAttribution: RaulMuroc commentedYep, latest -dev release works nice :) HOpe soon will be included in the Stable release.
Comment #107
subadmin CreditAttribution: subadmin commentedThanks for #61
issue
solved :)
Comment #108
Patrick Nelson CreditAttribution: Patrick Nelson commentedYeah. #61. awesome.
Comment #109
DamienMcKennaFYI this fix was in the recent 7.x-1.4 release, everyone should update.
Now, lets leave this issue be.
Comment #110
fnikola CreditAttribution: fnikola commentedI can confirm the patch in #12 corrected the following error on 7.x-1.3:
PHP Fatal error: Unsupported operand types in /home2/northwa8/public_html/includes/common.inc on line 4461