File::generateSampleValue makes bad Uris

Created on 30 August 2024, 3 months ago

I'm using devel_generate to generate nodes which have file attachments.
Drupal\file\Plugin\Field\FieldType\FileItem::generateSampleValue()
generates uris with 3 slashes when files are not configured to be in a subdirectory. so if $settings['file_directory'] is configured it's great
private://my_dir/blah.txt
otherwise
private:///blah.txt

Suggested fix. Instead of
$destination = $dirname . '/' . $random->name(10, TRUE) . '.txt';
this

    if ($settings['file_directory']) {
      $dirname .= '/';
    }
    $destination = $dirname . $random->name(10, TRUE) . '.txt';
🐛 Bug report
Status

Active

Version

10.3

Component
File system 

Last updated about 11 hours ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024