I just upgraded Pathauto (and Drupal) from v5.16 to v6.11, and am getting some unexpected results with taxonomy terms. I searched and read through some long threads that seem similar but are not really, so please point to a duplicate if I missed something.

I am using Hierarchical Select (settings:single hierarchy, multiple-select, save term lineage) to handle a vocabulary that looks like this:

News (vocab)
-Tech (1)
-Science (2)
--Chemistry (2-1; a subcategory of Science)

My automated alias settings for node are: news/[yyyy]-[mm]-[dd]/[term-raw]/[title-raw] and for Taxonomy term are just [catpath-raw]. When I create a node and select Tech as a term, I get an automatic URL like: news/2009-04-15/tech/node-title. If I edit the node and re-assign the taxonomy terms to Science with a subcategory of Chemistry, I get a URL like news/2009-04-15/chemistry/node-title. If I re-edit the node once again, and re-assign it to the Tech category, I get the same URL as I did for chemistry: news/2009-04-15/chemistry/node-title. (However, the node's display itself shows the node is now classified under Tech).

Two questions:
1. Why is the URL not being rewritten? I flushed caches, checked and unchecked Automatic URL, manually deleted the chemistry URL alias... I am using Views frontpage to display the nodes.
2. With a setting for [term-raw] I was expecting Science in the URL not Chemistry since the Replacement patterns say that is for the "Unfiltered name of top taxonomy term."

Thanks, and please close the issue if some-one can point me to answer.

Comments

talatnat’s picture

Update:
#1. I tried a clean install of just Pathauto and Token and everthing works as expected. I will try and trace any other module clashes since it seems to work fine when I added Hierarchical Select, too.

#2. I still get Chemistry instead of Science for the "top taxonomy term" default behavior of [term-raw], and I beginning to suspect that this the desired behavior. If so, please close the issue.

However, since it is not the desired outcome for me, can someone explain how I can limit the URL alias to the top primary term and not the subcategory?

greggles’s picture

Do you use revisions?

Does the problem go away with 6.x-1.x-dev?

talatnat’s picture

Greg: Hi.

1. Yes, I use node Revisions, and it seems to be the problem.
I just checked on the clean install (6.11 + Pathauto + Token) by turning on Revisions before re-submitting the node with a new term, and it did have the same problem: The new URL was the same as the old one, but the node display showed the new taxonomy term. Not using Revisions cleared the problem, even on my development system, but see below.

2. The 6.x-1.x-dev did not help, unfortunately, in both the clean install and my development system.
---

Some observations: I needed to delete all the entries in Revisions queue before it worked. In the clean install, it was not easily apparent because I was cycling between 2-3 taxonomy terms. On the dev system, with a dozen terms, it seemed to work each time I chose a brand-new term. But when I reverted to a previously used term, it failed. So, the behavior seemed erratic -- the taxonomy term would take sometimes and not at other times. After I cleaned out all Revisions for that node {some 150 of them because of all this testing :(( }, everything fell into place :)
---

It is a major problem if we cannot use Revisions. Any suggestions? We didn't have this issue with Drupal 5, to my knowledge.

Finally, thanks for the timely reply (it really came at the right time); I was tearing my hair out weeding out "culprit" modules.

greggles’s picture

Well, #423132: Incorrect retrival of node's taxonomy terms with revisions seems like the exact problem you describe, but it is marked as fixed...perhaps it will help provide some clues on this?

talatnat’s picture

Greg: I will try this tomorrow (11:21 pm right now), and report back. Khap khun krap (thank you).

T'nat

talatnat’s picture

Update:
I applied the patches (I wrongly assumed that the 6.x.1.x-dev already had the patches), and things work well with Revisions turned on. The URL is news/2009-05-08/SUBcategory/node-title for [term-raw]: Is this the correct behavior for "top term"?

FYI, in case someone experiences this unexpected behavior:
On my dev system, the URL comes out as news/2009-05-08/category/node-title (and not subcategory) with a custom CCK content type. Oddly, this is 90% of the time, because I do get an occasional URL with subcategory listed, as in #1; this always happens to one particular term/subterm, and deleting and putting them back in vocabulary does not help. Also, in all cases, both category and subcategory are listed on node display, so the subcategory is going into the database.

But, if I move taxonomy AFTER all the CCK fields in the create-content form, then we revert to normal behavior of news/2009-05-08/SUBcategory/node-title... :)) Any ideas on why this is happening, and how to prevent it (I would prefer taxonomy at the top of the form")?

greggles’s picture

Specifically which patches did you apply?

talatnat’s picture

Greg: Hi. Sorry for the confusion: I applied Nonsie's patches manually. But, here's what happened:

1. When I first checked with 6.x-1.x-dev, it worked on the clean install but not on my dev system (because of the CCK-content problem, which I had not yet resolved). So, I did a diff on pathauto using Nongsie's suggestions, and figured the patch had not been applied (somehow overlooking your better solution because it was just one character different!).

2. So, now I had your's and Nongsie's patches on the same file :) when I checked again, and it worked, again partially, because of CCK.

3. I took out Nongsie's patches and checked again, duh: everything was OK, again except for the CCK problem. If this is a CCK problem let me know.

4. If a CCK problem, we can close this issue, except for my original support question: Is [term-raw] the "top" or highest primary term or the "deepest" secondary/tertiary one. And if it is the deepest, how can I limit the URL alias to the primary category? (I have tried "Primary Term" module, but it does not work with H-Select and other modules.) If I cannot somehow specify the primary category in the URL, I think that would be a good feature for URL alias, and hope that we could turn this support issue to a feature request.

Thanks again.

talatnat’s picture

Greg: On further testing on a clean install of Pathauto, Token and Hierarchical Select (with lineage):

1. It appears one should start without a list of old revisions with buggy url's in the hopper. Revisions that have incorrect terms sometimes seem to cause a new term revision to not "take" -- thus reverting to the old term. For example, a node that had a wrong url alias of just science, rather than science/chemistry, on being revised correctly to an alias of business/markets, and then being revised again to science/chemistry would still have the alias of just science. Only if that "science" revision is deleted would the correct url of science/chemistry "take".
2. For my use case of terms/subterms, adding both your modifications AND Nonsie's suggestions (my misapplication!) seems to work better than using the modifications in the dev versions alone. (With the dev patches, I could not change the wrong url of the "science" node to business/markets; the double patches could change it to business/markets, but fail to just science when one tried to revert to science/chemistry.)

I don't understand the code behind your and Nonsie's suggestions, and I don't know if anything else is at play here, so this is just an empirical note on some testing...

greggles’s picture

If the problem only shows up during a "revert" of the node perhaps we just need to test that and figure out what's going on there.

lonerzzz’s picture

For those needing to work around the problem, here is what I do:

1) use phpmyadmin to go into the drupal database on your system
2) Browse the contents of the url_alias table
3) You should see one row with the old url alias and another row with the new alias
4) Delete the new row after copying your alias path
5) Update the old url row and paste your saved alias path over the existing path

After that, you can use the database approach to make the changes on the desired row directly until such time as someone who understands the code fixes the bug

Jason

aschiwi’s picture

I am having this problem as well. The aliases are created, they are in the alias list. But they are not the current alias of the node. I also have revisions enabled.

dave reid’s picture