Skip to content

Commit

Permalink
Merge pull request #1272 from UN-OCHA/berliner/HPC-9989
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
berliner authored Dec 22, 2024
2 parents 8f8a81a + 9a0b5f2 commit 139daee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"Issue #3001188: Make it possible to add relationships to layout builder": "./patches/3001188-make-it-possible-to-add-relationships-to-layout-builder.patch",
"Issue #2329253: Allow the ChangedItem to skip updating the entity's changed timestamp when synchronizing (f.e. when migrating)": "https://www.drupal.org/files/issues/2024-07-30/2329253-10.x.patch",
"Issue #3467860: Ensure consistent library ordering between page an asset requests when calculating asset aggregates": "./patches/3467860.mr-9219.patch",
"Issue #3487488: ExtensionMimeTypeGuesser::guessMimeType must support file names with '0' (zero) in the extension parts like foo.0.zip": "https://git.drupalcode.org/project/drupal/-/commit/0475ceccefc.patch",
"Issue #?? (maybe #2837833): 'Required contexts without a value": "./patches/missing-context-value-in-layout-builder-admin.patch"
},
"drupal/flat_taxonomy": {
Expand Down
25 changes: 25 additions & 0 deletions html/modules/custom/ghi_image/ghi_image.deploy.php
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();
}
}
}

0 comments on commit 139daee

Please sign in to comment.