Skip to content
Snippets Groups Projects
Commit d60ba4d8 authored by catch's avatar catch
Browse files

Issue #3254727 by Leon Kessler, ranjith_kumar_k_u, cmlara, andileco: File...

Issue #3254727 by Leon Kessler, ranjith_kumar_k_u, cmlara, andileco: File links with query parameters no longer work
parent e5c38d9e
No related branches found
No related tags found
No related merge requests found
......@@ -1522,7 +1522,7 @@ function template_preprocess_file_link(&$variables) {
$variables['attributes']->addClass($classes);
$variables['file_size'] = format_size($file->getSize() ?? 0);
$variables['link'] = Link::fromTextAndUrl($link_text, $url->setOptions($options))->toRenderable();
$variables['link'] = Link::fromTextAndUrl($link_text, $url->mergeOptions($options))->toRenderable();
}
/**
......
......@@ -16,7 +16,7 @@ class FileEntityFormatterTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['file', 'user'];
protected static $modules = ['file', 'user', 'file_test'];
/**
* The files.
......@@ -171,4 +171,22 @@ public function testFormatterFileSize() {
}
}
/**
* Tests the file_link field formatter using a query string.
*/
public function testFormatterFileLinkWithQueryString() {
$file = File::create([
'uri' => 'dummy-external-readonly://file-query-string?foo=bar',
'filename' => 'file-query-string',
]);
$file->save();
$file_link = [
'#theme' => 'file_link',
'#file' => $file,
];
$output = \Drupal::service('renderer')->renderRoot($file_link);
$this->assertStringContainsString($this->fileUrlGenerator->generate('dummy-external-readonly://file-query-string?foo=bar')->toUriString(), $output);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment