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.
For the Year Only fields I get the following warnings:
$info['tokens']['node-field_my_node_field_type1_year']['value']
$info['tokens']['node-field_my_node_field_type2_year']['value']
$info['tokens']['node-field_my_node_field_type3_year']['value']
$info['tokens']['node-field_my_node_field_type4_year']['value']
$info['tokens']['paragraph-field_my_node_field_type1_year']['value']
$info['tokens']['paragraph-field_my_node_field_type2_year']['value']
$info['tokens']['paragraph-field_my_node_field_type3_year']['value']
$info['tokens']['paragraph-field_my_node_field_type4_year']['value']
Comment | File | Size | Author |
---|---|---|---|
#7 | token_missing-2951179-7.patch | 1.69 KB | jungle |
Comments
Comment #2
steveoriolYou can add (patch) in "yearonly.module" with the next code, but it's not dynamic :-(
Comment #3
waverate CreditAttribution: waverate commentedIt looks like the Heading Field module figured out how to do this dynamically within the module.
See how they did it in patch #10 at #2934662: TOKENS OR TOKEN TYPES MISSING NAME PROPERTY after update.
Comment #4
waverate CreditAttribution: waverate commentedShamelessly taken from Heading Field module at #3.
Patch attached.
Comment #5
GaëlGIt may be shameless, but it works! :)
Comment #6
jungleThe root cause is that the filed type definition is incomplete
Comment #7
jungleRun `drush updb` to get it updated
Comment #8
jungleComment #9
aperedos CreditAttribution: aperedos commentedThe patch https://www.drupal.org/files/issues/2019-08-01/token_missing-2951179-7.p... doesn´t work for 1.3.0, the warning still apearing on the status report page after apply the patch and run updb.
Thanks,
Comment #10
ronaldmulero CreditAttribution: ronaldmulero at U.Group commentedThanks waverate. #4 works.
Drupal 8.8.5
yearonly 8.x-1.3
Comment #11
robcarrPatch #4 works on Drupal 8.9
Comment #12
superlolo95 CreditAttribution: superlolo95 commented#4 works for nodes but not for paragraphs.
Comment #13
skumararatne CreditAttribution: skumararatne commentedI used patch #4 but slightly modified it to work with my custom content entities that were throwing the missing name property warning. This should work with paragraph entities as well though i haven't tested that.
Comment #14
PCate CreditAttribution: PCate as a volunteer commented#4 patch did not apply for me with latest 8.x release, but #7 did and fixed the issue once I ran updb.
Comment #15
noah CreditAttribution: noah as a volunteer commentedIt looks like the patch excludes every entity type except nodes—is that necessary for this solution? I've seen this warning for fields in taxonomy terms and paragraphs, would a more generic solution like that proposed by @skumararatne work, or are there potential unintended consequences?
Comment #16
ronaldmulero CreditAttribution: ronaldmulero at U.Group commented#7 fixes
$info['tokens']['term-field_year']['value']
warning that #4 did not.Thanks jungle!
Drupal 8.9.13
yearonly 9.0.0
Comment #17
AlvaroDeMendoza CreditAttribution: AlvaroDeMendoza commentedUpdated patch with code from #13
Drupal 9.3.9
yearonly 9.0.0
Comment #18
superlolo95 CreditAttribution: superlolo95 commented+1 for #17
Comment #19
adrianodias CreditAttribution: adrianodias commented+1 for #17
Drupal 9.4.1
yearonly 9.0.0
Comment #20
joseph-dickson+1 for #17
Drupal 9.4.2
yearonly 9.0.0
I've applied #17 using the 'cweagans/composer-patches' composer.json patching method.
gist available at https://gist.github.com/josephdickson/5178979b3b67c3cc14c84f3ff33746de
Comment #21
joseph-dicksonComment #22
joaomfantunes CreditAttribution: joaomfantunes commented+1 for #17
Comment #23
justcaldwellNew co-maintainer here 👋. Moving to the 9.x branch, as all new development/fixes will occur there. Thanks!
Comment #24
jungle#11 RTBC'ed #4 but I don't think #4 should be RTBC'ed. And #17 does resolve the issue, but I do not think it's the right way.
I still think #7 is the right fix with the confirmation from #14 and #16, thanks!
Comment #25
jungleImplement foo_token_info_alter() to alter the tokens provided by module foo itself, which is weird and does not make sense at all.
Comment #26
jungleComment #27
justcaldwellHi @jungle. Yeah, I was just looking at this, and I tend to agree that your solution (#7) is likely the way to go. I'm going to do a bit more testing. Thanks for the additional feedback!
Comment #29
justcaldwellI committed #7 to the 9.x-dev branch because:
Please test with the dev branch if you are able. Be sure to run updates (
drush updb
)! 😀Comment #30
justcaldwellComment #31
justcaldwellUpdating credit. Thanks to everyone for pushing this forward.
Comment #32
jungleThanks @justcaldwell for reviewing and committing!
Comment #33
justcaldwellIncluded in 9.1.0 release.