Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#8 | preg-match-simpletest.patch | 1.01 KB | Gábor Hojtsy |
#5 | l10n_update-db_prefix-array-937298-5.patch | 970 bytes | Sutharsan |
Comments
Comment #1
grootte CreditAttribution: grootte commentedproblem is fixed in dev version when not updating database. after database update the problem is back
Comment #2
grootte CreditAttribution: grootte commentedComment #3
Sutharsan CreditAttribution: Sutharsan commentedI 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.
Comment #4
-redShadow- CreditAttribution: -redShadow- commentedThis 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:
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..Comment #5
Sutharsan CreditAttribution: Sutharsan commentedI can not find any simpletest which uses an array of prefixes, therefore a simple check could solve this issue.
Comment #6
Sutharsan CreditAttribution: Sutharsan commentedAnyone interested in getting this fixed? Please test and review the patch.
Comment #7
Gábor HojtsyDrupal core has the same handling, I'd just look there (it had a similar bug for some time too :).
Comment #8
Gábor HojtsyIndeed, this is what core has in Drupal 6:
Updated patch attached and committed.