It would be nice to have a place to add specific paths that should be ignored by subpathauto. There are some times you want to ignore what subpathauto does. Just had a problem with taxonomy pages where my views were not working properly. Attached an initial patch to just ignore things for paths added through admin interface.

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

lemuelsantos created an issue. See original summary.

lemuelsantos’s picture

StatusFileSize
new71.82 KB
lemuelsantos’s picture

Title: Ignore specific paths (blacklist) » Ignore specific paths (blacklist) for D8
lemuelsantos’s picture

StatusFileSize
new1.71 KB
nkoporec’s picture

Status: Active » Needs work

\Drupal::config('subpathauto.settings')->get('blacklist');
\Drupal::service('path.matcher')->matchPath($path, $pattern)

Please inject services using dependency injection.Otherwise, the patch applies cleanly.

hlopes’s picture

StatusFileSize
new2.41 KB
new766 bytes

The patch only works for inbound links.

hlopes’s picture

StatusFileSize
new2.98 KB
new1.92 KB

Changed the line where isValidPath verification is made

And tweaked the pathmatcher, it expects a string, no need for a foreach.

lobsterr’s picture

Status: Needs work » Needs review
StatusFileSize
new16.02 KB

1) I have rerolled the path
2) I also noticed that patch handles only only inbound processing, but not outbound. I added this case also
3) I updated all the tests for inbound and outbound cases to check blacklists.
4) Another small fix here is local task, which is not displayed, because we are missing route, I change it to 'entity.path_alias.collection'. I believe it is the most suitable place for it.

nickdickinsonwilde’s picture

Title: Ignore specific paths (blacklist) for D8 » Ignore specific paths
Status: Needs review » Needs work
Issue tags: -subpathauto, -blacklist, -ignore paths

I very much am in favour of the least configurable settings possible to meet the majority use case. This setting is clear and harmless in it's default empty state and provides a potentially very useful option so I'm in favour of the feature.

That said, this is a new feature so have a strong feeling that we shouldn't be using 'blacklist' - see also #2993575: [meta] Remove usage of "blacklist", "whitelist", use better terms instead in core with regards to existing features where it is way more complicated and compatibility issues etc. I think ignorelist would be clearest - and then can use nice verb tenses like ignored etc.

Additionally, does need a re-roll due to other changes committed in the last couple weeks.

lobsterr’s picture

Status: Needs work » Needs review
StatusFileSize
new19.86 KB

1) Rerolled the patch
2) Replace blacklist with denylist
3) We still call "path_alias.whitelist", but it comes from path_alias module

nickdickinsonwilde’s picture

Version: 8.x-1.0-alpha1 » 8.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

Thanks! I like it. Going to leave open for a few days and if no one else has opinions I'll probably commit it early next week.

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

urvashi_vora’s picture

Hi @LOBsTerr,

Tested the patch, it applied cleanly.

urvasi@urvasi-Inspiron-15-3552:/var/www/html/contribution/drupal/web/modules/contrib/subpathauto-2964786$ git apply -v 2964786-11.patch
Checking patch config/schema/subpathauto.schema.yml...
Checking patch src/Form/SettingsForm.php...
Checking patch src/PathProcessor.php...
Checking patch subpathauto.links.menu.yml...
Checking patch subpathauto.services.yml...
Checking patch tests/src/Functional/SubPathautoFunctionalTest.php...
Checking patch tests/src/Kernel/SubPathautoKernelTest.php...
Checking patch tests/src/Unit/SubPathautoTest.php...
Applied patch config/schema/subpathauto.schema.yml cleanly.
Applied patch src/Form/SettingsForm.php cleanly.
Applied patch src/PathProcessor.php cleanly.
Applied patch subpathauto.links.menu.yml cleanly.
Applied patch subpathauto.services.yml cleanly.
Applied patch tests/src/Functional/SubPathautoFunctionalTest.php cleanly.
Applied patch tests/src/Kernel/SubPathautoKernelTest.php cleanly.
Applied patch tests/src/Unit/SubPathautoTest.php cleanly.

@NickDickinsonWilde, committing the changes to save your time and efforts.

Thanks

lobsterr’s picture

@NickDickinsonWilde Can we already merge it ?
It also would be nice to have a new release tagged.
Thanks

mistergroove’s picture

Hey. Great work on this guys. Have been using the solution in https://www.drupal.org/project/subpathauto/issues/2964786 till now but don't think I can use it on the 10 compatible version.

Did this make it into the official release yet?

loon’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new19.75 KB

It is not possible to exclude 'node/*/edit' pages
Updated patch #11

batigolix’s picture

Thanks for this great feature.

I had some trouble understanding how it worked, so I think this needs a bit of documentation and some clearer UI texts.

I would change the label to:

"Ignore the following paths"

And I would change the description to:

"These paths will be ignored by subpathauto. Use for example '/node/*/edit' to ensure that subpathauto ignores the node edit path. You can use wilcards(*). Start each path with a forward slash '/'. Enter one path per line."

I've read you discussed how to name the list and you settled for Denylist. Would "Ignore list" not be a better name for this?

batigolix’s picture

Status: Needs review » Needs work
kevin w’s picture

The patch is very helpful! For a URL like /part1/part2, if /part1 is redirected to /new-part1, I can't stop the redirection from /part1/part2 to /new-part1/part2. Adding some lines in processInbound() to skip /part1/part2 works.

kevin w’s picture

StatusFileSize
new19.92 KB

Added the check for denyList at the start of processInbound(). This helps address the issue when /part1 and /part1/* should be redirected except a unique path like /part1/special_path_here.

mistergroove’s picture

Great patch @kevin-w. Did anyone re-roll this patch for 1.4 by any chance?

I need a way to keep /node/*/edit paths excluded. It would be great if this could be part of the module.

lobsterr’s picture

Assigned: Unassigned » lobsterr

Guys, please provide an interdiff every time you change something, it is impossible to follow your changes. I will reroll it, but since this moment we will switch to MR

lobsterr’s picture

Assigned: lobsterr » Unassigned
Status: Needs work » Needs review

So, I have rerolled the latest patch and also renamed denylist to ignore. As it was suggested in here

Please use PR from this point

batigolix’s picture

I reviewed this and it works good.

The UI is also much clearer now.

There was a small code mistake though that I fixed. See my last commit in the PR.

batigolix’s picture

Issue tags: +finalist-sprint
lazzyvn’s picture

StatusFileSize
new34.77 KB

newest patch for dev branch

batigolix’s picture

Status: Needs review » Reviewed & tested by the community

@lazzyvn please see the merge request for any changes.

Personally, I think the generic solution provided in this issue is better than the specific solution proposed in #2830425: Add option to ignore admin paths

I tested the MR and it works well.

alorenc’s picture

Works fine to me. Can this be released?

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Needs review

Left an improvement remark in the MR to be reviewed.

claudiu.cristea’s picture

I still have a remark. If fixed I think this is RTBC

batigolix’s picture

I made the change.

The pipeline fails on phpunit, but the errors seems unrelated to the changes in this MR.

Issue for the phpunit pipeline error is #3606780: testProcessOutbound fails on Drupal 11.1+

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Thank you.

batigolix’s picture