TypeError: Argument 1 passed to Drupal\Core\File\FileUrlGenerator::transformRelative() must be of the type string, null given

Created on 29 June 2022, almost 2 years ago
Updated 24 July 2023, 11 months ago

I am upgrading to 9.3.16. The backwards compatibility layer for file_uri() addressed in https://www.drupal.org/project/drupal/issues/3254245 β†’ applies only for generateAbsoluteString and generateString.. but does not apply for transformRelative... So I am getting following error message after upgrading to 9.3.16..

TypeError: Argument 1 passed to Drupal\Core\File\FileUrlGenerator::transformRelative() must be of the type string, null given, called in /var/www/docroot/core/includes/file.inc on line 105 in Drupal\Core\File\FileUrlGenerator->transformRelative() (line 208 of core/lib/Drupal/Core/File/FileUrlGenerator.php)

After I patched locally with below fix, its working !

function file_url_transform_relative($file_url) {
@trigger_error('file_url_transform_relative() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\File\FileUrlGenerator::transformRelative() instead. See https://www.drupal.org/node/2940031 β†’ ', E_USER_DEPRECATED);
++ if (is_null($file_url)) {
++ return NULL;
++ }
return \Drupal::service('file_url_generator')->transformRelative($file_url);
}

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
File systemΒ  β†’

Last updated about 2 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States maddysp3

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • 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.

Production build 0.69.0 2024