First, let me say thanks for a very cool and much needed module. :)

I'm not sure if this is a bug with pathfilter or just the way things work in drupal. The following is what I experience on my site, using drupal 4.7.2 and the latest CVS version of pathfilter:

1) node/10 is aliased as my/alias

2) node/20 has an internal link, "internal:node/10", which shows the correct alias in the content: my/alias

3) in admin/path, I change the alias my/alias to my/new/alias

4) node/20 still shows the internal link "internal:node/10" as my/alias in the content, instead of as my/new/alias

5) editing the content of node/20 in any way, say adding some space, and then saving it will then cause its internal link "internal:node/10" to show the correct alias my/new/alias in the content.

It would be great if any change to an alias would be automatically reflected in any "internal:" type links on the site, but again, I'm not sure if this is a limitation in the way that drupal works.

CommentFileSizeAuthor
#7 doc_patch.txt1.37 KBRayZ
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RobRoy’s picture

This has to do with the fact that page content is cached and saving updates the cache. I'll try and brainstorm a good solution as clearing the entire cache on each alias change would be overkill probably.

jsa’s picture

This has to do with the fact that page content is cached and saving updates the cache.

Ah! Thanks for clearing that up for me. :)

So, if one wanted to manually clear the cache after running a bulk update of aliases with the pathauto module, one could possibly use this SQL Snippet?

DELETE FROM cache;
RobRoy’s picture

Yes, but it would be better to install the devel.module which has a clear cache link, then you don't have to get into the DB at all.

jsa’s picture

The devel.module looks like a much better method for clearing the cache than the SQL snippet, and comes with other additional features.

Thanks :)

RayZ’s picture

Category: bug » support
Status: Active » Closed (fixed)

I'm not sure if this is a bug with pathfilter or just the way things work in drupal.

Since it's the latter, I am changing this to a support request and closing it. I suppose it could be argued that it's a bug in "the way things work in drupal", but that should be opened as a separate bug report in the drupal issue queue.

RobRoy’s picture

Status: Closed (fixed) » Active

In a perfect world, we would store a records of the aliases that PathFilter uses to nodes, and when one of these nodes/aliases is modified we would clear the cache for the specified node(s). Although, I'd hate to bring a db schema into this. This is something to think about since this is PathFilter's main job, we should eventually think of a solution to avoid broken links. A really clunky solution would just be to invalidate all node cache upon adding/removing/modfiying an alias, but that would be a big performance hit.

So the key is to somehow keep record of any nodes that use "internal:" and invalidate the cache when an alias changes, right? I wonder how it works right now with input formats using print l('node/9', 'Link'); .

RayZ’s picture

Status: Active » Needs review
FileSize
1.37 KB

I did a quick test and found that using l('Link', 'node/9') with a "PHP code" input filter does not require clearing the cache. The page reflects the updated alias automatically. I assume these pages are not cached.

Upon further thought, I suppose this really is a Path Filter issue after all. However, is it something that happens often enough that manually clearing the cache is an unacceptable workaround? A mention of this, of course, does need to be included in the documentation (see attached patch).

It seems to me that this is only an issue if you use Path Filter to reference specific node ids, and then update the corresponding aliases frequently. I can't think of why one might want to do that. I tend to reference the alias directly in my links. I might change the node that the alias points to, but I rarely change the alias. I'd be interested in hearing a use case where this is a serious problem.

marc.zonzon’s picture

I have a slightly different problem, my site can be accessed on the lan as http://www.localaddr.com/drupal and thru a reverse proxy from the wan as
http://www.example.com, if I use internal:node/242 it gives the right link for the lan (http://www.localaddr.com/drupal/node/242) when saved from the lan, and the right link for the wan (http://www.example.com/node/242) when saved from the wan.
But the link is erroneous when viewed the other way, i;e. if saved from the lan I get the lan link even when viewing from the wan.
Of course php code like <?php print l('link to node/242', 'node/242'); ?> always give the good link whatever the place I save and read my page.
In this case I would like to avoid completely the cache, is there a way to do so?

RobRoy’s picture

Status: Needs review » Fixed

Committed some docs, thanks Ray.

@marc.zonzon You can change the link type from absolute to relative which will print out links like "/drupal/some-link-here" instead of "http://www.example.com/drupal/some-link-here". This setting can be found in administer » input formats » configure » configure tab (for any input format that has pathfilter enabled). This is probably your best bet. It's not very easy to find, I admit, but this is a Drupal usability issue that should probably be addresses elsewhere.

In thinking this over, maybe we should move the pathfilter filtering to go on top of any existing caching? Since part of this module's purpose is to have a surefire way of creating a permanent link to a page who's alias may change in development, or a way to create an absolute URL link to a page when it's server may change or be constantly changing. Thoughts? We can set 'no cache' $op TRUE in hook_filter but this disables caching for that input format completely.

marc.zonzon’s picture

Using relative links is of no help when sites have different prefixes "/drupal/some-link-here" will do for my lan where the prefix is /drupal, not for the wan site which is directly under the root.
Of course, I actually use the same prefix by writing simply "/drupal/node/242", and to cope with the absence of prefix on one site I have a rewrite rule such that apache rewrite "/drupal/node/242" to "/node/242" when the request come from the reverse proxy. But this situation is not good because all my nodes can be accessed along two paths with and without "/drupal" on the wan (proxied site). It is just to improve this situation that I have tried Path Filter.
Moreover it does not solve the problem that page saved within the lan will get "/drupal/node/242" and page saved within the wan will get "/node/242".

All these problem were in the past resolved by href to a different base_url, but It had also it's drawbacks and has been removed since 4.7.

I know very few about drupal caching, but "All or nothing" is not usefull when your site can have some dynamic aspect, It seems that path filter may come after caching, paths are not indexed so it does not harm the search facility, We would like path filter to offer at least the same ease than this <?php print l('link to node/242', 'node/242'); ?> without obliging to have the full page with a php filter. It seems that the MVC concepts are not present in drupal, which ignore the need to mix dynamic content and a static model.

RobRoy’s picture

This can be done. Feel free to submit a patch as well. If we refactor pathfilter to come on top of page caching it would dynamically generate the link on each page view. I'll have to think about this some more to think if this should be an option or the way we always do it.

Anonymous’s picture

Status: Fixed » Closed (fixed)
gpk’s picture

#132003: caching was marked a duplicate (about 3 years ago)...

Note that the fix (#9) was to put a warning in README.txt: http://drupalcode.org/viewvc/drupal/contributions/modules/pathfilter/REA... so from what I can make out the original problem is still present.