Problem/Motivation

Forward slash in filter aliases in URL alias overview doesn't filter to show only aliases containing a forward slash.

Steps to reproduce:

Add a couple of url aliases

Go to /admin/config/search/path and try to find "tags/example"

As result you get:

Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "keys" for route "/admin/config/search/path/list/{keys}" must match "[^/]++" ("tags/example" given) to generate a corresponding URL. in Symfony\Component\Routing\Generator\UrlGenerator->doGenerate() (line 167 of core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php).
Symfony\Component\Routing\Generator\UrlGenerator->doGenerate([Array], [Array], [Array], [Array], [Array], /admin/config/search/path/list/{keys}, FALSE, [Array])
Drupal\Core\Routing\UrlGenerator->getInternalPathFromRoute(Symfony\Component\Routing\Route, [Array])
Drupal\Core\Routing\UrlGenerator->generateFromRoute(path.admin_overview_filter, [Array], [Array])
Drupal\Core\Url->toString()
Drupal\Core\Form\FormSubmitter->redirectForm(Drupal\Core\Form\FormState)
Drupal\Core\Form\FormSubmitter->doSubmitForm([Array], Drupal\Core\Form\FormState)
Drupal\Core\Form\FormBuilder->processForm(path_admin_filter_form, [Array], Drupal\Core\Form\FormState)
Drupal\Core\Form\FormBuilder->buildForm(Drupal\path\Form\PathFilterForm, Drupal\Core\Form\FormState)
Drupal\Core\Form\FormBuilder->getForm(Drupal\path\Form\PathFilterForm, NULL)
Drupal\path\Controller\PathController->adminOverview(NULL)
call_user_func_array([Array], [Array])
Drupal\Core\Controller\HtmlPageController->getContentResult(Symfony\Component\HttpFoundation\Request, \Drupal\path\Controller\PathController::adminOverview)
Drupal\Core\Controller\HtmlPageController->content(Symfony\Component\HttpFoundation\Request, \Drupal\path\Controller\PathController::adminOverview)
call_user_func_array([Array], [Array])
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Symfony\Component\HttpFoundation\Request, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Symfony\Component\HttpFoundation\Request, 1, TRUE)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Symfony\Component\HttpFoundation\Request, 1, TRUE)
Drupal\Core\StackMiddleware\PageCache->handle(Symfony\Component\HttpFoundation\Request, 1, TRUE)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Symfony\Component\HttpFoundation\Request, 1, TRUE)
Stack\StackedHttpKernel->handle(Symfony\Component\HttpFoundation\Request, 1, TRUE)
Drupal\Core\DrupalKernel->handle(Symfony\Component\HttpFoundation\Request)

Proposed resolution

See patch

Remaining tasks

Commit to Drupal 7.x

User interface changes

None

API changes

None

Original report by @username

When using the filter aliases form at the following path: admin/config/search/path/list/tools, it is impossible to search for an url alias containing a forward slash.
If you search for 'foo/bar ' for instance, the search is only done to foo, due to the fact the bar is assumed to be another argument.

It might be an idea to change the search term from an argument to an url-parameter.

Comments

MantasK’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new705 bytes

Uploading patch

dawehner’s picture

Version: 7.22 » 8.0.x-dev
Priority: Minor » Critical
Issue summary: View changes
berdir’s picture

Status: Needs review » Active

Patch is for 7.x, 8.x needs a completely different solution, so setting to active, not needs work.

swentel’s picture

Status: Active » Needs review
StatusFileSize
new2.42 KB

So something like this by passing the search in the url ?

berdir’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
+++ b/core/modules/path/src/Controller/PathController.php
@@ -55,7 +55,8 @@ public static function create(ContainerInterface $container) {
-  public function adminOverview($keys) {
+  public function adminOverview() {
+    $keys = \Drupal::request()->query->get('search');
     // Add the filter form above the overview table.
     $build['path_admin_filter_form'] = $this->formBuilder()->getForm('Drupal\path\Form\PathFilterForm', $keys);

We should add Request $request to the constructor here I think.

Also passing it along to the form seems pointless if you switch to getting it from the request there? Is that really necessary?

But yes, I think that is the way to go here. I hope we have at least some test coverage of that filtering, then it should be easy to add another condition for some/path.

dawehner’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new3.57 KB
new1.85 KB
new4.03 KB

You can simplify stuff here a bit ... the path controller can get it with the controller arguments and the form can use the passed along keys directly.

Here is also a test to cover the thing.

The last submitted patch, 6: 2039709-fail.patch, failed testing.

berdir’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D7

This looks good to me and I think is the correct fix here. Has test coverage.

Some fix will also be necessary in 7.x, so tagging accordingly. but it can be downgraded to a normal/major bug again, as it doesn't cause an exception like it does in 8.x.

alexpott’s picture

Version: 8.0.x-dev » 7.x-dev
Priority: Critical » Major
Status: Reviewed & tested by the community » Patch (to be ported)

Committed 8afff8c and pushed to 8.0.x. Thanks!

diff --git a/core/modules/path/src/Controller/PathController.php b/core/modules/path/src/Controller/PathController.php
index ef8b1cd..ffabbde 100644
--- a/core/modules/path/src/Controller/PathController.php
+++ b/core/modules/path/src/Controller/PathController.php
@@ -56,6 +56,15 @@ public static function create(ContainerInterface $container) {
     );
   }
 
+  /**
+   * Displays the path administration overview page.
+   *
+   * @param \Symfony\Component\HttpFoundation\Request $request
+   *   The request object.
+   *
+   * @return array
+   *   A render array as expected by drupal_render().
+   */
   public function adminOverview(Request $request) {
     $keys = $request->query->get('search');
     // Add the filter form above the overview table.

Added docblock on commit.

  • alexpott committed 8afff8c on 8.0.x
    Issue #2039709 by dawehner, swentel, MantasK | jurcello: Fixed Forward...
kala4ek’s picture

About backport to D7, looks like patch from https://www.drupal.org/node/2418755 do it.

  • alexpott committed 8afff8c on 8.1.x
    Issue #2039709 by dawehner, swentel, MantasK | jurcello: Fixed Forward...

  • alexpott committed 8afff8c on 8.3.x
    Issue #2039709 by dawehner, swentel, MantasK | jurcello: Fixed Forward...

  • alexpott committed 8afff8c on 8.3.x
    Issue #2039709 by dawehner, swentel, MantasK | jurcello: Fixed Forward...

  • alexpott committed 8afff8c on 8.4.x
    Issue #2039709 by dawehner, swentel, MantasK | jurcello: Fixed Forward...

  • alexpott committed 8afff8c on 8.4.x
    Issue #2039709 by dawehner, swentel, MantasK | jurcello: Fixed Forward...
xrxphawxby’s picture

Path #1 appears to work correctly in Drupal 7.

donquixote’s picture

Alternative to using multiple path fragments, what about urlencode() + urldecode()?
But ok for me to use the fragments, to be closer to the D8 solution, and perhaps more BC in D7.

donquixote’s picture

Status: Patch (to be ported) » Needs review

Queued re-test for patch #1.

solideogloria’s picture

Patch #1 works for me, but is it okay for the URL to be admin/config/search/path/list/search/terms/here if searching for search/terms/here? What would happen if some custom module creates a page at that URL?

Also, I changed the patch slightly to fix the coding standard for the comment.

solideogloria’s picture

StatusFileSize
new713 bytes
solideogloria’s picture

Status: Needs review » Reviewed & tested by the community

Re: my question in #20, searching for the last part in a URL conflict would indeed navigate to that page.

However, I consider that to be out of the scope of this issue, since a module or admin would have to intentionally add such a conflict.

izmeez’s picture

Why are tests failing?

izmeez’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new348 bytes

Patch in comment #1 passes tests while patch in #21 fails yet the only difference is formatting for coding standards. Attached is an interdiff.

solideogloria’s picture

Status: Needs review » Reviewed & tested by the community

The tests just needed to be run again.

solideogloria’s picture

Issue summary: View changes
solideogloria’s picture

Issue summary: View changes
mcdruid’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

The D8 fix added to the tests to specifically check a search term including one or more slashes (see #6).

We should do the same for D7.

izmeez’s picture

Added #2418755: Path alias filter by system path as related issue with patch for D7 in comment #1, https://www.drupal.org/project/drupal/issues/2418755#comment-9722205 that has been RTBC, without the patch "it's very hard to find alias which contains few slashes in path."

solideogloria’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new2.7 KB
new1.93 KB

I added tests and tested them with the fix. Two will fail without the fix, because (1) the slash and anything after it will be removed from the filter input element, and (2) an extra node will show in the search results.

solideogloria’s picture

Realized I forgot to delete an alias. Fixed.

The last submitted patch, 30: path-allow_slash_in_overview-2039709-30.patch, failed testing. View results

mcdruid’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs backport to D7 +Pending Drupal 7 commit

The tests look great, thanks!

fabianx’s picture

RTBC + 1

  • mcdruid committed 9e44325 on 7.x
    Issue #2039709 by solideogloria, dawehner, MantasK, swentel, izmeez,...
mcdruid’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Pending Drupal 7 commit

Thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

solideogloria’s picture