File::generateSampleValue makes bad Uris

Created on 30 August 2024, 5 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 2 hours ago

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024