I would like a way to resolve conflicts. If I have path aliases foo and foo/bar, I would like to have a blacklist for subpathauto so that I can tell it not to resolve foo/bar. Alternatively, if I only want to use the module for user/name/contact, I would like to be able to do that.

For now, I have to put up with user/2/contact because I have a page (path alias) foo and another one (created by Views, but maybe that does not matter) foo/bar.

Update: Yes, it does matter that the alias is created by Views. If foo and foo/bar are aliases for node/1 and node/2, then there is no problem, but if foo/bar is a path set in Views, then the View is lost.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

BenK’s picture

Subscribing

Taxoman’s picture

Title: Add whitelist or blacklist. » Add whitelist or blacklist to Sub-pathauto
Version: 7.x-1.1 » 7.x-1.x-dev
smoothify’s picture

Here is an implementation for blacklisting and whitelisting.

It allows you to specify a blacklist and a whitelist separately for inbound and outbound. The outbound I would expect to be most commonly used, the inbound is good to save a bit of performance on a large site but using it can create 404s on your site if you are overzealous with blacklisting.

The blacklist takes precedence over the whitelist, which means that a path that is listed in the blacklist will never be converted, whereas one in the whitelist will only be converted IF it doesn't appear in the blacklist.

So the order of precedence when at least one path is in the whitelist:
Blacklist - any paths matching here WILL NOT be converted.
Whitelist - any paths matching here but not in the blacklist WILL be converted
All other paths WILL NOT be converted.

If the whitelist is empty (default) the order of precedence becomes:
Blacklist - any paths matching here WILL NOT be converted.
Admin Paths - if ignore admin paths is checked, and the path is an admin path then it WILL NOT be converted.
All other paths WILL be converted.

xaqrox’s picture

Status: Active » Needs review

Patch in #3 seems to work but I didn't test it very thoroughly, just enough to get my work done. Probably needs more eyes.

orakili’s picture

Status: Needs review » Reviewed & tested by the community

Tested the patch in #3 on a large site, it worked fine.

It would be nice to have it included into the module.

Setting as RTBC.

jordanmagnuson’s picture

Thanks for the great patch, smoothify! Definitely adds a lot to the module!

Have tested it pretty thoroughly using both inbound and outbound filters, and it seems to be working, so plus one for getting it committed (though I have not done any performance benchmarks).

Can anyone tell me what the best way to benchmark performance gains from this patch would be?

chili.hh’s picture

Patch from #3 works as desired, but causes an infinite recursion on drush cc all on my system in conjunction with xmlsitemap.

Snippet from the backtrace:

menu_link_save() /www/myentdecker/htdocs/includes/menu.inc:2841
drupal_alter() /www/myentdecker/htdocs/includes/menu.inc:3052
xmlsitemap_menu_menu_link_alter() /www/myentdecker/htdocs/includes/module.inc:1022
xmlsitemap_menu_xmlsitemap_process_menu_links() /www/myentdecker/htdocs/sites/all/modules/contrib/xmlsitemap/xmlsitemap_menu/xmlsitemap_menu.module:211
xmlsitemap_link_save() /www/myentdecker/htdocs/sites/all/modules/contrib/xmlsitemap/xmlsitemap_menu/xmlsitemap_menu.module:96
drupal_alter() /www/myentdecker/htdocs/sites/all/modules/contrib/xmlsitemap/xmlsitemap.module:580
xmlsitemap_xmlsitemap_link_alter() /www/myentdecker/htdocs/includes/module.inc:1022
drupal_get_normal_path() /www/myentdecker/htdocs/sites/all/modules/contrib/xmlsitemap/xmlsitemap.xmlsitemap.inc:250
subpathauto_url_inbound_alter() /www/myentdecker/htdocs/includes/path.inc:272
menu_get_item() /www/myentdecker/htdocs/sites/all/modules/contrib/subpathauto/subpathauto.module:25
menu_rebuild() /www/myentdecker/htdocs/includes/menu.inc:458
_menu_navigation_links_rebuild() /www/myentdecker/htdocs/includes/menu.inc:2702

Addition:
Before updating subpathauto from v7.x-1.1 to v7.x-1.3 and applying the patch there was no occurence of an infinite recursion. The only changes since happened to subpathauto.

chili.hh’s picture

Just noticed that the bug from #7 is already known, see https://drupal.org/node/1844150. So please just ignore my nonsense above for this issue :)

dshields’s picture

Patch in #3 is awesome!

i'm blacklisting:
*/edit
*/moderation
*/translate

which brings back standard urls for those operations while allowing me to set up something like node/%node/foo/bar to provide an alternative display for node/%node

Let's get this patch committed!

dshields’s picture

Issue summary: View changes

update after further experimentaiton

func0der’s picture

Issue summary: View changes
StatusFileSize
new1.61 KB

A pretty simple whitelist solution would be also the one attached.

I know blacklisting is missing, but it works pretty fine.

bdanin’s picture

The patch in #10 is working great for me, just what I needed!
subpathauto was interfering with all my node-edit links

I am whitelisting quiz/* for my quiz/take sub-paths. This patch fixed the problem, thank you!

EDIT: actually path-auto + quiz (when clicking on a link) reverts the URL in to use the node/ID/take instead of the subpath; probably a conflict in the quiz-5.x module though

heddn’s picture

+1 on RTBC

stefan.r’s picture

Re-roll of #3 (which was RTBC) attached

heddn’s picture

To clarify, I was RTBCing #3.

azinck’s picture

#13 is RTBC for me.

jordanmagnuson’s picture

It looks like this patch was never applied to the module. Anyone know if the 7.x version of this module still being maintained?

c.e.a’s picture

Such a great and useful module...
But what about the Drupal 8 version of this module ??

I would like to ENABLE this module only for /user/... and /node/... pages, is that possible ??

Thank you,

volkswagenchick’s picture

Status: Reviewed & tested by the community » Needs work
Related issues: +#2993575: [meta] Remove usage of "blacklist", "whitelist", use better terms instead

This issue doesn't seem to have moved forward... but, there is an effort in the Drupal community to move away from using white/black list in favor of more inclusive language. Please see this core issue: https://www.drupal.org/project/drupal/issues/2993575

Thanks, moving this to needs work.

banoodle made their first commit to this issue’s fork.