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.
You create an array for the token_replace_multiple() function that includes the $node parameter that you just loaded. The problem is that you always add the node even if it doesn't exist.
I get errors in the token, pathauto and other modules because of this small mistake.
What I suggest is that you add the $node parameter to the array only if the node was loaded. (see patch)
I specifically see the problem on a page created from a view, i.e. not a node and not a page that was added to a menu either.
Thank you.
Alexis Wilke
Comment | File | Size | Author |
---|---|---|---|
google_analytics-3.x-tokens_without_node-6.x.patch | 927 bytes | AlexisWilke | |
Comments
Comment #1
hass CreditAttribution: hass commentedDave have reviewed this code... What token version are you using and how can I repro this? I have never seen any warnings myself... What abou D7?
Comment #2
AlexisWilke CreditAttribution: AlexisWilke commentedI don't use D7. 8-}
This only happens on pages that are not nodes (i.e. a view).
I have E_ALL turned ON as well to see all E_NOTICE errors, but the problem is that the hook_token_values() using the type 'node' can be overwritten by many and all expect a valid $node... Some other processes also generate an error (i.e. pathauto.)
If you want to get the error every time, use NULL instead of $node, then in token you get an error here:
By changing your code with my patch, I avoid the problem by not putting the $node in the array when it does not represent a valid node (i.e. on a view.)
Thank you.
Alexis
Comment #3
hass CreditAttribution: hass commentedYeah, but D7 comes very first... Than a backport...
Comment #4
AlexisWilke CreditAttribution: AlexisWilke commentedThat's up to you... You already got the fix for D6 though.
Oh and 114k users for D6 versus 6k for D7. But I guess that doesn't count since that's 114k happy customers. 8-)
Comment #5
hass CreditAttribution: hass commentedI guess you are familiar with the process to prevent regressions... :-)
Comment #6
hass CreditAttribution: hass commentedCommitted to D6 and changed version committed to D7.