Download & Extend

warning: mb_strlen() expects parameter 1 to be string, array given in /root/htdocs/d6/includes/unicode.inc on line 404.

Project:Paging
Version:6.x-1.0-beta3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Hello

When I activate the dropdown list I have this warning.

Comments

#1

This issue is not related to the specific module, but from hours we spent trying to find out why the this happens, we saw that when you put a "#maxlength" property on a "confirm_password" field this issue arise.
Note that according to FAPI (http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...), #maxlength should be defined only for textfield elements. Remove this property from the password_confirm form element, and you're clear for takeoff.

#2

But there's no password field used in paging. It might something related. Let's see.

#3

I bet its something similar. I would have checked that:
* does the presented page have forms within? I so, carefully check the form's definition. Make sure #maxlength is defined ONLY on textfield form elements.
* I would have also possibly patched the offending source file (unicode.inc), in order to catch and (temporarily) resolve all such possible bugs, with something like:

if $text is array
then
$text = array_shift($text)
watchdog("something terrible happened!!!", 'error')
endif

#4

Status:active» postponed (maintainer needs more info)

According to above explanations, the problems doesn't look like to be emerging from paging. Nor I have any other clue what might be the cause.

#5

Hi, friends. t(...) is not needed:) Patch attached, it also solves the problem described above, which occurred to me too.

AttachmentSize
paging.patch 932 bytes

#6

Is this the right patch file? I don't think so. But it solved the problem manually removing the t(...) from the .module file on the specified lines. Thanks a lot!

#7

Status:postponed (maintainer needs more info)» reviewed & tested by the community

Yes, I can confirm the bug. It occurs when viewing the first and last pages, and the pager is set to a dropdown. t() will return an array if $page_names is called with an invalid offset (negative or larger than the last page), thus breaking truncate_utf8.

Agree that t() is not necessary here, however it still shouldn't be called with invalid indexes. An alternate take:

  if ($pager_current > 1) { 
    $prev_name = truncate_utf8(t($page_names[$pager_current - 2]), 50, TRUE, TRUE);
    $li_previous = theme('pager_previous', (isset($tags[1]) ? $tags[1] : t('Previous page: !prev', array('!prev' => $prev_name))), $limit, $element, 1);
  }

  if ($pager_current < $pager_max) {
    $next_name = truncate_utf8(t($page_names[$pager_current]), 50, TRUE, TRUE);
    $li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : t('Next page: !next', array('!next' => $next_name))), $limit, $element, 1);
  }

#8

Status:reviewed & tested by the community» needs review

#9

I had a blank string as the first parameter of the t() function, like this t(''). I replaced it with '' and the error went away.

--g

#10

You will also witness this behaviour if you inadvertently define #maxlength for a form date field.

#11

Thanks Muggin, you saved the day!

#12

You will also witness this behaviour if you inadvertently define #maxlength for a form date field.

:)

*SOLVED*

nobody click here