Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292343

File::generateSampleValue makes bad Uris

$
0
0

Problem/Motivation

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

Steps to reproduce

From the description
1. Use devel_generate
2. generate some content for something that has file attached
3. Don't set file_directory in settings.php

Proposed resolution

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

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

Remaining tasks

Review

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A


Viewing all articles
Browse latest Browse all 292343

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>