Skip to content
This repository was archived by the owner on Jan 5, 2018. It is now read-only.

Commit d80358a

Browse files
gaurav-bajpaiBerdir
authored andcommitted
Issue #2679239 by gaurav.bajpai: Editing the MimeTypes of a file type is buggy
1 parent 51dad17 commit d80358a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

file_entity.install

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,13 @@ function file_entity_uninstall() {
8888
// Remove the added column to the core {file_managed} table.
8989
db_drop_field('file_managed', 'type');
9090
}
91+
/**
92+
* Update existing bogus entries for File types Document.
93+
*/
94+
function file_entity_update_8002(&$sandbox) {
95+
foreach (\Drupal::configFactory()->listAll('file_entity') as $config_name) {
96+
$config = \Drupal::configFactory()->getEditable($config_name);
97+
$config->set('mimetypes', str_replace("\r", "", $config->get('mimetypes')));
98+
$config->save();
99+
}
100+
}

src/Form/FileTypeForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ protected function copyFormValuesToEntity(EntityInterface $entity, array $form,
131131
// Convert multi-line string to array before copying.
132132
// This may be called multiple times and exectued only if it is a string.
133133
if (is_string($form_state->getValue('mimetypes'))) {
134-
$form_state->setValue('mimetypes', explode("\n", $form_state->getValue('mimetypes')));
134+
$form_state->setValue('mimetypes', explode("\n", str_replace("\r", "", $form_state->getValue('mimetypes'))));
135135
}
136136
parent::copyFormValuesToEntity($entity, $form, $form_state);
137137
}

0 commit comments

Comments
 (0)