diff -u b/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php --- b/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -301,11 +301,9 @@ $form['#build_id'] = 'form-' . Crypt::randomBytesBase64(); } - // #action defaults to - // $this->requestStack->getCurrentRequest()->getRequestUri(), - // but in case of Ajax and other partial rebuilds, the form - // is submitted to an alternate URL, and the original - // #action needs to be retained. + // #action defaults to $request->getRequestUri(), but in case of Ajax and other partial + // rebuilds, the form is submitted to an alternate URL, and the original + // #action needs to be retained. if (isset($old_form['#action']) && !empty($rebuild_info['copy']['#action'])) { $form['#action'] = $old_form['#action']; } @@ -536,7 +534,7 @@ // Only update the action if it is not already set. if (!isset($form['#action'])) { - $form['#action'] = $this->requestUri(); + $form['#action'] = $this->requestStack->getCurrentRequest()->getRequestUri(); } // Fix the form method, if it is 'get' in $form_state, but not in $form. @@ -1103,11 +1101,2 @@ - /** - * Gets the current request URI. - * - * @return string - */ - protected function requestUri() { - return $this->requestStack->getCurrentRequest()->getRequestUri(); - } - } only in patch2: unchanged: --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -598,6 +598,12 @@ function drupal_validate_utf8($text) { * equivalent using other environment variables. * * @todo The above comment is incorrect: http://drupal.org/node/1547294. + * + * NB This function is intended for limited use, in cases before the $container + * is available. Use $request->getRequestUri() whereever possible. + * + * @return string + * The request URI */ function request_uri($omit_query_string = FALSE) { if (isset($_SERVER['REQUEST_URI'])) { only in patch2: unchanged: --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -866,10 +866,10 @@ protected function initializeRequestGlobals(Request $request) { // are in effect and the script path can be similarly dropped from URL // generation. For servers that don't provide $_SERVER['REQUEST_URI'], // we do not know the actual URI requested by the client, and - // request_uri() returns a URI with the script name, resulting in + // $request->getRequestUri() returns a URI with the script name, resulting in // non-clean URLs unless // there's other code that intervenes. - if (strpos(request_uri(TRUE) . '/', $base_path . $script_path) !== 0) { + if (strpos($request->getRequestUri(TRUE) . '/', $base_path . $script_path) !== 0) { $script_path = ''; } // @todo Temporary BC for install.php, authorize.php, and other scripts. only in patch2: unchanged: --- a/core/modules/dblog/src/Tests/DbLogTest.php +++ b/core/modules/dblog/src/Tests/DbLogTest.php @@ -143,7 +143,7 @@ private function generateLogEntries($count, $type = 'custom', $severity = RfcLog 'link' => NULL, 'user' => $this->adminUser, 'uid' => $this->adminUser->id(), - 'request_uri' => $base_root . request_uri(), + 'request_uri' => $base_root . \Drupal::request()->getRequestUri(), 'referer' => \Drupal::request()->server->get('HTTP_REFERER'), 'ip' => '127.0.0.1', 'timestamp' => REQUEST_TIME, @@ -452,7 +452,7 @@ protected function testDBLogAddAndClear() { 'link' => NULL, 'user' => $this->adminUser, 'uid' => $this->adminUser->id(), - 'request_uri' => $base_root . request_uri(), + 'request_uri' => $base_root . \Drupal::request()->getRequestUri(), 'referer' => \Drupal::request()->server->get('HTTP_REFERER'), 'ip' => '127.0.0.1', 'timestamp' => REQUEST_TIME, only in patch2: unchanged: --- a/core/modules/locale/src/LocaleLookup.php +++ b/core/modules/locale/src/LocaleLookup.php @@ -12,6 +12,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Lock\LockBackendInterface; +use Symfony\Component\HttpFoundation\Request; /** * A cache collector to allow for dynamic building of the locale cache. @@ -66,6 +67,13 @@ class LocaleLookup extends CacheCollector { * @var \Drupal\Core\Language\LanguageManagerInterface */ protected $languageManager; + + /** + * The current request. + * + * @var \Symfony\Component\HttpFoundation\Request + */ + protected $request; /** * Constructs a LocaleLookup object. @@ -84,13 +92,16 @@ class LocaleLookup extends CacheCollector { * The config factory. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. + * @param \Symfony\Component\HttpFoundation\Request $request + * The current request. */ - public function __construct($langcode, $context, StringStorageInterface $string_storage, CacheBackendInterface $cache, LockBackendInterface $lock, ConfigFactoryInterface $config_factory, LanguageManagerInterface $language_manager) { + public function __construct($langcode, $context, StringStorageInterface $string_storage, CacheBackendInterface $cache, LockBackendInterface $lock, ConfigFactoryInterface $config_factory, LanguageManagerInterface $language_manager, Request $request) { $this->langcode = $langcode; $this->context = (string) $context; $this->stringStorage = $string_storage; $this->configFactory = $config_factory; $this->languageManager = $language_manager; + $this->request = $request; $this->cache = $cache; $this->lock = $lock; @@ -178,10 +189,10 @@ protected function resolveCacheMiss($offset) { } /** - * Wraps request_uri(). + * Wraps $request->getRequestUri(). */ protected function requestUri($omit_query_string = FALSE) { - return request_uri($omit_query_string); + return $this->getRequestUri($omit_query_string); } } only in patch2: unchanged: --- a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php +++ b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php @@ -328,13 +328,6 @@ public function drupalStaticReset($name = NULL) { static::$seenIds = array(); } - /** - * {@inheritdoc} - */ - protected function requestUri() { - return ''; - } - } }