Leading slash in exposed "from" filter in redirect view does not allow to search redirects

Created on 7 October 2022, about 2 years ago
Updated 6 August 2024, 4 months ago

Problem/Motivation

Under /admin/config/search/redirect view there is an issue with the "From" exposed filter. When looking for an alias with a leading slash, there are no results returned. Removing the leading slash gives correct result.
This is misleading, as the "From" column in the search results contains leading slash.

Steps to reproduce

  1. Create a node with an alias "/testing-redirects".
  2. Go to /admin/config/search/redirect
  3. Add new redirect from "/testing-redirects" to something else i.e. https://drupal.org
  4. Try to enter "/testing-redirects" in "From" column - there are no results returned
  5. Try to enter "testing-redirects" in "From" column - there is a result returned
  6. Observe, that the returned result contains leading slash

No results returned for redirect with leading slash:

Result returned for redirect without leading slash:

Proposed resolution

The mentioned situation happens because the following SQL query is being executed on the redirect view:

SELECT "redirect"."rid" AS "rid"
FROM
{redirect} "redirect"
WHERE "redirect"."redirect_source__path" LIKE '%/testing-redirect%' ESCAPE '\\'
ORDER BY "redirect"."created" ASC
LIMIT 50 OFFSET 0

The redirect.redirect_source__path column does not include leading slash, so looking for a redirect with leading slash gives no result. My proposal for the fix is to remove leading slash from the view results output to avoid confusion.

Remaining tasks

Review the issue, propose and implement solution.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇵🇱Poland piotrkonefal

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024