diff --git a/core/modules/search/lib/Drupal/search/Form/SearchBlockForm.php b/core/modules/search/lib/Drupal/search/Form/SearchBlockForm.php index a28b6dd..a384ff7 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchBlockForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchBlockForm.php @@ -7,8 +7,10 @@ namespace Drupal\search\Form; +use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Form\FormInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; /** * Builds the search form for the Search Block. @@ -16,6 +18,13 @@ class SearchBlockForm implements FormInterface { /** + * The current request. + * + * @var \Symfony\Component\HttpFoundation\Request + */ + protected $request; + + /** * {@inheritdoc} */ public function getFormID() { @@ -25,7 +34,10 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, array &$form_state, Request $request = NULL) { + // Save the request variable for use in the submit method. + $this->request = $request; + $form['search_block_form'] = array( '#type' => 'search', '#title' => t('Search'), @@ -54,8 +66,8 @@ public function submitForm(array &$form, array &$form_state) { // The search form relies on control of the redirect destination for its // functionality, so we override any static destination set in the request. // See http://drupal.org/node/292565. - if (isset($_GET['destination'])) { - unset($_GET['destination']); + if (isset($this->request) && $this->request->query->has('destination')) { + $this->request->query->remove('destination'); } // Check to see if the form was submitted empty. @@ -77,5 +89,4 @@ public function submitForm(array &$form, array &$form_state) { form_set_error(NULL, t('Search is currently disabled.'), 'error'); } } - }