diff --git a/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php b/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php index 833580f..921c223 100644 --- a/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php @@ -30,6 +30,6 @@ public function getDirectoryPath() { */ function getExternalUrl() { $path = str_replace('\\', '/', $this->getTarget()); - return url('system/files/' . $path, array('absolute' => TRUE)); + return url('system/files', array('absolute' => TRUE, 'query' => array('file' => $path))); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php b/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php index 0763507..46dad9e 100644 --- a/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php @@ -103,7 +103,7 @@ function testFileCreateUrl() { $script_path_original = $script_path; foreach (array('', 'index.php/') as $script_path) { $this->checkUrl('public', '', $basename, $base_url . '/' . file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath() . '/' . $basename_encoded); - $this->checkUrl('private', '', $basename, $base_url . '/' . $script_path . 'system/files/' . $basename_encoded); + $this->checkUrl('private', '', $basename, url($base_url . '/' . $script_path . 'system/files', array('query' => array('file' => $basename_encoded)))); } $script_path = $script_path_original; } diff --git a/core/modules/system/lib/Drupal/system/FileController.php b/core/modules/system/lib/Drupal/system/FileController.php index 67aeeff..064c555 100644 --- a/core/modules/system/lib/Drupal/system/FileController.php +++ b/core/modules/system/lib/Drupal/system/FileController.php @@ -9,6 +9,8 @@ use Drupal\Core\Extension\ModuleHandler; use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Controller\ControllerInterface; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpFoundation\BinaryFileResponse; @@ -45,16 +47,14 @@ public function __construct(ModuleHandler $module_handler) { * * @see hook_file_download() */ - function fileDownload() { + function fileDownload(Request $request, $scheme) { + $target = $request->request->get('file'); // Merge remaining path arguments into relative file path. - $args = func_get_args(); - $scheme = array_shift($args); - $target = implode('/', $args); $uri = $scheme . '://' . $target; if (file_stream_wrapper_valid_scheme($scheme) && file_exists($uri)) { // Let other modules provide headers and controls access to the file. - $headers = $this->moduleHandler->invokeAll('file_download', $uri); + $headers = $this->moduleHandler->invokeAll('file_download', array($uri)); foreach ($headers as $result) { if ($result == -1) { diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index b3f0c9d..25a2cd4 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -78,6 +78,6 @@ system_files: pattern: '/system/files' defaults: _controller: 'Drupal\system\FileController::fileDownload' - file_type: private + scheme: private requirements: _access: 'TRUE'