Problem/Motivation
When a media type is created in the admin UI, a field is automatically created to store the media. The field name is generated automatically:
$base_id = 'field_media_' . str_replace(static::DERIVATIVE_SEPARATOR, '_', $this->getPluginId());
Here, the field_ prefix in the field name is hardcoded. However, there is a config setting for this: see https://www.drupal.org/node/2060489.
The config value should be respected here.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3218103-4-FAIL.patch | 1.35 KB | phenaproxima |
Issue fork drupal-3218103
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3218103-10.1.x
changes, plain diff MR !3392
- 3218103-media-module-creates
changes, plain diff MR !1056
Comments
Comment #4
phenaproximaFail patch to prove that the fix works as intended. The full fix is in the merge request.
Comment #6
phenaproximaFail patch failed; merge request passed. (in Emperor Palpatine voice) Good...good.
Comment #7
joachim commentedLooks good, just one comment about the use of a default value with the config.
Comment #8
phenaproximaAs @longwave points out, it could also be empty if Field UI isn't installed. So I think we want to handle three cases:
field_prefix.Maybe what's needed here is to change
?:to??so that we detect, and add test coverage for an empty prefix. Oh, and add a comment.Comment #9
phenaproximaComment #10
joachim commented> Field UI isn't installed, so that config value is null (as opposed to an empty string): use the default field_ prefix.
I think that's the right thing to do in terms of the effect... but it violates DRY, and having to differentiate between '' and NULL looks like a code smell to me.
That makes me think that the config value should be moved into the field system, rather than being in Field UI. But one for a separate issue, too much scope creep for here.
Comment #11
joachim commented> That makes me think that the config value should be moved into the field system, rather than being in Field UI. But one for a separate issue, too much scope creep for here.
Although the other question that could be asked here, is: why does a field that is created programatically use the prefix that's intended for user-created fields? More scope creep though!
Comment #15
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Can the MR please be updated for 10.1
Comment #18
rpayanmI updated the MR for 10.1
Comment #19
smustgrave commented+1 from me but will let another also take a look.
Comment #20
smustgrave commentedSo it doesn't sit here and it got 1+ for RTBC will move it on.
Comment #22
catchCommitted c10a6ab and pushed to 10.1.x. Thanks!