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
Comment #1
MantasK commentedUploading patch
Comment #2
dawehnerUpdating this issue based upon #2357039: Adding "/" in url alias search fatals
Comment #3
berdirPatch is for 7.x, 8.x needs a completely different solution, so setting to active, not needs work.
Comment #4
swentel commentedSo something like this by passing the search in the url ?
Comment #5
berdirWe 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.
Comment #6
dawehnerYou 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.
Comment #8
berdirThis 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.
Comment #9
alexpottCommitted 8afff8c and pushed to 8.0.x. Thanks!
Added docblock on commit.
Comment #11
kala4ekAbout backport to D7, looks like patch from https://www.drupal.org/node/2418755 do it.
Comment #17
xrxphawxby commentedPath #1 appears to work correctly in Drupal 7.
Comment #18
donquixote commentedAlternative 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.
Comment #19
donquixote commentedQueued re-test for patch #1.
Comment #20
solideogloria commentedPatch #1 works for me, but is it okay for the URL to be
admin/config/search/path/list/search/terms/hereif searching forsearch/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.
Comment #21
solideogloria commentedComment #22
solideogloria commentedRe: 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.
Comment #23
izmeez commentedWhy are tests failing?
Comment #24
izmeez commentedPatch in comment #1 passes tests while patch in #21 fails yet the only difference is formatting for coding standards. Attached is an interdiff.
Comment #25
solideogloria commentedThe tests just needed to be run again.
Comment #26
solideogloria commentedComment #27
solideogloria commentedComment #28
mcdruid commentedThe 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.
Comment #29
izmeez commentedAdded #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."
Comment #30
solideogloria commentedI 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.
Comment #31
solideogloria commentedRealized I forgot to delete an alias. Fixed.
Comment #33
mcdruid commentedThe tests look great, thanks!
Comment #34
fabianx commentedRTBC + 1
Comment #36
mcdruid commentedThanks everyone!
Comment #38
solideogloria commentedIt'd be nice if someone could review #3189420: Underscores in filter aliases in url alias overview treated as wildcards as well.