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:

<?php
 
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.

Comments

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

Status:Active» Needs review
StatusFileSize
new597 bytes
PASSED: [[SimpleTest]]: [MySQL] 68 pass(es).
[ View ]

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.

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

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

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.

StatusFileSize
new859 bytes
PASSED: [[SimpleTest]]: [MySQL] 68 pass(es).
[ View ]

This version uses drupal_render().

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.

StatusFileSize
new837 bytes
PASSED: [[SimpleTest]]: [MySQL] 68 pass(es).
[ View ]

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

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.

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.

StatusFileSize
new1.3 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/ctools/plugins/content_types/block/block.inc.
[ View ]

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

StatusFileSize
new1.3 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch ctools-n1925018-12.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Typoo, sorry.

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.

#12 works for me.

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

#12 is working for me.

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

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.

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

Status:Needs review» Reviewed & tested by the community

Yeah, #12 looks good.

@merlinofchaos, can it be committed?

still no commit ?

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.

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

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

#12 work for me too.

# 12 is working as expected.

#12 works as expected.

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

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

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

StatusFileSize
new160.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

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

@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

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

<?php
   
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.

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

@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

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

StatusFileSize
new244.01 KB

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

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

@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

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

#12 works for me.

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

#12 works .. Thanks DamienMcKenna

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

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.

StatusFileSize
new136.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.

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.

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

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

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

@kenorb: Any particular reason to change the status?

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?

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

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)

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

#12 has worked for me too.

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!

StatusFileSize
new20.21 KB

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.

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

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

Status:Reviewed & tested by the community» Needs review
StatusFileSize
new1.08 KB
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es).
[ View ]

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.

Status:Needs review» Reviewed & tested by the community

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

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

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

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.

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.

#12 fixed it for me. Thanks! :)

Latest dev fixes it. Thanks guys.

Status:Fixed» Closed (fixed)

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

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?

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.

#61 works! Thanks!

*Smiles*
:)

#12 worked perfect for me.

Other notice disappears too.
Thk!

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

#61 patch worked for me. Thanks!

7.x-1.3+3-dev works!

#61 works perfect for me. Thanks!

#61 patch worked for me. Thanks

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

Version:7.x-1.x-dev» 7.x-1.3
Status:Closed (fixed)» Active
StatusFileSize
new53.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.

Status:Active» Closed (fixed)

Version:7.x-1.3» 7.x-1.x-dev

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

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

#61 works!

How about:

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

instead of:
<?php
$block
->title = t('No title');
?>

?

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.

patch still applies cleanly to latest stable release.

Can we get this committed?

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

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

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

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.

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

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

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.

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.

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.

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

Thanks :)

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.

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.

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.

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

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

Thanks for #61
issue
solved :)

Yeah. #61. awesome.

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

Now, lets leave this issue be.