Problem/Motivation

The generator always generates a link for the verbose messenger but that might not on, so this is not necessary.

Steps to reproduce

Proposed resolution

Change/refactor VerboseMessenger (deprecate the interface, stop using?) to add verboseEnabled() method or so and then inside to the message, or using a callback or something.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork pathauto-3631761

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

berdir created an issue. See original summary.

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

realsp’s picture

Assigned: Unassigned » realsp
Status: Active » Needs review
StatusFileSize
new96.54 KB
new97.51 KB

I opened an MR https://git.drupalcode.org/project/pathauto/-/merge_requests/194

Problem

AliasStorageHelper::save() builds and renders a link to the new alias for the "Created new URL alias" message, and only then passes it to VerboseMessenger, which drops it unless verbose messages are on. Verbose is off by default, so on most sites every alias save resolves a URL through the path validator and router and renders a link nobody sees. The link was added in #3419907, and #3608478 moved it after the save. This is the remaining part.

Fix

  • New VerboseMessengerInterface extends MessengerInterface with isVerbose(?string $op = NULL): bool.
    VerboseMessenger implements it, and the existing check (setting, notify of path changes permission, op) moves into isVerbose(), which addMessage() also uses.
  • AliasStorageHelper::save() builds the link and adds the message only when isVerbose() is TRUE. If the messenger is some other MessengerInterface implementation, it behaves as before.
  • MessengerInterface is unchanged, so this doesn't break anyone implementing it.

Results

URL resolutions Messages
Before, verbose off 200 0
After, verbose off 0 0
After, verbose on 200 200

With verbose off, 200 saves took a median of 1093 ms before and 415 ms after (5 runs each, local DDEV; rough numbers).

With verbose on, the message and its alias link work as before:

Before:

 Created new URL alias /article/fix-3631761 for /node/1, with a link to the alias

After:
 Created new URL alias /article/after-fix-3631761 for /node/2, with a link to the alias

AI disclosure: Claude Code was used for the investigation and to draft this comment; reviewed and tested by a human.