I've spent a lot of time the past few days trying to track down why Auto Node Title was not updating titles correctly when existing nodes were edited, and I stumbled across #674556: Outdated titles when token_replace called on old node information before ANT which pointed out that PathAuto was to blame. Sure enough, when I disabled PA, I found that ANT did indeed work correctly.

After reading through the code, playing with it a bit, and then reading through both #180440: If an alias is manually created, don't automatically replace it on edit and #369840: If a user changes the automatic path, try to remember that in the future, I discovered that the issue. As it turns out, PA actually taints the Token cache with stale node information as part of comparing the node path to the one that would be generated if the path is supposed to be automatically updated.

Now, you could argue that Token should include modification times or similar information as part of its caching scheme, or you could argue that ANT should flush the token cache before it queries for information. The fact is, the Token cache is only stale as a side effect of the rather hack-ish solution in pathauto_form_alter() for determining if PA should auto-regenerate node paths; were it not for that, Token's caching scheme would work as expected.

I understand all of the concerns that were raised in both #180440: If an alias is manually created, don't automatically replace it on edit and #369840: If a user changes the automatic path, try to remember that in the future about not having sufficient APIs for managing tables, and not wanting extra storage in the database (for performance concerns?), but I don't really see a good solution to that issue without resorting to storing the auto-update flag SOMEWHERE. As it stands, the current guess-and-compare behavior is a band aid that causes much more obscure and hard-to-address behavior in other modules other than PA, and is fragile if the path pattern depends on any values other than what's in the node. A database-based approach would not have the same drawbacks, and would be easier to maintain in the long-run.

Comments

dave reid’s picture

Status: Active » Closed (duplicate)

Please see #936222: Merge in pathauto_persist module functionality to prevent losing manual aliases with node_save() calls. Side note this is not going to be addressed or fixed in 6.x-1.x at all.

guypaddock’s picture

Status: Closed (duplicate) » Needs review
StatusFileSize
new958 bytes

Although I'm not happy band-aid-ing an already band-aid-ed solution, attached is a patch that can be applied temporarily so that the effects of the tainted token cache are reversed after pathauto_form_alter() has done the path comparison.

This isn't really a good long-term solution, especially for performance because we're essentially having Token construct an entire cache of values, only to have it throw it away and re-build it the next time any token value is requested.

greggles’s picture

Status: Needs review » Closed (won't fix)

Other modules should clear the cache for themselves.