It first appeared when I updated to the newest CCK, Facebook Style Statuses, Cumulus, and OG for Drupal 6.6. I have removed each and everyone of these modules completely and it has not gone away. I have run update.php a few times. Optimized the database. Cleared the cache. Did some cron runs. Looked up the issues here at Drupal.org followed some of the advice hear except I did not want to run a patch listed here which I do not know will cause problems in the future . I do not know much php so I was wondering if anyone knew anything else I could do to tackle this problem . Any help is appreciated.
I have the most up to date php. I have an apache server. Its drupal version 6.6. All drupal paths are affected. It happens when I use any kind of web browser.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | drupal-n332345.patch | 856 bytes | damienmckenna |
Comments
Comment #1
DaveIsFluffy commentedThis normally stings me when I double up on a form element. How it got me: I was working on a module that displayed user profiles, so I started off with the profile.module and got hacking (this was not only my first Drupal code ever, also my first PHP).
To cut a long story short, when accessing pages that had common elements between my module and profile.module, there were two elements that had the same name and so PHP had avoided throwing an error by making the two strings into an array.
To do some troubleshooting on this, start disabling modules till it starts working again. The direct path (to side step any errors like you've seen) is /admin/build/modules
Comment #2
damienmckennaHere's a patch that modifies drupal_attributes() to support attribute values that are arrays.
Comment #3
boftx commentedI just got hit with what is essentially the same error with the project bundle:
From looking at many other reports for this and similar errors, and looking at the code, it seems to me that the culprit is the check_plain function itself.
That function is called for many different reasons. This error is going to be produced whenever it is called to check a display field that potentially has an array value such as is provided by a pulldown select field.
I believe the correct fix for this, which will fix many different contrib modules at thesame time, is to have check_plain detect an array and then call drupal_validate_utf8 on each member of the array, replaceing as needed. Here is the logic I am proposing:
I am not a PHP person, I work mainly in perl and c, or I would do this myself.
Again, a search for "warning: preg_match() expects parameter 2 to be string" indicates that this is a very common problem and the intermitent nature is driving people nuts.
Comment #4
damienmckennaboftx: I think it's perfectly acceptable for a string function to only handle strings, it's the responsibility of other code to ensure that only strings are passed to it - most languages work this way, a does PHP itself.
Comment #5
boftx commentedI agree with your statement in principle, and in my own shop would enforce that ruthlessly.
But given how widespread this is, and the apparent ability for code to call check_plain with an array unbeknownst to the programmer, I think some defensive action is called for. Most of the reports I have read stem from using a view or CCK fields. This implies that an end-user could conceivably create an error of this type simply by changing an existing field.
Because of this I submit for consideration that this function, check_plain, needs to be re-implemented to handle arrays as well as strings. A review of some of the modules having this problem will probably indicate what the expected return needs to be when called with an array. It might well be that simply modifying the values in-place will be sufficient.
If nothing else, an error message with a reasonable back trace should be produced.
Thank you for responding.
Comment #6
drupdruppalpal commentedhi,
same here,
what do you think about that solution?
http://drupal.org/node/525036
i dont like but i need to solve it.
regards
Comment #7
webel commentedfollowing, after many hours trying to get behind this problem after upgrading to Drupal6.15 and many recommended module upgrades:
How diagnose: warning: preg_match() expects parameter 2 to be string, array given in .../includes/bootstrap.inc 777