How do I track this down:

Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan() (line 124 of C:\wamp\www\Core7\includes\token.inc).
CommentFileSizeAuthor
#28 1923616-28.patch584 bytesjoshmiller
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

It means that the $string parameter passed into token_replace() is not a string.

NancyDru’s picture

Status: Active » Closed (works as designed)

Found it

sahaj’s picture

Version: 7.x-1.4 » 7.x-1.5
Status: Closed (works as designed) » Active

Got the same message, but don't know how to solve it.
@NancyDru or some one could maybe give more details? I'm having it on an entityform page.
Thanks for help.

MrPaulDriver’s picture

Issue summary: View changes

Got this too. I'm lost, any ideas?

NancyDru’s picture

Check your calls against the API.

MrPaulDriver’s picture

@NancyDru I'm a site builder, the API stuff is over my head I'm afraid.

jminker’s picture

I'm posting this in case someone else might need it.

I've been getting this same error lately on most every page, and nothing addressed in the few threads I've found gave me any clues. What I figured out was that the error only showed up on pages with comments on them (which are most pages on my site). So I experimented by editing one of my content types. I unchecked the box in the comment settings that says, "Show reply form on the same page as comments." After testing it numerous times on pages of that type, the errors stopped.

But I didn't like having the comment box on a different page because it separates it from my menus, and it gives no return options. I really didn't want to fool around setting that up. So I rechecked the box. I went back to verify that the errors would come back by visiting a few pages, but I wasn't getting any more errors on that content type.

I also edited one more thing for the content type. In the Content Display tab, and then the Custom Display Settings, I checked the Token box. Saved it, and then went back and changed the format option to Plain Text.

Whether both things are needed, I don't know, but all I can say is that the hundreds of errors have ceased!

jackalope’s picture

That post was a huge help, jminker--thank you!

I was having similar problems on a site, and also noticed that the errors seemed to occur only on pages with comments on them. Comments are closed across the entire site, so there seemed no harm in unchecking the "Show reply form on the same page as comments." box. After doing so, the errors stopped for me, too.

francescosciamanna’s picture

@jminker: Thank you again for give the SOLUTION! unchecking "Show reply form on the same page as comments." has flawlessly resolved this problem on my siter once it for all! It's definitely a Bug, moreover in my case this trick solved me also a problem that practically blocked all my comment until today(from beginning of september), that was:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND s.context = '' AND s.textgroup = 'default'' at line 1: SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = AND s.context = :context AND s.textgroup = 'default'; Array ( [:language] => it [:context] => ) in locale()

I'll post this issue also somewhere else in order to share our experience, but I want to ask you jiminker, have you installed some particular module? I suspect that is a fatal combination of some buggy modules that afflicted our sites... what do you think?
Cheers! Francesco

memoo’s picture

Disabling Metatag: Google+ (metatag_google_plus) 7.x-1.4 made the warning disappear in my case.

scott.browne’s picture

Disabling Metatag: Google+ (metatag_google_plus) 7.x-1.4 made the warning disappear in my case.

This worked for me, thank you

kamenrs’s picture

Disabling Metatag: Google+ (metatag_google_plus) 7.x-1.4 made the warning disappear, is working perfectly in my case too.

Thanks a lot.

jaydee1818’s picture

I'm also getting this error and none of the suggestions so far have worked for me.

inversed’s picture

I notice that I get this error after updating Feeds to the latest dev version (7.x-2.0-alpha8+71-dev).

samozin’s picture

Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan() (line 124 of /home/xxx/public_html/ar/includes/token.inc).

the same with me any solutions ?

ikeigenwijs’s picture

We also got this issue 2 times on every page.

borntosucceed’s picture

same here disabling google+ fixed it. Interesting though problem only started happening after I installed the Other module adding the other option to selectboxes.

meaton’s picture

I had the same issue and can also confirm that disabling Metatag: Google+ removed the warnings.

jelo’s picture

Did anyone post this in the issue queue of metatags module? It sounds like that module is passing the wrong parameter, at least in a good number of cases...

borntosucceed’s picture

Tested this again on another site. The problem only started happening after I had installed the select_or_other module and changed the page type to Other.

The only way to get rid of the error was to disable the google+ module.

also posted this under MetaTag issues: https://www.drupal.org/node/2449425

ikeigenwijs’s picture

We don't use the google+ module so the source of this problem is elsewhere or 2 sources.

jelo’s picture

Based on Dave's comment in #1 it would be caused by any module implementing token_replace() with wrong parameters, i.e. it is likely that it can be triggered by multiple different modules. But given that Google+ was mentioned so many times, it seems to be one of the likely candidates...

vladimirkomarek’s picture

i have the same problem, fixed disabling google plus metatag module. i hope they will fix that soon

ikeigenwijs’s picture

After some debugging and tracing on a local copy.

I found that in function token_scan($text) in /includes/token.inc
the $matches is undefined when the function is processed.
This gives NULL what gives all the warnings.

So where should $matches be filled? its not passed as a parameter.
I dont know the code of the token module at all but if someone would guide me we may find it together.

mastoll’s picture

@ideigenwijs, how did you find that?

I'm experiencing this error but neither of the two symptom-solutions above are relevant to my site. So I'm interested in an ultimate solution.

ikeigenwijs’s picture

I used php storm and step by step debugging with brakepoints.
This gives you a list of all defined variables in the scope.

I also did a search to find where the function is being used.
The next step is to disable all modules involved one by one to find the culprit.

We do not use the google+ module.

I find it very strange the $matches is not passed as parameter, but tokens works most of the time so it gets them from somewhere.

Maybe good to know, we use all the stable releases, and not the dev releases of the modules.

bjlewis2’s picture

Thanks jminker! Unchecking and rechecking the "comment on same page" box as described in #7 worked for me!

joshmiller’s picture

Title: preg_match_all() expects parameter 2 to be string » token_scan() throws warnings if given something other than string.
Project: Token » Drupal core
Version: 7.x-1.5 » 7.x-dev
Component: Code » token system
Category: Support request » Bug report
Priority: Normal » Minor
Status: Active » Needs review
Issue tags: +Novice
FileSize
584 bytes

I'm not expecting this patch to be accepted into core, but these warnings are annoying for a lot of us. If this function is misused, let's avoid the warning and return an empty array().

joshmiller’s picture