Problem/Motivation

On the Monitoring sensors overview page (the route monitoring.sensor_list at /admin/reports/monitoring), the Edit dropdown link in SensorList::content() sets the destination query parameter to the literal string admin/reports/monitoring:

$links['edit'] = array(
  'title' => t('Edit'),
  'url' => $sensor_config->toUrl('edit-form'),
  'query' => array('destination' => 'admin/reports/monitoring')
);

This hardcoded path bypasses the routing system. Sites using the Rename Admin Paths module (which rewrites admin to another segment, for example adm) are redirected to the literal /admin/reports/monitoring after saving a sensor, which 404s or falls through to access-denied depending on the rename configuration.

Steps to reproduce

  1. Install Monitoring and Rename Admin Paths, and rename admin to for example adm.
  2. Visit the sensors overview at the renamed path (for example /adm/reports/monitoring).
  3. Click Edit on any sensor, change a value, save.
  4. Observe the redirect lands on the literal /admin/reports/monitoring (not the renamed path).

Proposed resolution

Generate the destination from the route instead of hardcoding the path. Pattern already used upstream in #3547508 for domain_content:

use DrupalCoreUrl;
// ...
'query' => ['destination' => Url::fromRoute('monitoring.sensor_list')->toString()],

Remaining tasks

  • Replace the hardcoded destination string in src/Controller/SensorList.php.
  • Add the use DrupalCoreUrl; import.

User interface changes

None — the Edit link still goes to the same edit form and still returns the user to the sensor list after saving. It now uses the routed URL, which respects modules like Rename Admin Paths.

API changes

None.

Data model changes

None.

Issue fork monitoring-3586573

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

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review