Changing admin path makes content --> files disappear

Created on 20 May 2022, almost 3 years ago
Updated 2 May 2024, 11 months ago

Problem/Motivation

After changing admin path by using the module "Rename Admin Paths", in the Content menu the link to manage Files is not visible anymore.
See attached screenshots.

Steps to reproduce

Login as administrator
Click Content, see Contents, Comments and files
Extent --> Rename admin path --> Configure --> Rename admin path
Click Content, see Contents and Comments
Extent --> Rename admin path --> Configure --> Reset admin path to default
Click Content, see Contents, Comments and files

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • 🇺🇸United States johnlutz

    Can confirm that this happens for me as well.

    Drupal 10.3.6
    rename_admin_paths 3.0.0

  • 🇯🇵Japan ptmkenny

    The file list admin page is still available at https://example.com/backend/content/files

    You can "fix" this by editing the configuration of the file list admin view at https://example.com/backend/structure/views/view/files/edit/page_1. Change the "path" from "admin/content/files" to "backend/content/files".

    I don't understand why the content view at /admin/content is overridden correctly, but the files view at /admin/content/files is not. However, since there is a workaround available, I'm setting this issue to "Minor".

  • Assigned to jaydev bhatt
  • 🇮🇳India jaydev bhatt Pune, Maharashtra
  • 🇮🇳India jaydev bhatt Pune, Maharashtra

    I attempted to recreate this issue on Drupal 11, and the problem persists.

    When the admin path is changed via the “Rename Admin Paths” module, the “Files” link in the Content menu no longer appears. This issue seems to be tied to the admin path alteration, which causes a routing mismatch, preventing the “Files” link from being displayed.

    After further investigation, I found that the menu links for managing Files were closely tied to the default admin path. Altering this path caused the routing issue.

    To resolve this, I implemented a function that dynamically handles path changes based on a flag (revert) and a dynamic prefix. When updating the path, the “admin” prefix is replaced with a dynamic prefix (e.g., “backend”). When reverting, it switches back to “admin”. This ensures that paths are updated consistently based on the current configuration.

    By implementing this function, whenever the admin route is altered, the function ensures that all related view paths are updated accordingly to the user’s specified prefix.

    I’m attaching the patch file for the fix and moving this to “Needs Review.”

  • 🇮🇳India jaydev bhatt Pune, Maharashtra

    Updating the patch file for the views namespace issue

  • 🇯🇵Japan ptmkenny

    Please submit an MR, not a patch. Patches are no longer tested by CI, so we need an MR to run the CI tests.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 143s
    #442633
  • Pipeline finished with Failed
    about 1 month ago
    Total: 255s
    #442706
  • Pipeline finished with Failed
    about 1 month ago
    Total: 398s
    #442716
  • Pipeline finished with Failed
    about 1 month ago
    Total: 161s
    #442730
  • Pipeline finished with Failed
    about 1 month ago
    Total: 191s
    #442743
  • Pipeline finished with Success
    about 1 month ago
    Total: 180s
    #442748
  • 🇮🇳India jaydev bhatt Pune, Maharashtra

    Created the MR and Fixed all the PHPCS, PHPstan and PHPunit issues.
    moving this to NR but can taken to RTBC.

  • 🇯🇵Japan ptmkenny

    Thanks, this is an interesting approach.

    I will try to do a full review later, but the first issue I noticed:

    1. Install the module and change the admin path. The views get renamed.
    2. Uninstall the module.
    3. The views did not get renamed because the module config was not saved.

    So I think this needs an uninstall hook as well.

  • 🇮🇳India jaydev bhatt Pune, Maharashtra

    Sure i'll work on this.

  • Pipeline finished with Failed
    28 days ago
    Total: 166s
    #444426
  • Pipeline finished with Failed
    28 days ago
    Total: 224s
    #444448
  • Pipeline finished with Failed
    28 days ago
    Total: 299s
    #444470
  • Pipeline finished with Success
    28 days ago
    Total: 153s
    #444500
  • 🇮🇳India jaydev bhatt Pune, Maharashtra

    I have added an uninstall hook in the .install file to revert the Views paths back to the default admin path when the module is uninstalled. Here’s what the update does:
    •It retrieves the custom admin path from the module’s configuration (rename_admin_paths.settings).
    •It loads all Views in the system and iterates through their display settings.
    •If a View’s path starts with the custom admin path, it replaces it with admin, effectively reverting it to the default.
    •The updated View is then saved to apply the changes.
    •Finally, the render cache is cleared to ensure the changes take effect immediately.

    Additionally, I have fixed a couple of PHPCS issues, including enforcing stricter empty checks and adding a missing short description in the doc comment. I also replaced the deprecated invalidateAll() method with deleteAll() to ensure compatibility with Drupal 11 and future versions.

    Keeping this in Review for verification for the code.

    Thank you!

Production build 0.71.5 2024