After updating to D6rc4, while searching some keywords through the search engine, I got this error (and without my search result) :

warning: preg_match() expects parameter 2 to be string, array given in /home/mydomain/includes/bootstrap.inc on line 709.

pictogram

Comments

pictogram’s picture

Well in fact, the results are there, but still with the warning message.

gábor hojtsy’s picture

Are you sure that this module causes the warning? This comes from the code inside drupal_validate_utf8(). Which might be used by some filter on your site, but is not used by l10n_client itself. It might use drupal_validate_utf8() indirectly though. The "search engine" you mention is the search box with the X by its side at the bottom part of the page?

gábor hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)
pictogram’s picture

No, no, let me clarify my post.

I'm not talking about the search box within the localization client. I'm talking about the drupal search engine. The search box returns this error when l10n_client is installed. I tried uninstalling every module and it stopped when I deactived the client. Reinstalling it returned again the same error ?!?!?

I know that bootstrap.inc is a core file but since activating the client returns an error inside it, I thought it would most probably come from the client ?? But maybe I'm wrong ???

gábor hojtsy’s picture

Title: warning: preg_match() » warning: preg_match() with locale module search box

Hm, interesting. It would be great if someone else could reproduce this.

macedigital’s picture

Here is a way to reproduce:

Do a fresh drupal 6.0 install, enable the l10n_client module (and its dependencies). Enable "search box" in garland theme settings, so the search box is omnipresent in the left sidebar and type random search strings.
Result: Every result page will display this error.

I can confirm, that if l10n_client module is not enabled, there is not the message warning: preg_match() expects parameter 2 to be string, array given in /path/to/drupal6/includes/bootstrap.inc on line 721.

Function drupal_validate_utf8() triggers the warning, which expects to preg_match a string, but is given an array. If one explicitly typecasts the passed $text var, the function will work. The array passed to the function which causes the warning comes from the function l10n_client_search(), from l10n_client.module, line 210.

Then I got interested as to why this specific form api array is passed through the drupal_validate_utf8() function. My take is it, that former function actually implements the hook_search() function. I don't know if this is intended here ?

function l10n_client_search() {
  global $language;
  // Selector and editing form.
  $form = array();
  $form['search'] = array(
    '#type' => 'textfield',
  );
  $form['clear-button'] = array(
    '#value' => "<input id='search-filter-clear' class='form-submit' type='button' value='".t('X')."'/>",
  );
  return $form;
}

After I renamed the above function to l10n_client_search_form() the warning message went away.

gábor hojtsy’s picture

Yes, it sounds reasonable that it indeed implements the search hook.

gábor hojtsy’s picture

Status: Postponed (maintainer needs more info) » Fixed

I committed this change to fix the issue: http://cvs.drupal.org/viewcvs/drupal/contributions/modules/l10n_client/l... Thanks for the analysis, much appreciated. Now onto releasing the fixes.

macedigital’s picture

You're welcome :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

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