-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
HPC-9989: Apply a core patch from #3487488 that fixes an issue with mime type detection, update mime types of affected files
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains deploy functions for the GHI image module. | ||
*/ | ||
|
||
/** | ||
* Fix some mime types after applying core patch from #3487488. | ||
*/ | ||
function ghi_image_deploy_fix_mime_types(&$sandbox) { | ||
/** @var \Drupal\file\FileInterface[] $files */ | ||
$files = \Drupal::entityTypeManager()->getStorage('file')->loadByProperties([ | ||
'filemime' => 'application/octet-stream', | ||
]); | ||
/** @var \Drupal\Core\File\MimeType\MimeTypeGuesser $mime_type_guesser */ | ||
$mime_type_guesser = \Drupal::service('file.mime_type.guesser'); | ||
foreach ($files as $file) { | ||
$mime_type = $mime_type_guesser->guessMimeType($file->getFileUri()); | ||
if ($file->getMimeType() != $mime_type) { | ||
$file->setMimeType($mime_type); | ||
$file->save(); | ||
} | ||
} | ||
} |