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.
After updating the Token Module from 6.x-1.16 to 6.x-1.17, my dblog prints the following error when displaying a view:
preg_match_all() expects parameter 2 to be string, array given in /etc/drupal6/all/modules/token/token.module on line 701.
And, in the view of question some fields are empty. Thus my views are now broken! Worked fine in the 6.x-1.16 version.
Comment | File | Size | Author |
---|---|---|---|
#6 | update-viewfield-token-replacement-for-api-change-1329428-6.patch | 815 bytes | keithm |
Comments
Comment #1
storytellerjeff CreditAttribution: storytellerjeff commentedSubscribe - I'm getting the same error on my site.
Comment #2
Dave ReidI have added some debugging code to 6.x-1.x-dev release that will help trace what function is responsible for calling this incorrectly. Please download the 6.x-1.x-dev release in about 12 hours to help me debug this further.
Comment #3
roball CreditAttribution: roball commentedThanks for adding the debug code. With 6.x-1.x-dev rolled out at 2011-Nov-03, 00:31 UTC the error message mentioned above changed to
Thus the error in my CCK nodes and views is caused by the Viewfield module 6.x-1.2, within the "theme/viewfield.theme.inc" file. Its problematic function currently is:
Can you please say how that function must be changed in order to be compatible with your significant change in Token 6.x-1.17?
Comment #4
Dave ReidTransferring to the Viewfield issue queue.
Comment #5
storytellerjeff CreditAttribution: storytellerjeff commented@Dave Reid - I'm not sure that this is specifically a Viewfield issue. Here's the error message I'm now getting:
The _custom_breadcrumbs_get_breadcrumb() function called token replacement with an array rather than a string for $text in /home/catdocto/public_html/sites/all/modules/token/token.module on line 263.
Any thoughts?
Comment #6
keithm CreditAttribution: keithm commentedIt looks like token_replace() stopped accepting an array for its first argument starting in token-6.x-1.15. Viewfield needs to be updated accordingly.
Comment #7
Dave ReidHrm, thanks for pointing that out. So yeah, the API did actually support an array as of 6.x-1.15 but we've slowly moved away from that. This is still a good change for module authors to make as it never should have been supported like that, but I'm probably going to file a new issue in token to now throw the notice when this happens now.
@storytellerjeff: Yes, multiple modules did this. See #1327960: Invalid use of token_replace API - causes preg_match_all errors in token module for the custom_breadcrumbs issue.
Comment #8
storytellerjeff CreditAttribution: storytellerjeff commented@Dave Reid - Thanks! I appreciate that you're on top of this so quickly.
Comment #9
roball CreditAttribution: roball commentedThanks for the patch at #6, keithm! Have applied it on Viewfield 6.x-1.2 and it solved the problem. No longer "The _viewfield_get_view_args() function called token replacement with an array rather than a string for $text in /etc/drupal6/all/modules/token/token.module on line 263." warnings by Token Module 6.x-1.18.
Comment #10
keithm CreditAttribution: keithm commented@roball: thanks for testing.
Committed http://drupalcode.org/project/viewfield.git/commit/ecfb898 on 6.x-1.x; http://drupalcode.org/project/viewfield.git/commit/a0d53ca on 6.x-2.x.
Comment #11
allnet000 CreditAttribution: allnet000 commentedI am not using the ViewField module, but still getting a similar error message. Is there a different patch I need to apply?
user notice: The custom_pagers_get_list_from_view() function called token replacement with an array rather than a string for $text in sites/all/modules/token/token.module on line 263.
Comment #12
roball CreditAttribution: roball commented@allnet000: as you can see in your error message, that's a problem of the custom_pagers module: #1327982: Invalid use of token_replace API - causes preg_match_all errors in token module.
Comment #13
allnet000 CreditAttribution: allnet000 commentedthank you.
Comment #14
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.
Comment #16
kayuna CreditAttribution: kayuna commentedUhm.. I'm very new to all this, do I paste that string into the existing php thing, or make a new?
Comment #17
keithm CreditAttribution: keithm commented@kayuna: This issue was fixed for viewfield, though there might be other modules that still have the problem. As Dave Reid says in #14, upgrading Token to the latest development version 6.x-1.x-dev will fix all warnings regardless. If you need other support, please open a new issue since this issue is currently closed.
Comment #18
yktdan CreditAttribution: yktdan commenteddev version works, 6.18 does not, still. If the proper fix is to install a new viewfield (and others without the api change), then viewfield needs a new release, not just yet another dev. Most of us like to run supported releases, not dev versions. So how about a token 6.19 that is fixed.
Comment #19
nicktr CreditAttribution: nicktr commentedDev version works for me too. Any news on a 6.19 release?
Comment #20
roball CreditAttribution: roball commentedThis issue is one of the Viewfield module and already closed.
nicktr, you are asking for a new release of the Token module. I have posted this request in their own issue queue here: #1772136: Release of Token 6.x-1.19.