PHP Exception because of preprocess_file_link

Created on 2 April 2018, over 6 years ago
Updated 15 July 2024, about 2 months ago

preprocess_file_link uses file_create_url function and tries to generate a link.
But file_create_url could return FALSE
.....

* @return string
 *   A string containing a URL that may be used to access the file.
 *   If the provided string already contains a preceding 'http', 'https', or
 *   '/', nothing is done and the same string is returned. If a stream wrapper
 *   could not be found to generate an external URL, then FALSE is returned.

....

in this case Url::fromUri will throw InvalidArgumentException

πŸ› Bug report
Status

Closed: outdated

Version

11.0 πŸ”₯

Component
File moduleΒ  β†’

Last updated 5 days ago

Created by

πŸ‡ΊπŸ‡¦Ukraine kashandarash

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia kim.pepper πŸ„β€β™‚οΈπŸ‡¦πŸ‡ΊSydney, Australia

    I think we can safely close this one as outdated. file_create_url() was deprecated in drupal 9.3.0 and template_preprocess_file_link() now calls \Drupal\Core\File\FileUrlGeneratorInterface::generate() which returns a \Drupal\Core\Url object (not FALSE or NULL).

Production build 0.71.5 2024