Closed (won't fix)
Project:
Drupal core
Version:
6.14
Component:
drupal.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Feb 2008 at 05:00 UTC
Updated:
22 Jan 2010 at 15:40 UTC
Hi,
I keep getting this error:
warning: preg_match() expects parameter 2 to be string, array given in /home/newmill/public_html/includes/bootstrap.inc on line 670.
I am using Drupal 5.7, cck, cck_address, cck_address_extension, image, nf_registration_mod, and many more.
Please tell me why is this error persisting ? How can I fix it ?
Thanks,
Hanly
Comments
Comment #1
nancydruThis may be a problem with search forms (http://drupal.org/node/219591).
Comment #2
nancydruI did a search on this message and it's turning up a lot and being blamed on a bunch of different modules. I think it's a core issue with the Form API, probably on search forms, and possibly related to blocks. Since it's so prevalent, I'm marking this critical to get some core folks to look at it. (BTW, I am also seeing this in 6.0.)
Comment #3
nancydruThis was originally opened against 5.7, so it is an ongoing issue.
Comment #4
xurizaemonFor us, it appears to originate from within search.module.
drupal_validate_utf8() is called on this array:
The preg_match() fails because the second argument supplied is an array, not a string.
We have Drupal 5.7 / PHP 5.2.0-8+etch5~pu1, and enough modules loaded that I won't bother listing them unless asked :)
Comment #5
nancydruBased on all the hits I get when I searched on this, I'd say this has to be the most frequently encountered bug in Drupal - and it's not getting much attention. But I hav to admit, just about every case I've seen was the result of a bad call.
Comment #6
sunjournal commentedYeah, I'm getting there error too, but it appears to be self inflicted. I'm using hook_search() in an attempt to make a Sphinx Search module. If I turn off my module, and clear my cache, this error goes away.
Comment #7
nancydruI patched my drupal_validate_utf8() so that anything other than a string returns "false". I don't know if this is good or not. I guess I could post a patch.
Comment #8
ingacosta commentedAre you using transliteration.module? I think my problem is because of this module.
Comment #9
nancydruNo, I'm not using that. The sources of this are MANY. The problem is inadequate error-detection in this function.
Comment #10
chx commentedIt's not adequate to add array detection to drupal_validate_utf8 instead that's called bloat. You very likely have a broken form which passes an array to check_plain instead of a string. If we would suppress the error as some here wants to do then you won't see a helpful error message alerting you to this fact.
Comment #11
nancydruI agree that my check is probably not the thing to do. The error message is not in the least helpful. There is nothing that helps to track down the offending element, not even a backtrace provides anything useful.
Comment #12
yngens commentedsubscribing.
Comment #13
mssarath commentedsubscribing
Comment #14
mssarath commentedmy error got solved, it was problem with email function. drupal 6 email parameters are different. as the error shows something in core, we can't understand which cause the error.
Comment #15
scottrigbyIs there any debug code we can add to track down the offending form? in my case, I see this error at the top of workflow_ng rule configs page. yet I've been using this for a long time now and haven't seen it before. I'm trying to retrace my steps but this is not really possible after a certain point.
I try to implement reasonable test plans along the way during development & configuration of sites, but I can't check every admin page after every small change I make (not possible).
So any advice about how to deal with this would be appreciated – even if not the 'right' way (like adding some temporary debug code in bootstrap.inc) – I'm just not quite knowledgeable enough about this to know what to add.
Thanks in advance!
Scott
Comment #16
nancydruAbout all I can suggest is to go into drupal_validate_utf8 and check if the text is a string. If not, do a print_r on it so you might get an idea of what the error is.
Comment #17
scottrigbyNancy, you mean go into function drupal_validate_utf8 in bootstrap.inc? If so, here's what we've got on line 666 (lovely number btw!) which returns the error on line 670:
(I'm working in D5.7)
Sorry to have to ask, but I'm not sure what you mean "check if the text is a string"? :p
Also, where do I put the print_r to debug? It would help if you could be *slightly* more specific – cause while I've used print_r I'm still a bit of a noob :) thanks!
Comment #18
nancydruBefore the "if" statement, try something like:
Comment #19
xurizaemonFor me, this happens on a site where I copy the DB from a live to testing server. It indicates that one of the serialised config variables is borked, and I just need to edit the config settings and save that variable to fix it. (Happens to be theme edit -> save that fixes this for me.)
You might not have the same issue (unless, like me, you do something like
mysqldump drupal | sed -e 's#site1#site2#g' | mysql test_drupal). By doing so, I'm loading "bad" data into my DB, so the warning is being helpful and telling me so.This issue has been marked "won't fix" because the warning is actually a useful indicator that something else is wrong and needs fixing. Find that problem and fix it, rather than hiding the error message.
You can just hide the warning, but what will help MORE is to do a bit of debugging and learn where this bad string is coming from, so you can handle it better.
Comment #20
kulfi commentedSubscribing - also receiving this error.
Comment #21
As If commentedSubscribing. I'm getting this error while working on and then subsequently viewing a View. The error message appears on the "Edit View" page as soon as any change is made to the View, and it also appears on the public page in which this View is mounted as a Block. I'm using Views 6.x-2.x-dev, and Date/Calendar 6.x-2.x-dev. I mention the latter because the error began appearing after I played with adding a date-based filter to my view. After looking around up here, the problem seems to be bigger than any one contrib module. Still have no idea what's causing it.
Comment #22
nancydruWell, if you notice in #10, chx marked this "won't fix;" that pretty much means core developers aren't looking at this issue any more.
Comment #23
jlmeredithI had the same issue with this error. My solution was to disable the module that allows for photo uploading during registration. http://drupal.org/project/reg_with_pic Disabled - error goes away.
Comment #24
As If commentedYeah I know, Nancy, I'm just using this page as an excuse to hang around talking about it ;-) I think it's a legacy thing in various modules, and I think it's working its way out of the system. Old habits die hard...
Comment #25
amariotti commentedI'm getting the error on a views edit page and no where else. Not sure what the deal is. I might try to recreate the view to see if that solves the problem.
Comment #26
pingvinen commentedGot this problem after I installed the imagefield module for D6.
Comment #27
LejfM commentedI got the error too, after implementing a production site, using the test DB, as i changed some thing in the testsite ... i gor the error ..
but what to do ?
Comment #28
xurizaemonLejfM, there are many causes of this error, but the comment above which sounds most similar to your situation is #19.
You don't say which of the suggestions above you've tried already.
Try re-reading my earlier comment, and if that doesn't help you could try a few of the other suggestions above too.
Do post back what you learn, so that others may share your wisdom when they face the same challenge at a later date!
Thanks
Comment #29
ericinwisconsin commentedI got this error too recently, but it disappeared when I updated to the newest version of Views (6.x-2.3).
-----------------
EDIT: Ok, I spoke too soon. It's back.
This is odd, because it's only happening on one of the 10+ Drupal sites I host. Here's a list of the modules I use on that one site that I do NOT use on any of the others. They're all the latest versions. I hope this helps:
OpenID (Core, but the only site I actually use it on.)
Content Profile
SimpleTest
Token Actions
Rules
Comment #30
d.cox commentedsorry found http://drupal.org/node/431186 which fit my issue
Comment #31
vm commentedComment #32
blagrone commentedThis is on 6.12 - I'm not sure where else to post it. If anyone can direct me to a more relevant area, please do.
I was able to solve this problem by editing the bootstrap file on line 771 and also the previous function to this affect:
I had some modules wanting to pass an array, or mixed string/array through the preg_match filter. I edited it to 'if array'>'implode array' before passing to the filter. It seems to have worked so far in our beta testing.
I have also considered writing a separate preg_match type filter for the array, but have not had the time to do so and likely will not as this seems to work for me.
If it continues to work I might do a patch.
I'd like any feedback on this.
Comment #33
xurizaemondrupal_validate_utf8() does not accept arrays as input.
Patching core to remove the error message is simply masking your real issue, which is that some other module or function is passing inappropriate data to
drupal_validate_utf8().See chx's reply above giving the reason for marking this issue won't fix.
Please do not work around this issue by patching your core files, for reasons which are better explained elsewhere.
Instead, you should debug a little further to where the problem has originated rather than where the error message appears.
Because you're working on a development install (right?) and have the devel module installed, you can temporarily add a snippet of code like this to the start of drupal_validate_utf8() to debug the issue -
... which will show you the preceding functions and arguments which led to the passing of an array or other non-string data into drupal_validate_utf8().
That's where the problem lies. You may have to dig a little further (eg, "Why is it that search.module is getting handed an array of search terms when it expects a string?") but the solution is definitely not to add code to a string validation function to make it deal with non-string input.
That's why this issue is marked won't fix.
If you get stuck debugging, please ask for help in the forums, on IRC (via web), or by asking for paid support before adding another workaround / comment to this issue.
Thanks, and good luck!
Comment #34
blagrone commentedThanks Xurizaemon,
I get the point: I have to go to the module that wants to pass an array and implode it (or whatever it takes) there.
And follow the rule: "DO NOT HACK CORE"
Ben
Comment #35
tejuspratap commentedFor me everything was working properly until I enabled "Optimize JS files" option from the Performance admin.
Then I started getting this error. The error was being thrown from the function check_plain(). I modified the function as follows.
I am not sure why this error did not turn up until I enabled JS optimization.
Comment #36
amariotti commented@tejuspratap: I just checked and my JS Optimization is disabled and I've been having this issue since we upgraded.
Is this possible that this issue is showing up for upgraded Drupal installs from 5.x? Any other upgraders out there?
Comment #37
nancydruI have upgraded many and rarely use JS optimization. In my experience, #33 is correct. Frankly, I'd like to see it changed, but that would take a new issue.
Comment #38
balik kampung commentedIt happened to me while sending email to more than one address(recipient) in a single email. However if i send an email invitation to a single recipient; no error.
I request mssarath (#13, #14) to give me the details of how he has overcome the problem as he mentioned that he too encounter the error while sending email.
Any other folks who has encountered the same error while sending email and has successfully resolved please post your solutions.
Thanks.
Making your journey memorable forever
www.balikampung.com
Comment #39
xurizaemonBalik (and the next person who comes in via Google), please refer to comments #10 and #33 above which explain why this issue is marked WON'T FIX.
This is not the issue you're looking for.
Comment #40
scothiam commented#18 was very helpful, thanks NancyDru :)
This told me what was going wrong and saved a tonne of trouble shooting
Comment #41
davidinnes commentedFor the record I started getting a version of the error (/includes/bootstrap.inc on line 771) while correcting taxonomy spelling errors in /admin/content/taxonomy/x
Unfortunately I didn't notice *which* change it was.
Based on the type of the error (regular expression getting something besides a string) I'm curious if I introduced a duplicate that's being returned as, I dunno, maybe a record count or an array containing the two duplicates instead of the expected string? Total speculation, obviously. If I can find something obvious in the database I'll report back.
Comment #42
nancydruSee #18 and #33
Comment #43
summit commentedSubscribing, having this error using taxonomy hierarchical select.
Greetings, Martijn
Comment #44
nancydruThen report it to the HS maintainer - it is not a core problem.
Comment #45
summit commentedI am not sure it is a HS thingie..will investigate more...
Trying #33, but got memory problems with Devel. Particularly Krumo! I set memory on settings.php to 500M! But still problems with Devel. Will still investigate more.. greetings, Martijn
EDIT: The HS is fixed, it was a label not filled in.
Having this issue now with newest ctools /panels..
Comment #46
nflowers1228 commentedI'm getting the error in the views module. I created a view to list events/dates similar to one that already existed, and the error suddenly appeared.
Comment #47
nflowers1228 commentedI reverted teh view I was working with to the default view and the error went away. I lost my work, but didn't loose any content. Since I wasn't sure what I had, and am new in the development end of Drupal, I figured it was the easiest thing to do.
Comment #48
danny_joris commentedHi,
I have this error as well. I would love to find the bug according to #33, but I don't know how to do this.
How do I do this? I can see that Devel allows me to add a snippet of php, but how do I add this "to the start of drupal_validate_utf8()" ?
Tnx in advance for any help.
Danny
Comment #49
vm commented@ Danny_Joris have you read #18 and #33 as instructed by others with similar questions?
Comment #50
danny_joris commentedGreat, tnx.
I managed to copy the right code and at one point where I always have this error, this is the output: http://dannyjoris.be/files/fora/preg_match-debug.png . I don't really know what to look for here...
I am also wondering: could it be related to this: http://drupal.org/node/372710#comment-2102300 . I added that Patch. I believe it has to do with uft-code, but I'm not sure what that is.
I feel I shouldn't discuss this here, but I wouldn't know where, because I don't know the cause yet.
Cheers,
Danny
-- Edit: I solved this issue thanks to a lot of help from bdragon on irc chat. It appeared that there was no default time set for the drupal install and that conflicted with a custom content type called Events, which uses a Date cck field...
--Edit2: This preg_match error came back very quickly. After a long search i found that this was caused by Rootcandy after all. It was this issue: #656558: $items passed to theme('item_list',...) may contain subarrays from menu_navigation_links's $menu_tree . I upgraded to the .dev version and that fixed it. I still don't understand how to find the source of preg_match errors though.
Comment #51
andy2009 commentedComment #52
heine commentedI've closed this issue for further comments.
Here's the procedure once again, copied from #33:
drupal_validate_utf8() does not accept arrays as input.
Patching core to remove the error message is simply masking your real issue, which is that some other module or function is passing inappropriate data to
drupal_validate_utf8().See chx's reply above giving the reason for marking this issue won't fix.
Please do not work around this issue by patching your core files, for reasons which are better explained elsewhere.
Instead, you should debug a little further to where the problem has originated rather than where the error message appears.
Because you're working on a development install (right?) and have the devel module installed, you can temporarily add a snippet of code like this to the start of drupal_validate_utf8() to debug the issue -
... which will show you the preceding functions and arguments which led to the passing of an array or other non-string data into drupal_validate_utf8().
That's where the problem lies. You may have to dig a little further (eg, "Why is it that search.module is getting handed an array of search terms when it expects a string?") but the solution is definitely not to add code to a string validation function to make it deal with non-string input.
That's why this issue is marked won't fix.
If you get stuck debugging, please ask for help in the forums, on IRC (via web), or by asking for paid support before adding another workaround / comment to this issue.
Thanks, and good luck!