Solr Batch export should use route instead of hardcoded path for redirection

Created on 28 May 2025, 2 months ago

Problem/Motivation

On some projects, it may occur that the /admin paths are rewritten to something else (e.g. on a project, we use https://www.drupal.org/project/rename_admin_paths to override "/admin" with "/administration").
When doing so, any hard-coded path will result into a 404 error because the overriding usually happens on route_alter.

Steps to reproduce

- Install https://www.drupal.org/project/rename_admin_paths and navigate to '/admin/config/system/rename-admin-paths' to rename the admin path to something else (e.g. "administration").
- Install and configure SOLR Search Synonym
- Navigate to the list page of SOLR synonyms
- Click the "Import to Solr" button
- You should end up on a 404 page instead of the batch page.

Proposed resolution

In SolrSynonymUploaderBatchExport.php, replace :
$redirect_url = '/admin/config/search/solr-search-synonyms';
with :
$redirect_url = Url::fromRoute('entity.solr_search_synonym.collection')->toString();

It will solve the above problem and be more robust if the route path should change in the future for any reason.
Attached is a patch for immediate use.

Remaining tasks

Include this change in the main module branch.

Feature request
Status

Active

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024