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.
In `field_token_info_alter` it's checked whether there is a token type specified. If this is the case the fields are loaded and looped through. The first check in the loop is to see if there is any info set for the token type. If this is not the case then the field is skipped and the loop continues to the next field. Between one field and the next there's no way for the condition's result to change. It makes more sense to check this before loading any fields at all and just skip the entire loop.
Comment | File | Size | Author |
---|---|---|---|
#7 | interdiff.txt | 590 bytes | Kingdutch |
#7 | 2886498-7-dont-load-fields-if-token_type-does-not-exist.patch | 926 bytes | Kingdutch |
|
Comments
Comment #2
KingdutchPatch attached
Comment #4
KingdutchI don't quite see how that test is related to the changes in the patch unless it relied on side effects of loading the fieldDefinitions.
Comment #5
BerdirNope, it wasn't, fixed the test fails in #2891981: Update tests for Drupal 8.4.x.
Comment #6
BerdirMakes sense, directly about we have an empty($token_type) check, what about combining both cases into a single if (this || that)? We have tons of continues and conditions in those loops and this helps to simplify that a bit I think.
Comment #7
KingdutchGood observation!
Attached is the patch that includes this change. If you've already applied that patch you can use the interdiff.
Comment #8
BerdirThanks, committed.