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.
When updating the alias through pathauto_taxonomy_term_update_alias() it uses taxonomy_get_tree(), which will load the entire vocabulary. When dealing with vocabularies with many terms, this will add a very heavy load, both CPU, DB and memory, and may even cause memory limit breaks. Using taxonomy_get_children() fixes this.
Comment | File | Size | Author |
---|---|---|---|
#8 | interdiff.txt | 635 bytes | olli |
#8 | pathauto-2259527-using_taxonomy_get_children-8.patch | 618 bytes | olli |
#1 | pathauto-2259527-using_taxonomy_get_children-1.patch | 584 bytes | frakke |
Comments
Comment #1
frakke CreditAttribution: frakke commentedComment #2
frakke CreditAttribution: frakke commentedComment #4
jvandyk CreditAttribution: jvandyk commentedThis seems like a smart change for sites with many terms.
Comment #5
Dave ReidComment #6
joelpittetWould there be a regression if you have more than 2 levels as I think that only get's the direct children?
Comment #7
Dave ReidWhy aren't we using $term->vid as the second parameter here?
Comment #8
olli CreditAttribution: olli commentedRe #6: I think you're right. Current code sets 'alias children' to FALSE before recursive call because it already gets all levels from taxonomy_get_tree(). Here's a patch that doesn't set 'alias children'.
Re #7: I don't know but I guess we can add that since taxonomy_get_tree() also returned terms by
$term->vid
.Note that taxonomy_get_children() always loads entities while taxonomy_get_tree() didn't.
Comment #9
Dave ReidLet's merge this with #2114323: Field based aliases incorrectly generated for taxonomy term children when updating top level term which also adds tests for the taxonomy children aliasing functionality.