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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna’s picture

FYI this is the problem that leads to errors when adding beans to Panels pages: #1925008: Errors when displaying beans in Panels

DamienMcKenna’s picture

Status: Active » Needs review
FileSize
597 bytes

This 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.

merlinofchaos’s picture

There 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. :(

merlinofchaos’s picture

Aha. I can't find it because it's not a patch: #1922044: Latest dev breaks Quicktabs (Panels)

merlinofchaos’s picture

And 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.

DamienMcKenna’s picture

FileSize
859 bytes

This version uses drupal_render().

berdyshev’s picture

I don't sure we should use drupal_render(), it will be rendered later any way. So, for me the patch in #2 is better.

berdyshev’s picture

FileSize
837 bytes

Also, 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

merlinofchaos’s picture

Please 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.

merlinofchaos’s picture

Also, 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.

DamienMcKenna’s picture

FileSize
1.3 KB

@merlinofchaos: In that case would something like this work better?

DamienMcKenna’s picture

FileSize
1.3 KB

Typoo, sorry.

berdyshev’s picture

There are no penalties to running drupal_render

I don't sure. What if someone wants to alter admin info and to display block content in some other way?

+++ b/plugins/content_types/block/block.incundefined
@@ -286,13 +286,24 @@ function ctools_block_content_type_admin_info($subtype, $conf) {
+    elseif (empty($block->title)) {
+      $block->title = t('No title');

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.

dagomar’s picture

#12 works for me.

das-peter’s picture

#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.

saltednut’s picture

#12 is working for me.

Regarding #13 I'd rather see the delta than 'No Title' - at least that's something people can use.

merlinofchaos’s picture

It'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.

saltednut’s picture

@merlinofchaos - Ok I see what you are saying. Can we settle #12 is RTBC then?

merlinofchaos’s picture

Status: Needs review » Reviewed & tested by the community

Yeah, #12 looks good.

berdyshev’s picture

@merlinofchaos, can it be committed?

rei’s picture

still no commit ?

merlinofchaos’s picture

Yes, 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.

gmclelland’s picture

The 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:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /panels/ajax/editor/add-pane/panels_mini%3Aheader/branding/block/views--exp-site_search-page/form
StatusText: OK
ResponseText: Warning: strlen() expects parameter 1 to be string, array given in strlen() (line 1598 of /Users/glenn/websites/7c9d097f-0bc1-457d-8314-1d9e37f102bf/includes/bootstrap.inc).

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

Anonymous’s picture

*really* looking forward to a commit here, am working on a site that uses quicktabs within panels. THANKS!

babyduck’s picture

#12 work for me too.

Sinovchi’s picture

# 12 is working as expected.

vikramy’s picture

#12 works as expected.

deepbluesolutions’s picture

#12 works as expected on two sites im seeing the problem,

ehalber’s picture

I second #24, but #12 has saved the day.

sivapattabhiram’s picture

#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.

algazaras’s picture

FileSize
160.8 KB

Hi 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

DamienMcKenna’s picture

@algazaras: Would you mind explaining what part of UI in the screenshot is not working the way you would expect?

algazaras’s picture

@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

DamienMcKenna’s picture

@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:

    if (!empty($block->content)) {
      // If this isn't a simple string then it needs to be rendered first.
      if (!is_string($block->content)) {
        //$block->content = drupal_render($block->content);
        dpm($block);
      }
      //$block->content = filter_xss_admin($block->content);
    }

(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.

imoreno’s picture

#12 saved my site... working as expected.

algazaras’s picture

@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

DamienMcKenna’s picture

@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.

algazaras’s picture

FileSize
244.01 KB

This image is what I get after doing that change, but the panes are still broken

DamienMcKenna’s picture

@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?

algazaras’s picture

@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

DamienMcKenna’s picture

@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?

Exploratus’s picture

#12 works for me.

algazaras’s picture

@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..

Rajab Natshah’s picture

#12 works .. Thanks DamienMcKenna

Scott M. Sanders’s picture

#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.

Anonymous’s picture

Just 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.

Khun’s picture

FileSize
136.29 KB

Hi! #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.

Anonymous’s picture

Hi 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.

j3ann0t’s picture

#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.

kenorb’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
DamienMcKenna’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

@kenorb: Any particular reason to change the status?

kenorb’s picture

The 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?

DamienMcKenna’s picture

@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.

kenorb’s picture

Backtrace:

21: strlen() (Array, 1 element)
args (Array, 1 element)
0 (Array, 1 element)
#markup (String, 46793 characters ) <div class="view view-categories-grouped view-i...
20: drupal_validate_utf8() (Array, 2 elements)
file (String, 27 characters ) includes/bootstrap.inc:1587
args (Array, 1 element)
0 (Array, 1 element)
#markup (String, 46793 characters ) <div class="view view-categories-grouped view-i...
19: filter_xss() (Array, 2 elements)
18: filter_xss_admin() (Array, 2 elements)
file (String, 24 characters ) includes/common.inc:1402
args (Array, 1 element)
0 (Array, 1 element)
#markup (String, 46793 characters ) <div class="view view-categories-grouped view-i...
17: ctools_block_content_type_admin_info() (Array, 2 elements)
file (String, 74 characters ) sites/all/modules/contrib/ctools/plugins/conten...
args (Array, 3 elements)
0 (String, 30 characters ) views-categories_grouped-block
1 (Array, 2 elements)
override_title (Integer) 0
override_title_text (String, 0 characters )
2 (Array, 0 elements)
16: ctools_content_admin_info() (Array, 2 elements)
file (String, 57 characters ) sites/all/modules/contrib/ctools/includes/conte...
args (Array, 4 elements)
0 (Array, 16 elements)
1 (String, 30 characters ) views-categories_grouped-block
2 (Array, 2 elements)
3 (Array, 0 elements)
15: panels_renderer_editor->render_pane() (Array, 2 elements)
file (String, 95 characters ) sites/all/modules/contrib/panels/plugins/displa...
args (Array, 1 element)
0 (Object) stdClass
14: panels_renderer_standard->render_panes() (Array, 2 elements)
13: panels_renderer_standard->render_layout() (Array, 2 elements)
12: panels_renderer_editor->render() (Array, 2 elements)
11: panels_edit_display_form() (Array, 2 elements)
10: panels_panel_context_edit_content() (Array, 2 elements)
 9: call_user_func_array() (Array, 1 element)
 8: drupal_retrieve_form() (Array, 2 elements)
 7: drupal_build_form() (Array, 2 elements)
 6: ctools_wizard_multistep_form() (Array, 2 elements)
 5: _page_manager_get_operation_content() (Array, 2 elements)
 4: page_manager_get_operation_content() (Array, 2 elements)
 3: page_manager_edit_page_operation() (Array, 2 elements)
 2: call_user_func_array() (Array, 1 element)
 1: menu_execute_active_handler() (Array, 2 elements)
 0: main() (Array, 2 elements)
kenorb’s picture

@DamienMcKenna:
Thank you for the info and for explaining the status, it makes more clearer.

galooph’s picture

#12 has worked for me too.

Khun’s picture

Hi! 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!

RaulMuroc’s picture

Applied the patch in comment #12 to latest stable Ctools 7.x-1.3 but the error persists:

I get it in:

admin/structure/pages/nojs/operation/page-front_page/handlers/page_front_page_panel_context/content

I have all the modules to the latest stable release: panels, views, ctools, cck, location, entity api, etc....

Attached image.

saltednut’s picture

@RaulMuroc - did you try applying the patch to the latest HEAD? (dev)

GrahamAIT’s picture

Updating to 1.3 caused this error for us but the patch in comment #12 fixed everything.

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.08 KB

I 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.

saltednut’s picture

Status: Needs review » Reviewed & tested by the community

#61 applies cleanly and I'm not seeing any errors.

DamienMcKenna’s picture

+1. Thanks for taking the time to look at this, Tim.

GrahamAIT’s picture

Patch in #61 solves the problem for us as well.

mcfilms’s picture

I 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.

tim.plunkett’s picture

Status: Reviewed & tested by the community » Fixed

Thanks 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.

Triumphent’s picture

#12 fixed it for me. Thanks! :)

Countzero’s picture

Latest dev fixes it. Thanks guys.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mcfilms’s picture

I'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?

merlinofchaos’s picture

This 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.

rwoldezghi’s picture

#61 works! Thanks!

Triumphent’s picture

*Smiles*
:)

Anonymous’s picture

#12 worked perfect for me.

Other notice disappears too.
Thk!

millionleaves’s picture

Latest -dev version (+3) worked for me, as per #71. Thanks.

dublutz’s picture

#61 patch worked for me. Thanks!

LeviThomason’s picture

7.x-1.3+3-dev works!

aliciagh’s picture

#61 works perfect for me. Thanks!

jatorresdev’s picture

#61 patch worked for me. Thanks

drupov’s picture

7.x-1.3+3-dev works too!

Anonymouse’s picture

Version: 7.x-1.x-dev » 7.x-1.3
Status: Closed (fixed) » Active
FileSize
53.11 KB

After 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.

hass’s picture

Status: Active » Closed (fixed)
hass’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
mcfilms’s picture

@Anonymouse Hass is, I believe, indicating that this IS fixed in the development branch, to please install that one and give it a try.

kiff’s picture

Status: Closed (fixed) » Reviewed & tested by the community

#61 works!

kenorb’s picture

How about:

$block->title = t('(no title)');

instead of:

$block->title = t('No title');

?

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Closed (fixed)

This 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.

jenlampton’s picture

patch still applies cleanly to latest stable release.

Exploratus’s picture

Can we get this committed?

DamienMcKenna’s picture

@Exploratus: It was, see comment #66 from Tim Plunkett, who's a CTools co-maintainer.

talpageo’s picture

Status: Closed (fixed) » Reviewed & tested by the community

patch #61 [ctools-1925018-61.patch] worked for me

das-peter’s picture

Status: Reviewed & tested by the community » Fixed

Quoting DamienMcKenna - with highlights:

This issue was already fixed (as of #66), 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.

DamienMcKenna’s picture

Can someone please lock this issue? There's no benefit to be gained by any further comments.

ferdienandp’s picture

Version: 7.x-1.x-dev » 7.x-1.3
Priority: Normal » Critical

Thanks 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

hass’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Priority: Critical » Normal

Better than locking a case would be tagging a new release. What is the problem in tagging a new release?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

reyshk’s picture

Status: Closed (fixed) » Needs review

12: ctools-n1925018-12.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 12: ctools-n1925018-12.patch, failed testing.

DamienMcKenna’s picture

Issue summary: View changes
Status: Needs work » Closed (fixed)

Do 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.

Bizio’s picture

#61 works fine for me: Core 7.23, Ctools 7x-1.3, Panel 7x-3.3

Thanks :)

Ted51’s picture

Status: Closed (fixed) » Needs review

12: ctools-n1925018-12.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 12: ctools-n1925018-12.patch, failed testing.

DamienMcKenna’s picture

Status: Needs work » Closed (fixed)

Once 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:

  1. Apply the ctools-1925018-61.patch patch that Tim Plunkett provided in comment #61 above.
  2. Download the -dev release of CTools.
dadderley’s picture

Thank 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.

Type php
Date Tuesday, November 19, 2013 - 15:17
User admin
Location https://mysite.ca/admin/structure/pages/nojs/operation/node_view/handler...
Referrer https://mysite.ca/project/example-project
Message Notice: Array to string conversion in filter_xss() (line 1442 of /home/safetywizard/public_html/includes/common.inc).
Severity notice
Hostname xx.xx.xx.xxx
Operations

I can edit the panel now and the error is gone.

dkane’s picture

The latest .dev release solved this issue for me. Thank you very much everyone for your work on this!

RaulMuroc’s picture

Yep, latest -dev release works nice :) HOpe soon will be included in the Stable release.

subadmin’s picture

Thanks for #61
issue
solved :)

Patrick Nelson’s picture

Yeah. #61. awesome.

DamienMcKenna’s picture

FYI this fix was in the recent 7.x-1.4 release, everyone should update.

Now, lets leave this issue be.

fnikola’s picture

I 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