After updating to the latest version of token today, all the custom breadcrumbs stopped working and I started getting the following message:
warning: preg_match_all() expects parameter 2 to be string, array given in [snip]/sites/all/modules/token/token.module on line 705.
After initially thinking this was a bug with token module and supplying a patch to fix it here - #1307890: token_replace() performance when there are no tokens - it turns out that token_replace accepting arrays was unintended functionality that was never meant to be supported and now that there is a performance fixup stopping array input, the module will not work.
So, the fix now is change custom_breadcrumbs_nodeapi() to call token_replace with only strings.
Comment | File | Size | Author |
---|---|---|---|
#14 | custom_breadcrumbs-1327960-14.patch | 887 bytes | Boobaa |
#8 | invalid_use_of_token_replace-1327960-8.patch | 755 bytes | kaare |
#1 | 1327960-custom_breadcrumbs-fix-token-api-use-1.patch | 1.68 KB | ELC |
Comments
Comment #1
ELC CreditAttribution: ELC commentedAttached is a patch that does just that. It also reduxes the calling of token replace to only parts that it's using.
Comment #2
betovargah man... i just updated token and i get "warning: preg_match_all() expects parameter 2 to be string, array given in /Applications/MAMP/htdocs/manati/sites/all/modules/token/token.module on line 701."
Can anyone confirm the patch works?
Comment #3
djmolny CreditAttribution: djmolny commentedFor now, I opted to go with ELC's patch of the token module itself. And yes, that fixed my problem.
Comment #4
Danny_Joris CreditAttribution: Danny_Joris commentedI have this issue in the 6.2-dev branch. The code is different.
Comment #5
Patrizio CreditAttribution: Patrizio commentedThis is the code for the 6.x-2.0-rc1 version
Comment #6
emi_bcn CreditAttribution: emi_bcn commentedHi there,
I have same problem here. Confirmed that the patch solves the bug.
Changed the attributes so module maintainer knows what's happening.
Comment #7
bohz CreditAttribution: bohz commentedThanks, @Patrizio.
#5 works flawlessly
Comment #8
kaareHere's the patch as a .patch ;-)
Indentation fixed to adhere drupal coding style.
Comment #9
MGN CreditAttribution: MGN commentedThanks to everyone for helping on this. I'll review it and commit as soon as I get a free moment (now where did I leave it...)
Comment #10
fzipi CreditAttribution: fzipi commentedI can also confirm that patch solves bug.
Comment #11
fchandler CreditAttribution: fchandler commentedHaving the same problem in 6.x-1.5 of custom breadcrumbs and token 6.x-1.17, 1.18 and 1.dev. I will try the patch. Albeit, i will have to learn how to apply a patch. The other part of that is not having command line access on shared hosting sites. Then there is the problem of running a dev version on a production site, which is something I have been told not to do. So at this point it looks like I have few options other than not updating the Token module or disabling the Custom Breadcrumbs module. Any suggestions?
Comment #12
basvredelingI can confirm patch #8 too. It works fine.
Comment #13
andrewsuth CreditAttribution: andrewsuth commentedPatch #8 works for me too. Nice work.
Comment #14
BoobaaHere is the patch for the latest 6.x stable version.
Comment #15
ntg CreditAttribution: ntg commentedThank you. Patch #8 worked (for 6.x-2.x-dev).
Comment #16
stijnbe CreditAttribution: stijnbe commentedPatch #14 worked for me, thanks.
Comment #17
killua99 CreditAttribution: killua99 commentedThe path #1327960-8: Invalid use of token_replace API - causes preg_match_all errors in token module works for the 6.x-2.x-dev branch.
Thanks.
Comment #18
ahimsauziSame here for #5! Thanks @Patrizio
Comment #19
szt CreditAttribution: szt commented#5 (and #8) works for 6.x-2.0-rc1!
Patrizio++
Comment #20
ehudash CreditAttribution: ehudash commentedPatch #8 worked for me (function _custom_breadcrumbs_get_breadcrumb)
Thanks kaare!
Comment #21
eL CreditAttribution: eL commentedPatch #8 worked for me (for 6.x-2.0-rc1)
Comment #22
Chad_Dupuis CreditAttribution: Chad_Dupuis commentedPatch in #14 for the 6.x-1.5 version did not work for me... I still get the following after patching, updating and clearing all caches...
User notice: The custom_breadcrumbs_nodeapi() function called token replacement with an array rather than a string for $text in token_replace_multiple() (line 263 of /.../sites/all/modules/token/token.module).
Comment #23
ELC CreditAttribution: ELC commentedThe author of Token has insisted that everyone is wrong for using arrays and refused to update the API.
As a result, since 1.18 you now get a warning any time a module uses an array instead of text, instead of a flat our error.
I'm going to open a feature request on Token to update the API documentation, return to the efficient handling of arrays, and remove the warning. Just haven't got around to it yet since it will need to be a rather long request.
You can remove the error being written to the logs by removing the line of code from the Token module. I haven't looked at it to see where it is yet.
Comment #24
Dave ReidA quick update on this from the token maintainer (me): I'm officially backtracking on not supporting $text being an array. I looked back and as of 6.x-1.15 the token_replace() functions officially had it documented that $text could either be a string or an array. This reference to it being an array was removed when I updated the documentation for the functions which I had assumed the array reference was a mistake (which was my fault). At this point in 6.x-1.x-dev (and eventually in the future 6.x-1.19 release) of Token there are no more warnings thrown if $text is an array and token replacement should just work as before. I apologize to the end users of Token who encountered those frustrating notices and the module developers who had these bugs reported against their modules. This experience was at least valuable to know which modules were using array token replacement as they would have encountered this problem when porting modules to Drupal 7. Also, in the official API documentation, $text is a string. The parameter being an array is only supported for backwards-compatibility.
That said, this patch should still probably be committed.
Comment #25
wjackson CreditAttribution: wjackson commentedPatch #14 works for me in 6.x-1.5. Thanks Boobaa!
Comment #26
monotaga CreditAttribution: monotaga commentedPatch at #8 worked for me on 6.x-2.0-rc1.
Comment #27
szt CreditAttribution: szt commentedComment #28
eiland CreditAttribution: eiland commentedI applied path #5 to 2.0 rc and now I don't have an error anymore but my path now reads
"Home › [i18n-vocab] › [i18n-cat] > Title"
Setting is
(Titles: [i18n-vocab]
[i18n-cat]
Paths:
|[vocab-raw]
/[termalias]
WTF?
Comment #29
killua99 CreditAttribution: killua99 commented@eiland: rewrite yours settings. And tell us if that works.
Comment #30
eiland CreditAttribution: eiland commentedi unstalled the module and enabled it again. The brackets are gone, but the functionality didn't return to normal, as I expected it to. I saw the tokens were missing, and i remembered I once patched pathauto.
So I now believe my problem might be due the recent update of pathauto and the lacking i18n integration @#290421: pathauto patch to provide localized and entity translated taxonomy through i18n.
Comment #31
iantresman CreditAttribution: iantresman commentedFor anyone else that is not able to handle, or can not read patch files, the following worked for me for Custom Breadcrumbs 6.x-1.5:
and "rem" them out by adding two slashes at the beginning of the lines:
Comment #32
ryansnow CreditAttribution: ryansnow commentedThank you. This worked perfectly for me.
Comment #33
FiNeX CreditAttribution: FiNeX commentedPatch #8 works fine on Custom breadcrumbs 6.x-2.0-rc1. Thanks.
Comment #34
bomarmonk CreditAttribution: bomarmonk commentedPatch in #8 solved my issue: 6.x-2.0-dev. Thanks!
Comment #35
ngstigator CreditAttribution: ngstigator commentedthanks, patch #8 works for 6.0-rc1.
chris
Comment #36
Lucada CreditAttribution: Lucada commented...also for me!
Comment #37
joep.hendrix CreditAttribution: joep.hendrix commentedpatch #8 works for 6.x-2.x-dev 2011-Jul-16
Comment #38
venusrising CreditAttribution: venusrising commentedPatch 8 does not work for us for 6x-2 rc1 we still get Db errors. Does anyone know where to go from here?
Comment #39
venusrising CreditAttribution: venusrising commentedComment #40
venusrising CreditAttribution: venusrising commentedDave thanks for the reply.
The question is, do you know how to fix this or prevent the massive log pile up in Custom Breadcrumbs 6x2RC1 we have a production site filling up logs. We would be willing to pay for some help.
Comment #41
venusrising CreditAttribution: venusrising commented@FiNeX How did you get the patch to work? I installed patch but I still get the DB errors filling up.
Thanks for your help. Running same version as you 6x2RC1
Comment #42
MGN CreditAttribution: MGN commentedThanks everyone. I agree the patch in #8 is the way to go. Committed to 6.x-1.x-dev. If you still have a problem after trying the latest 6.x-1.x-dev release, please open another issue.
Comment #43
MGN CreditAttribution: MGN commentedComment #44
MGN CreditAttribution: MGN commentedNote: I also committed the fix (more or less) in #5 by Patrizio to the 6.x-2.x-dev branch.
Comment #45
venusrising CreditAttribution: venusrising commented@MGN sorry to reopen but can you tell us what may work with the 6x2 RC1 as we have it on a production site since it has the views integration and is working great for us with the exception of the DB errors
Comment #46
ressa CreditAttribution: ressa commentedPatch in post #8 also works for version 6.x-2.0-rc1, thanks.
Comment #47
venusrising CreditAttribution: venusrising commented@ressa we tried the patch but could not get it to work, what did you do to get it to work, we also are running same version as you.
Comment #48
ressa CreditAttribution: ressa commented@venusrising: I patched it manually in the file, not via the terminal. I know it's not the right way to do it, but I figured the bug would be fixed in the next release, and the changes were minor. Perhaps the patch is made for another version with different line numbers, and that's why it worked for me, but not for you?
Comment #49
sin CreditAttribution: sin commentedFrom #1341138: called token replacement with an array rather than a string for $text,
the error "user notice: The custom_breadcrumbs_nodeapi() function called token replacement with an array rather than a string for $text in /sites/all/modules/token/token.module on line 263." is fixed using token 6.x-1.x-dev
Comment #50
caspercash CreditAttribution: caspercash commented#8 solved my problem! Thanks! Token module version is 6.x-1.18
Comment #51
TwoDThe #8 patch worked for me as well.
Comment #52
carlop CreditAttribution: carlop commentedPatch #8 worked for me too, thanks.
Comment #53
sw3b CreditAttribution: sw3b commented#8 work for me too !!!
Comment #54
opegasus CreditAttribution: opegasus commentedOnly AWESOME
iantresman !!!
Thanks, worked perfectly for me! I had to dig a little since the code was a wee bit different in the latest dev of this module but it killed printing of the token glitch right away. Glad I scrolled though the thread.
I hope the changes don't screw anything else up but time will tell. Since I am not a 'developer', answers like yours are a life saver, thanks again.
Comment #55
Thomas_Zahreddin CreditAttribution: Thomas_Zahreddin commentedthis issue is a duplicate to http://drupal.org/node/1333878 and in 1333878 solved.
This is solved (according to the commit message) with
http://drupalcode.org/project/custom_breadcrumbs.git/commit/f6ee1aa
If you want to get the actual code download any version newer then
custom_breadcrumbs 6.x-2.0-rc1
and meanwhile you can use the -dev - version
http://drupal.org/node/417124
for drush: drush dl custom_breadcrumbs-6.x-2.x
Comment #56
wuiler CreditAttribution: wuiler commentedPatch #8 worked for me, thanks.
Comment #57
mgiffordSo Thomas_Zahreddin just want to confirm that there is no more support for the 1.x versions.
Looks like the upgrade is pretty simple. Any reason not to upgrade to the 2.x version?
Comment #58
Thomas_Zahreddin CreditAttribution: Thomas_Zahreddin commentedwell i listed all options to update to the version 2.x in #55
so you maybe want to close this issue as fixed?
Comment #59
mgiffordSure.. But your response in #55 doesn't clearly answer my question.
I will assume though that everyone should be encouraged to update to the 2.x version of the code.
Comment #60
bburgThe note in #55, that this issue is a duplicate to https://drupal.org/node/1333878 is not accurate because that issue was closed as a duplicate to this one in https://drupal.org/comment/5521980#comment-5521980.