Problem/Motivation
The search form at Content » Search and replace always shows "To configure settings go to Search and Replace Scanner configuration". Users with "Perform search only" or "Perform search and replace" can use the search form, but the configuration page requires "Administer scanner settings". Users without that permission get a link to a page that returns "Access denied".
The same applies to the message shown when no fields have been configured: "The search fields were not configured. To configure them go to Search and Replace Scanner configuration".
Steps to reproduce
1. Create a role with "Perform search and replace" (or "Perform search only") but not "Administer scanner settings", and log in as a user with that role.
2. Go to Content » Search and replace (/admin/content/scanner).
3. The form shows "To configure settings go to Search and Replace Scanner configuration".
4. Following the link gives "Access denied".
Proposed resolution
Check whether the current user can access the configuration page, and only link to it if they can.
Remaining tasks
- Merge request with the fix.
- Test coverage: build the search form as a user with and without "Administer scanner settings", with fields configured and with none.
- Review.
User interface changes
Users without "Administer scanner settings" no longer see the link to the configuration page.
API changes
None.
Data model changes
None.
Issue fork scanner-3625996
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:
- 3625996-search-form-links
changes, plain diff MR !118
Comments
Comment #3
john.oltman commentedThe MR is failing tests but in places unrelated to the new code, so I believe there may be an upstream issue. Hopefully resolves on its own. For now putting into review.
Comment #4
smustgrave commentedI'd pause on MRs..something in twig broke all render #3625969: Twig's 3.30 TypeError: Twig\Runtime\EscaperRuntime::escape(): Argument #4 ($autoescape) must be of type bool, null given
Comment #5
smustgrave commentedWas this AI generated?
Comment #6
john.oltman commentedAI generated, I reviewed it though - closely. I especially lean on AI to generate the tests, which it can do much faster than me.
Comment #8
smustgrave commentedThis is one I'm fine with skipping tests as it's minor to me. But I'd review the tests more from AI these look to be more complex then they needed to be.
Comment #10
smustgrave commentedThis seemed like a bug to me.