When creating a redirect, a suggestion will be made if the source is an existing route:

"The source path node/[nid] is likely a valid path. It is preferred to create URL aliases for existing paths rather than redirects."

The text create URL aliases is a URL to route path.admin_add. If the user does not have the administer url aliasespermission this will result in a 404.

The text create URL aliases should only be a link if the user has this permission.

Issue fork redirect-3064713

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

Feng-Shui created an issue. See original summary.

feng-shui’s picture

Status: Active » Needs review
StatusFileSize
new2.08 KB

Attached patch does a permission check before the text us printed as a URL.

berdir’s picture

Status: Needs review » Needs work

Thanks, there seems to be a syntax error, this also reverts short array syntax.

I'd prefer making two separate complete strings, one a s a link and one not, because properly translating them is hard otherwise.

feng-shui’s picture

StatusFileSize
new2.04 KB

Apologies, something went very wrong when copying/pasting re syntax and formatting.

Updated patch attached that has complete strings as requested.

feng-shui’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: create-url-alias-permission-404-3064713-4.patch, failed testing. View results

feng-shui’s picture

Ok, so that patch has extra white space in it.... what the hell is going on with my IDE...

feng-shui’s picture

StatusFileSize
new1.96 KB

Ok, let's try without that whitespace for starters.

feng-shui’s picture

Status: Needs work » Needs review
quicksketch’s picture

StatusFileSize
new1.65 KB

Thanks Feng-Shui for opening this issue. I just ran into this as well.

I'd prefer making two separate complete strings, one as a link and one not, because properly translating them is hard otherwise.

This patch reworks the messages to be complete sentences, so they can be translated with more context of the words around them. I also don't think we should be even mentioning path aliases if the user does not have access to manage them, so this replaces the string

'It is preferred to create URL aliases for existing paths rather than redirects.'

with

'Creating this redirect may make the path inaccessible.'

berdir’s picture

Having that one sentence separated is still a bit of an issue for RTL languages because the second sentence would then be "first" I thnk?

The alternative text looks good, makes sense to not mention aliases then at all.

feng-shui’s picture

StatusFileSize
new1.66 KB

Re-roll of #10 against 1.6.

@Berdir what would you like to see here re the RTL issue?

iancawthorne’s picture

Just stumbled on this issue on one of our Drupal sites and wondering if this can be progressed and committed?

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

dpi’s picture

The whole message

The source path %path is likely a valid path. It is preferred to create URL aliases for existing paths rather than redirects.

May not even be correct as it is not programmatically determine if its a "valid path", using language like "likely".

I'd rather not display the message at all if the user cant access the link.

This can be done with $url->access rather than permission checks, which are not enough when custom access control is added on a route.

dpi’s picture

My preference is MR !106, though I think proper messaging should be added in the other existing catch blocks, and the use of HTML and faking messenger is also gross. Out of scope.

  • Berdir committed 985790ef on 8.x-1.x authored by dpi
    Issue #3064713 by Feng-Shui, dpi, quicksketch: Link "create URL aliases...
berdir’s picture

Status: Needs review » Fixed

Unsure what to do about that. Combining multiple translatable strings together is definitely not good, because that will mess with LTR languages. Fine to just go with MR 106, just removing the message seems a bit tricky, but better than showing an inaccessible link I guess.

dpi’s picture

Thanks. Happy with this headline-satisfying change.

The block remains less than ideal, lets tackle other changes in follow ups.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.