Hi, I'm a beginner. I've just installed Drupal 7 with XAMPP on Windows XP. I've created a vocabulary (myvocabulary) with many nested terms. With Pathauto I would like to create urls such as www.example.com/parent_term/child_term.
In "Configuration » Search and metadata » URL aliases" I've set "Pattern for all myvocabulary paths" to [term:parent]/[term:name].
I've enabled also "Bulk generate aliases for terms that are not aliased".
Here is what happen when I hit the button "Save configuration":
1. All existing terms which do not already have aliases get a new correct url www.example.com/parent_term/child_term
2. When I create a new child term in the vocabulary, it get the wrong url www.example.com/child_term (In other words Drupal can't fetch the parent term for new child terms)
Is it a bug?
Note: sometimes when I apply a new URL Pattern in "Configuration » Search and metadata » URL aliases" with the option "Bulk generate aliases for terms that are not aliased" active, I get the following message:
The configuration options have been saved.
Bulk generation of terms completed, 23 aliases generated
Notice: Trying to get property of non-object in taxonomy_tokens() (line 141 of C:\xampp\htdocs\example\modules\taxonomy\taxonomy.tokens.inc).
(This last error message is repeated many times)
Comment | File | Size | Author |
---|---|---|---|
#4 | 844410-taxonomy-hook-token-D7.patch | 5.06 KB | Dave Reid |
#2 | 844410-taxonomy-hook-token-D7.patch | 5.52 KB | Dave Reid |
Comments
Comment #1
Dave ReidThis is a pretty major core bug. Posting a patch shortly.
Comment #2
Dave ReidSo several issues here:
1. Term parents are not saved prior to the hook_taxonomy_term_insert/update being executed. This was exposed in pathauto which tries to get the parent term's tokens and there is no hierarchy there. These kinds of hooks should always be post all insert or update operations.
2. When using [term:parent:*] tokens with a term that does not have any parents, this causes a PHP notice because taxonomy_get_parents() returns an empty array. This was also exposed in pathauto and the tests have been added to fix this bug.
Comment #4
Dave ReidRe-rolled to not use $term->is_new which affects processing if the value stays in the term object.
Comment #5
moshe weitzman CreditAttribution: moshe weitzman commentedCode looks proper and bot is happy. More test coverage as well.
Comment #6
marcingy CreditAttribution: marcingy commentedChanging to major as per tag.
Comment #7
MustangGB CreditAttribution: MustangGB commentedTag update
Comment #8
Dave ReidAdding the token tag since this affects token functionality when using [term:parent] tokens.
Comment #9
Dries CreditAttribution: Dries commentedLooks good. Committed to CVS HEAD.
Comment #10
Dave ReidHaven't actually seen this committed on http://drupal.org/project/cvs/3060 yet? :/
Comment #11
Dries CreditAttribution: Dries commentedFor real now. Committed to CVS HEAD.
Comment #12
Dave ReidExcellent! Thank you Dries, that fixes two hacks in Pathauto for D7.