diff --git a/core/includes/batch.inc b/core/includes/batch.inc
index d1902e0..85f956e 100644
--- a/core/includes/batch.inc
+++ b/core/includes/batch.inc
@@ -153,10 +153,12 @@ function _batch_progress_page() {
// Merge required query parameters for batch processing into those provided by
// batch_set() or hook_batch_alter().
- $batch['url_options']['query']['id'] = $batch['id'];
- $batch['url_options']['query']['op'] = $new_op;
+ $query_options = $batch['url']->getOption('query');
+ $query_options['id'] = $batch['id'];
+ $query_options['op'] = $new_op;
+ $batch['url']->setOption('query', $query_options);
- $url = _url($batch['url'], $batch['url_options']);
+ $url = $batch['url']->toString();
$build = array(
'#theme' => 'progress_bar',
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 69c970f..2c7ae24 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -747,7 +747,7 @@ function batch_set($batch_definition) {
*
* @param $redirect
* (optional) Path to redirect to when the batch has finished processing.
- * @param $url
+ * @param \Drupal\Core\Url $url
* (optional - should only be used for separate scripts like update.php)
* URL of the batch processing page.
* @param $redirect_callback
@@ -757,7 +757,7 @@ function batch_set($batch_definition) {
* @return \Symfony\Component\HttpFoundation\RedirectResponse|null
* A redirect response if the batch is progressive. No return value otherwise.
*/
-function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NULL) {
+function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = NULL) {
$batch =& batch_get();
if (isset($batch)) {
@@ -765,8 +765,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU
$process_info = array(
'current_set' => 0,
'progressive' => TRUE,
- 'url' => $url,
- 'url_options' => array(),
+ 'url' => isset($url) ? $url : Url::fromRoute('system.batch_page.html'),
'source_url' => Url::fromRouteMatch(\Drupal::routeMatch()),
'batch_redirect' => $redirect,
'theme' => \Drupal::theme()->getActiveTheme()->getName(),
@@ -793,7 +792,14 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU
if ($batch['progressive']) {
// Now that we have a batch id, we can generate the redirection link in
// the generic error message.
- $batch['error_message'] = t('Please continue to the error page', array('@error_url' => _url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished')))));
+ /** @var \Drupal\Core\Url $error_url */
+ $error_url = clone $batch['url'];
+ $query_options = $error_url->getOption('query');
+ $query_options['id'] = $batch['id'];
+ $query_options['op'] = 'finished';
+ $error_url->setOption('query', $query_options);
+
+ $batch['error_message'] = t('Please continue to the error page', array('@error_url' => $error_url->toString()));
// Clear the way for the redirection to the batch processing page, by
// saving and unsetting the 'destination', if there is any.
@@ -816,12 +822,13 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU
// Redirect for processing.
$options = array('query' => array('op' => 'start', 'id' => $batch['id']));
+ $batch['url']->setOption('query', $options['query']);
if (($function = $batch['redirect_callback']) && function_exists($function)) {
$function($batch['url'], $options);
}
else {
- $options['absolute'] = TRUE;
- return new RedirectResponse(_url($batch['url'], $options));
+ $url->setAbsolute();
+ return new RedirectResponse($batch['url']->toString());
}
}
else {
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 0da2d40..cab8bd7 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -18,6 +18,7 @@
use Drupal\Core\StringTranslation\Translator\FileTranslation;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\Core\Url;
use Drupal\language\Entity\ConfigurableLanguage;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpFoundation\Request;
@@ -577,7 +578,7 @@ function install_run_task($task, &$install_state) {
// install_redirect_url() returns core/install.php, so let's ensure to
// drop it from it and use base:// as batch_process() is using the
// unrouted URL assembler, which requires base://.
- $response = batch_process(preg_replace('@^core/@', 'base://', install_redirect_url($install_state)), install_full_redirect_url($install_state));
+ $response = batch_process(preg_replace('@^core/@', 'base://', install_redirect_url($install_state)), Url::fromUri('base://' . install_full_redirect_url($install_state)));
if ($response instanceof Response) {
// Save $_SESSION data from batch.
\Drupal::service('session_manager')->save();
diff --git a/core/modules/image/src/Entity/ImageStyle.php b/core/modules/image/src/Entity/ImageStyle.php
index a57904d..b5d1221 100644
--- a/core/modules/image/src/Entity/ImageStyle.php
+++ b/core/modules/image/src/Entity/ImageStyle.php
@@ -14,6 +14,7 @@
use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
use Drupal\Core\Routing\RequestHelper;
use Drupal\Core\Site\Settings;
+use Drupal\Core\Url;
use Drupal\image\ImageEffectPluginCollection;
use Drupal\image\ImageEffectInterface;
use Drupal\image\ImageStyleInterface;
@@ -222,7 +223,7 @@ public function buildUrl($path, $clean_urls = NULL) {
// actual file path, this avoids bootstrapping PHP once the files are built.
if ($clean_urls === FALSE && file_uri_scheme($uri) == 'public' && !file_exists($uri)) {
$directory_path = file_stream_wrapper_get_instance_by_uri($uri)->getDirectoryPath();
- return _url($directory_path . '/' . file_uri_target($uri), array('absolute' => TRUE, 'query' => $token_query));
+ return Url::fromUri('base://' . $directory_path . '/' . file_uri_target($uri), array('absolute' => TRUE, 'query' => $token_query))->toString();
}
$file_url = file_create_url($uri);
diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
index c58ff1a..0f2d83e 100644
--- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
+++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
@@ -9,6 +9,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageException;
+use Drupal\Core\Url;
use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;
use Drupal\Component\Utility\String;
@@ -99,7 +100,7 @@ public function post(EntityInterface $entity = NULL) {
$entity->save();
$this->logger->notice('Created entity %type with ID %id.', array('%type' => $entity->getEntityTypeId(), '%id' => $entity->id()));
- $url = _url(strtr($this->pluginId, ':', '/') . '/' . $entity->id(), array('absolute' => TRUE));
+ $url = Url::fromUri('base://' . strtr($this->pluginId, ':', '/') . '/' . $entity->id(), ['absolute' => TRUE])->toString();
// 201 Created responses have an empty body.
return new ResourceResponse(NULL, 201, array('Location' => $url));
}
diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php
index c3c25fa..b35fb3c 100644
--- a/core/modules/system/src/Controller/DbUpdateController.php
+++ b/core/modules/system/src/Controller/DbUpdateController.php
@@ -602,7 +602,7 @@ protected function triggerBatch(Request $request) {
);
batch_set($batch);
- return batch_process('update.php/results', 'update.php/batch');
+ return batch_process('update.php/results', Url::fromUri('base://update.php/batch'));
}
/**
diff --git a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php
index 910e809..16c72c1 100644
--- a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php
+++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php
@@ -314,7 +314,6 @@ function testBreadCrumbs() {
'url' => $url,
'title' => $link->getTitle(),
]];
- debug(array_keys($tree));
$this->assertBreadcrumb($url, $trail, $term->getName(), $tree);
$this->assertEscaped($parent->getTitle(), 'Tagged node found.');
diff --git a/core/modules/system/src/Tests/Menu/MenuTestBase.php b/core/modules/system/src/Tests/Menu/MenuTestBase.php
index 89c3fe3..587fb4d 100644
--- a/core/modules/system/src/Tests/Menu/MenuTestBase.php
+++ b/core/modules/system/src/Tests/Menu/MenuTestBase.php
@@ -8,7 +8,6 @@
namespace Drupal\system\Tests\Menu;
use Drupal\Component\Utility\String;
-use Drupal\Core\Url;
use Drupal\simpletest\WebTestBase;
abstract class MenuTestBase extends WebTestBase {
@@ -97,6 +96,7 @@ protected function assertMenuActiveTrail($tree, $last_active) {
end($tree);
$active_link_url = current($tree)['url']->toString();
$active_link_title = current($tree)['title'];
+ array_pop($tree);
$xpath = '';
$expected_titles = [];
if ($tree) {
@@ -130,8 +130,6 @@ protected function assertMenuActiveTrail($tree, $last_active) {
':href' => $active_link_url,
':title' => $active_link_title,
);
- debug($xpath);
- debug($args);
$elements = $this->xpath($xpath, $args);
$this->assertTrue(!empty($elements), format_string('Active link %title was found in menu tree, including active trail links %tree.', array(
'%title' => $active_link_title,
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 603668c..a41b080 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -457,7 +457,7 @@ function system_authorized_run($callback, $file, $arguments = array(), $page_tit
function system_authorized_batch_process() {
$finish_url = system_authorized_get_url();
$process_url = system_authorized_batch_processing_url();
- return batch_process($finish_url->toString(), $process_url->toString());
+ return batch_process($finish_url->toString(), $process_url);
}
/**