After upgrading to version 6.x-1.10 I get this error when viewing a translated node:
htmlspecialchars() expects parameter 1 to be string, array given in C:\inetpub\vhosts\fysiomed.com\httpdocs\includes\bootstrap.inc on line 856.

When I revert to version 6.x-1.09 the error is gone.

CommentFileSizeAuthor
#11 1316786-11.patch595 bytesgiorgosk

Comments

finex’s picture

I've reproduced this bug too.

castawaybcn’s picture

Same here.

ehudash’s picture

Priority: Normal » Major

I have the same issue.
It causes all my webforms to show English texts instead of the relevant language translation - looks like a major issue to me.

Thanks in advance.

UPDATE: the error come from check_plain($text) function in bootstrap.inc file, on line:
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
Hope this helps.

juliv’s picture

Status: Active » Fixed

fixed: http://info4admins.com/warning-htmlspecialchars-expects-parameter-1-be-s...
Line 856 in bootstrap.inc:

// 'original code in line 856' return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
// fix
return (preg_match('/^./us', (string)$text) == 1) ? htmlspecialchars((string)$text, ENT_QUOTES, 'UTF-8') : '';
pacufist’s picture

Category: bug » support
Status: Fixed » Needs review

Hm, why don`t we have type validation of $term in this part:

/**
 * Implementation of hook_token_values().
 */
function i18ntaxonomy_token_values($type, $object = NULL, $options = array()) {
...
      case 'taxonomy':
       $term = $object;
       $values['i18n-term-raw'] = i18nstrings("taxonomy:term:$term->tid:name", $term->name);
       $values['i18n-term'] = check_plain(i18nstrings("taxonomy:term:$term->tid:name", $term->name));
      break;
...
}
bartezz’s picture

Status: Needs review » Needs work

@Pacufist; you seem to be my life saver! I had the whole watchdog full of the htmlspecialchars() expects parameter 1 to be string error and couldn't find out why! Looks like your post was spot on!

Changed the code to:

$values['i18n-term'] = check_plain((string)i18nstrings("taxonomy:term:$term->tid:name", $term->name));

And this seems to stop all the watchdog errors popping up! Not sure if this is the best solution but it works for now!

Cheers

PS. The fix mentioned by juliv is over the top... type validation in i18ntaxonomy.module is what we need I think!

tomsm’s picture

about #6: Where do I need to change the code ?

OK, I have found the file: i18ntaxonomy.module.

Tested it: the error is gone. Thanks!

birdsarah’s picture

Fix #4 worked great for me - thanks!

nogat’s picture

Priority: Major » Normal

#6 worked fine for me

thank you

christiaan_’s picture

#6 is a great solution. Thank you.

giorgosk’s picture

Status: Needs work » Needs review
StatusFileSize
new595 bytes

solution from #6 works for me
here is a patch for it please test

Status: Needs review » Needs work

The last submitted patch, 1316786-11.patch, failed testing.

bartezz’s picture

Status: Needs work » Needs review

Thanx for patch, works for me! Line endings set aside (always have trouble with these as well)

bartezz’s picture

Status: Needs review » Reviewed & tested by the community

Sorry... wrong status!

daluxz’s picture

Patch works for me. Thanks!

vasrush’s picture

This is working for me too.
Thanks

jose reyero’s picture

Version: 6.x-1.10 » 6.x-1.x-dev
Status: Reviewed & tested by the community » Needs work

Besides the patch not passing automated tests, it doesn't fix the real bug, which is: why is i18nstring() returning a non string value?

bartezz’s picture

Patch not passing automated tests because of windows style line endings, always have trouble with those myself. Patch is good and although not completely fixing the cause (a returned array in stead of a returned string) it makes sure things do work...

jose reyero’s picture

@Bartezz,

Ok but we are not 'hiding bugs'. We are trying to *fix* bugs here.

jose reyero’s picture

Status: Needs work » Closed (duplicate)