I had a bug when trying to generate aliases with category_pathauto. Basically instead of generating aliases like ParentCategory/ChildCategory, it'd generate only ChildCategory.

I was able to trace the bug to a weird behavior: when calling _category_pathauto_get_path(ParentCategory), then _category_pathauto_get_path(ChildCategory) would change. ie:

_category_pathauto_get_path(ChildCategory) returns {Parent,Child}
_category_pathauto_get_path(ParentCategory) returns Parent
_category_pathauto_get_path(ChildCategory) returns Child !!!???

It then traced this issue to the simple cache mechanism implemented in category_get_category() in category.inc

Indeed defaulting to TRUE to reset the cache all the time fixes the issue.

Comments

jun’s picture

Well it almost fixes the issue, I also had to modify category_pathauto_get_placeholders()
by adding

$nodid = $node->nid

at the beginning, and replacing :

path = _category_pathauto_get_path($node);

by

path = _category_pathauto_get_path(node_load(array('nid' => $nodid)));

I guess it's something of pass by reference problem somewhere but I'm too lazy figuring out where exactly it is.

I hope this quick fix will help more than it'll hurt.

JirkaRybka’s picture

Status: Active » Closed (fixed)

Closing after 3 years. It was 4.7.x issue.