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.
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).
Comment | File | Size | Author |
---|---|---|---|
#28 | 1923616-28.patch | 584 bytes | joshmiller |
Comments
Comment #1
Dave ReidIt means that the $string parameter passed into token_replace() is not a string.
Comment #2
NancyDruFound it
Comment #3
sahaj CreditAttribution: sahaj commentedGot 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.
Comment #4
MrPaulDriver CreditAttribution: MrPaulDriver commentedGot this too. I'm lost, any ideas?
Comment #5
NancyDruCheck your calls against the API.
Comment #6
MrPaulDriver CreditAttribution: MrPaulDriver commented@NancyDru I'm a site builder, the API stuff is over my head I'm afraid.
Comment #7
jminker CreditAttribution: jminker commentedI'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!
Comment #8
jackalope CreditAttribution: jackalope commentedThat 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.
Comment #9
francescosciamanna CreditAttribution: francescosciamanna commented@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
Comment #10
memoo CreditAttribution: memoo commentedDisabling Metatag: Google+ (metatag_google_plus) 7.x-1.4 made the warning disappear in my case.
Comment #11
scott.browne CreditAttribution: scott.browne commentedDisabling Metatag: Google+ (metatag_google_plus) 7.x-1.4 made the warning disappear in my case.
This worked for me, thank you
Comment #12
kamenrs CreditAttribution: kamenrs commentedDisabling Metatag: Google+ (metatag_google_plus) 7.x-1.4 made the warning disappear, is working perfectly in my case too.
Thanks a lot.
Comment #13
jaydee1818 CreditAttribution: jaydee1818 commentedI'm also getting this error and none of the suggestions so far have worked for me.
Comment #14
inversed CreditAttribution: inversed commentedI notice that I get this error after updating Feeds to the latest dev version (7.x-2.0-alpha8+71-dev).
Comment #15
samozin CreditAttribution: samozin commentedWarning: 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 ?
Comment #16
ikeigenwijs CreditAttribution: ikeigenwijs commentedWe also got this issue 2 times on every page.
Comment #17
borntosucceed CreditAttribution: borntosucceed commentedsame here disabling google+ fixed it. Interesting though problem only started happening after I installed the Other module adding the other option to selectboxes.
Comment #18
meaton CreditAttribution: meaton commentedI had the same issue and can also confirm that disabling Metatag: Google+ removed the warnings.
Comment #19
jelo CreditAttribution: jelo commentedDid 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...
Comment #20
borntosucceed CreditAttribution: borntosucceed commentedTested 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
Comment #21
ikeigenwijs CreditAttribution: ikeigenwijs commentedWe don't use the google+ module so the source of this problem is elsewhere or 2 sources.
Comment #22
jelo CreditAttribution: jelo commentedBased 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...
Comment #23
vladimirkomarek CreditAttribution: vladimirkomarek commentedi have the same problem, fixed disabling google plus metatag module. i hope they will fix that soon
Comment #24
ikeigenwijs CreditAttribution: ikeigenwijs commentedAfter 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.
Comment #25
mastoll CreditAttribution: mastoll commented@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.
Comment #26
ikeigenwijs CreditAttribution: ikeigenwijs commentedI 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.
Comment #27
bjlewis2 CreditAttribution: bjlewis2 commentedThanks jminker! Unchecking and rechecking the "comment on same page" box as described in #7 worked for me!
Comment #28
joshmillerI'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().
Comment #29
joshmiller