On the page /admin/build/translate/update I get:
warning: preg_match() expects parameter 2 to be string, array given in /sites/all/modules/l10n_update/l10n_update.inc on line 250.

parameter 2 is the output of $GLOBALS['db_prefix']
wich in my case should be "wvk_" as this is my db_prefix.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

grootte’s picture

Status: Active » Closed (fixed)

problem is fixed in dev version when not updating database. after database update the problem is back

grootte’s picture

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

Status: Active » Postponed (maintainer needs more info)

I have installed drupal core with a database prefix on mysql database, installed the latest dev of l10n_update, enabled locale + admin menu + devel. Dowloaded the translations, installed an old version of a module, updated the translation, downloaded the latest version of this module, updated the translation again. And still got no error.

@grootte: Please describe all steps to reproduce your error.

-redShadow-’s picture

This happened once to me too. The problem, I guess, comes from the fact that $db_prefix is not always a string, but it could be an array too. If you need (as I do) to share some tables among different sites, you would use something like this in you settings.php:

$db_prefix = array(
  'default' => '',
  'users' => 'shared_tables.',
  'sessions' => 'shared_tables.',
  'authmap' => 'shared_tables.',
  'role' => 'shared_tables.',
  'users_roles' => 'shared_tables.',
);

Of course, this will cause problems if passed to preg_match() as second parameter.
I'm not 100% absolutely sure this is the cause of that issue, but there's a good 95% of choice that this is causing some problems.. If you do not need to run simpletest in a multi-prefix database setup, I guess you'd better check that is_array($_GLOBALS['db_prefix']) too before using preg_match..

Sutharsan’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
970 bytes

I can not find any simpletest which uses an array of prefixes, therefore a simple check could solve this issue.

Sutharsan’s picture

Anyone interested in getting this fixed? Please test and review the patch.

Gábor Hojtsy’s picture

Drupal core has the same handling, I'd just look there (it had a similar bug for some time too :).

Gábor Hojtsy’s picture

Version: 6.x-1.0-alpha2 » 6.x-1.x-dev
Status: Needs review » Fixed
FileSize
1.01 KB

Indeed, this is what core has in Drupal 6:

$ grep -r "simpletest" *
includes/common.inc:  if (is_string($db_prefix) && preg_match("/^simpletest\d+$/", $db_prefix, $matches)) {

Updated patch attached and committed.

Status: Fixed » Closed (fixed)

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