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

Created on 29 June 2022, about 3 years ago
Updated 24 July 2023, about 2 years 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 review

Version

9.5

Component
File systemย  โ†’

Last updated 4 days ago

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States maddysp3

Live updates comments and jobs are added and updated live.
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.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States rpayanm

    I can confirm the issue is still present in 9.5.10
    And the patch #5 worked fine.

  • last update about 2 years ago
    Patch Failed to Apply
  • Status changed to Needs work about 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    IS needs updating.

    testDeprecatedFileCreateUrl has been removed so will need a new test.

  • Status changed to Postponed 13 days ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mohit_aghera Rajkot

    I came across this issue while doing triage in Bugsmash initiative.
    I see that function file_url_transform_relative() is deprecated and removed from Drupal 10.

    This was reported in 9.4.x and 9.5.x release cycles.
    Now, both the releases are also out of the support.

    Considering that, I believe there isn't anything specific we can fix here.

    I'm marking this as postponed.
    Please reopen the issue again if you feel that this is affecting you.

    If anyone is still on 9.5.x, you can try the patch on comment #5

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia kim.pepper ๐Ÿ„โ€โ™‚๏ธ๐Ÿ‡ฆ๐Ÿ‡บSydney, Australia

    As this is only an issue on unsupported versions I think we can safely close.

Production build 0.71.5 2024