Does not include base path in searches

Created on 9 July 2025, 2 months ago

Problem/Motivation

If you have a site that uses a base path, e.g. Drupal root is "my-root", filtering does not work if you use the path from the browser. I.e.: /my-root/page1. This is especially a problem for exposed searches. Users expect to be able to use such urls.

This happens because the views_url_alias table doesn't include the base path.

Steps to reproduce

  1. Create a site with a base path, e.g. my-root
  2. Create a node with an alias of page1
  3. Create a view with Alias filtering
  4. Search for my-root/page1
  5. Get no results.
  6. Do get results for /page1

Proposed resolution

  • Add the base path via base_path() call to alias in views_url_alias_save
  • Add an update hook to rebuild the table

Remaining tasks

Have patch to add once issue is created

User interface changes

N/A

API changes

N/A

Data model changes

N/A

πŸ› Bug report
Status

Active

Version

3.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States cgmonroe

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

Merge Requests

Comments & Activities

  • Issue created by @cgmonroe
  • πŸ‡ΊπŸ‡ΈUnited States cgmonroe

    Here is a patch against the 3.1.0 branch (dev based patch will not install on release branch)

  • πŸ‡¬πŸ‡§United Kingdom rachel_norfolk UK

    Heh - I’m slightly amused that it took me longer to remember how to make a test site with a base path than it did to actually test the proposed change!

    With the change applied, the test site correctly takes into account the base path. It also continues to work when there isn’t a base path.

    There is an update function to update aliases that might already be stored, which is also nice.

    I think this is a good one. RTBC

  • πŸ‡¬πŸ‡§United Kingdom rachel_norfolk UK

    Actually, we need this against the 3.x branch, please.

    If someone can create a Merge Request, someone else test it, then I will happily merge.

    When testing, please consider the scenario that someone has both a base path and a translation.

  • First commit to issue fork.
  • Merge request !35#3535063 Include base path in searches. β†’ (Open) created by n-m-daz
  • Pipeline finished with Success
    22 days ago
    Total: 176s
    #579857
  • Pipeline finished with Success
    22 days ago
    Total: 132s
    #579859
  • Created a merge request base on patch create by cgmonroe #2 but
    I have remove the views_url_alias_update_88301() from the merge request as this will cause timeout issues on site with lots of url alias or contents. We have the "Rebuild views alias table" in "admin/structure/views/settings/alias" for this.

    Note for tester/reviewer

    This require Drupal multisite setup.

    Steps using ddev:
    1. Install Drupal as usual.
    2. Follow steps in this issue: https://www.drupal.org/project/drupal/issues/3529122#comment-16147644 πŸ’¬ Unable to set up Drupal 10 multisite using subfolders in DDEV (e.g., /site1 and /site2) Active

    After you have a multi site with sub directory setup, you will have something like this:
    https://example.ddev.site/site1
    https://example.ddev.site/site2

    The global base_path() function will now return /site1/ or /site2/ and
    Alias entries in the views_url_alias table will have the base path prepend on the url alias.

    3. Install the views_url_alias module or rebuild the table if you already have it installed.
    4. Create or edit an existing content views.
    5. Add Content URL Alias relationship.
    6. Add Content URL Alias field.
    7. Add Content URL Alias exposed filter.

    Output:
    Base path is added on the URL Alias field. E.g. /site1/node-298-article or /site2/node-298-article
    You can search url alias with base path.

Production build 0.71.5 2024