diff --git a/core/modules/path/src/Controller/PathController.php b/core/modules/path/src/Controller/PathController.php index 1b9cb7a..ef8b1cd 100644 --- a/core/modules/path/src/Controller/PathController.php +++ b/core/modules/path/src/Controller/PathController.php @@ -12,6 +12,7 @@ use Drupal\Core\Path\AliasManagerInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; /** * Controller routines for path routes. @@ -55,8 +56,8 @@ public static function create(ContainerInterface $container) { ); } - public function adminOverview() { - $keys = \Drupal::request()->query->get('search'); + public function adminOverview(Request $request) { + $keys = $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); // Enable language column if language.module is enabled or if we have any diff --git a/core/modules/path/src/Form/PathFilterForm.php b/core/modules/path/src/Form/PathFilterForm.php index 51a1a29..7c9a3f7 100644 --- a/core/modules/path/src/Form/PathFilterForm.php +++ b/core/modules/path/src/Form/PathFilterForm.php @@ -25,8 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state) { - $keys = $this->getRequest()->query->get('search') ? $this->getRequest()->query->get('search') : FALSE; + public function buildForm(array $form, FormStateInterface $form_state, $keys = NULL) { $form['#attributes'] = array('class' => array('search-form')); $form['basic'] = array( '#type' => 'details', diff --git a/core/modules/path/src/Tests/PathAdminTest.php b/core/modules/path/src/Tests/PathAdminTest.php index ef1d3e7..9073d7f 100644 --- a/core/modules/path/src/Tests/PathAdminTest.php +++ b/core/modules/path/src/Tests/PathAdminTest.php @@ -36,6 +36,7 @@ public function testPathFiltering() { // Create test nodes. $node1 = $this->drupalCreateNode(); $node2 = $this->drupalCreateNode(); + $node3 = $this->drupalCreateNode(); // Create aliases. $alias1 = $this->randomMachineName(8); @@ -52,6 +53,13 @@ public function testPathFiltering() { ); $this->drupalPostForm('admin/config/search/path/add', $edit, t('Save')); + $alias3 = $this->randomMachineName(4) . '/' . $this->randomMachineName(4); + $edit = array( + 'source' => 'node/' . $node3->id(), + 'alias' => $alias3, + ); + $this->drupalPostForm('admin/config/search/path/add', $edit, t('Save')); + // Filter by the first alias. $edit = array( 'filter' => $alias1, @@ -59,6 +67,7 @@ public function testPathFiltering() { $this->drupalPostForm(NULL, $edit, t('Filter')); $this->assertLinkByHref($alias1); $this->assertNoLinkByHref($alias2); + $this->assertNoLinkByHref($alias3); // Filter by the second alias. $edit = array( @@ -67,6 +76,16 @@ public function testPathFiltering() { $this->drupalPostForm(NULL, $edit, t('Filter')); $this->assertNoLinkByHref($alias1); $this->assertLinkByHref($alias2); + $this->assertNoLinkByHref($alias3); + + // Filter by the third alias which has a slash. + $edit = array( + 'filter' => $alias3, + ); + $this->drupalPostForm(NULL, $edit, t('Filter')); + $this->assertNoLinkByHref($alias1); + $this->assertNoLinkByHref($alias2); + $this->assertLinkByHref($alias3); // Filter by a random string with a different length. $edit = array(