I'm using the rename admin paths module to change the admin path. Once I did this, the config page for thesmtp module had no link in the configuration menu. Claude gave me this analysis and fix:

The getParentMenuName() method in Api.php (around line 859) was calling Url::fromUri('internal:/' . $path) with hardcoded paths like admin/config/ai. When rename_admin_paths changes /admin to /backend, this path lookup throws an exception.

The fix wraps the URL resolution in a try/catch:

PHP

public function getParentMenuName(string $path): ?string {
$parts = explode('/', trim($path, '/'));
array_pop($parts);
$path = implode('/', $parts);
try {
$url = Url::fromUri('internal:/' . $path);
$links = $this->menuLinkManager->loadLinksByRoute($url->getRouteName(), $url->getRouteParameters());
if (!empty($links)) {
$menuLink = reset($links);
return $menuLink->getPluginId();
}
}
catch (\Exception $e) {
// Path may not exist if admin paths are renamed.
}
return NULL;
}

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

pglatz created an issue. See original summary.

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

jurgenhaas’s picture

Version: 1.1.2 » 1.1.x-dev
Category: Bug report » Task
Status: Active » Needs review

Ah, there is a mixed relationship with this module. It's causing a lot of trouble, and I still don't get the reason why it should even be used. It certainly doesn't increase the site's security in any shape or format.

Anyway, just putting a try/catch into the code here would not really solve the problem. I've instead refactored the way we determine the parent menu item from a patch. Please give it a try and set the issue status to RTBC if it works in your context.