After updating to the latest version of token today, all the custom pages 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.
Amazingly similar to #1327960: Invalid use of token_replace API - causes preg_match_all errors in token module on custom_breadcrumbs.
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_pagers_get_list_from_view() to call token_replace with only strings.
.. patch incoming
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | custom_pager-token_api_fix.patch | 529 bytes | mrwendell |
| #1 | 1327982-custom_pagers-fix-token-api-use-1.patch | 1.08 KB | elc |
Comments
Comment #1
elc commentedThe patch, git am ready.
Comment #2
murfi commented3rd party confirmation; fix worked for me;
thank you
Comment #3
benjf commentedanother successful confirmation of the above patch. Thanks!
Comment #4
cjeffery commentedConfirmed patch is working. Thanks again!
Comment #5
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 #6
宁皓网_王皓 commentedThank you very de!
Comment #7
underpressure commentedI applied the patch but it's still not working. This is what I keep getting:
user notice: The custom_pagers_get_list_from_view() function called token replacement with an array rather than a string for $text in /home/raval0/public_html/sites/all/modules/token/token.module on line 263.Any help?
Comment #8
andriesellis commentedInstalled the 6.x-1.x-dev and problem solved. Thanks very much.
Comment #9
mrwendell commentedHowdy.
May I offer a simpler patch that worked me, based on the same token api issue that happened for the custom_breadcrumb module: #1327960: Invalid use of token_replace API - causes preg_match_all errors in token module
The patch was made out of my subversion repository, but it should all work the same (still have to get on to gitt)
Regards.
Comment #10
ironman_2010 commentedI also have the same issue as underpressure.
I applied the patch but it's still not working. This is what I keep getting:
user notice: The custom_pagers_get_list_from_view() function called token replacement with an array rather than a string for $text in /home/raval0/public_html/sites/all/modules/token/token.module on line 263.
I have tried to use the dev version of both the token module and custom_pagers module. When using these modules the error is not wriiten to the log but I still have the issue where by my photo galleries are not being displayed as before.
Any help?
Comment #11
th.sigit commentedThe patch worked for me. I am using 6.x-1.x-dev version (2011-Feb-25).
Comment #12
grofftech commentedThe patch worked for me too. I am currently using 6.x-1.0-beta2 version with Drupal 6.22. Thanks!
Comment #13
max_d commented#9 patch work for 6.x-1.x-dev.
Thank you, mrwendell!
Comment #14
ebyrne41 commentedI am getting this same error message, although I am using Custom Pagers 6.x-1.0-beta2, not the 'dev' version. (error message - "user notice: The custom_pagers_get_list_from_view() function called token replacement with an array rather than a string for $text in /usr/local/pem/vhosts/109204/webspace/siteapps/10277/htdocs/sites/all/modules/token/token.module on line 263.").
(SEE http://dublincitypubliclibraries.com/content/004-welcome-inn-parnell-st for error showing).
The problem arose when I updated the Token module a few days ago to 6.x-1.18.
Question: If I update the Token module to 6.x-1.x-dev, might this resolve the issue for me (as I am presuming from #5 above by Token maintainer), or is it unwise to install a development release?
Should I instead (or as well) install 6.x-1.x-dev release of the Custom Pagers module?
I am not a developer, and my understanding is that patches are really for developers to test and install. I have examined the process of implementing patches and it does seem too complex for my limited ability.
Thus, I am wanting to know if I should be trying the development release version (of Token and/or Custom Pagers) and might that work?
OR could I roll back the Token module to the version I had prior to upgrading it (token 6.x-1.16)?? And then wait for the next recommended release of Token (token 6.x-1.19)
Any help would be very much appreciated. Eddie
Comment #15
xeontheone commentedAhem, if the patch works, can we expect a maintenance release of Custom Pagers? I just hate to have to manually patch every module I download. In particular when I have to update them.
TIA
Comment #16
geerlingguy commentedSubscribing, and hoping that this will get committed, at least to -dev, sometime :)
Comment #17
cyigitemmy commentedThank you very much for the patch "1327982-custom_pagers-fix-token-api-use-1.patch". It worked!
Comment #18
bvirtual commentedPatch in #1 worked for me. Thanks.