From b40fd7680958b75ee8b8a9241c34374709ae8a40 Mon Sep 17 00:00:00 2001 From: Jonathan Hunt Date: Tue, 14 Dec 2021 20:35:07 +1300 Subject: [PATCH] Update File Entity to 7.x-2.33 --- .../contrib/file_entity/file_entity.info | 6 ++--- .../contrib/file_entity/file_entity.pages.inc | 26 +++++++++++++++---- .../contrib/file_entity/file_entity.test | 26 +++++++++---------- .../file_entity/file_entity.tokens.inc | 4 +-- .../file_entity/file_entity_views.test | 2 +- .../file_entity/tests/file_entity_test.info | 6 ++--- 6 files changed, 43 insertions(+), 27 deletions(-) diff --git a/docroot/sites/all/modules/contrib/file_entity/file_entity.info b/docroot/sites/all/modules/contrib/file_entity/file_entity.info index c0f68116..3d094a64 100644 --- a/docroot/sites/all/modules/contrib/file_entity/file_entity.info +++ b/docroot/sites/all/modules/contrib/file_entity/file_entity.info @@ -32,8 +32,8 @@ configure = admin/config/media/file-settings ; We have to add a fake version so Git checkouts do not fail Media dependencies version = 7.x-2.x-dev -; Information added by Drupal.org packaging script on 2020-06-15 -version = "7.x-2.30" +; Information added by Drupal.org packaging script on 2021-11-10 +version = "7.x-2.33" core = "7.x" project = "file_entity" -datestamp = "1592259102" +datestamp = "1636506143" diff --git a/docroot/sites/all/modules/contrib/file_entity/file_entity.pages.inc b/docroot/sites/all/modules/contrib/file_entity/file_entity.pages.inc index 640aa1d3..c2b19539 100644 --- a/docroot/sites/all/modules/contrib/file_entity/file_entity.pages.inc +++ b/docroot/sites/all/modules/contrib/file_entity/file_entity.pages.inc @@ -36,9 +36,22 @@ function file_entity_download_page($file) { return MENU_NOT_FOUND; } // @todo Why basename? Why not drupal_basename which was working up until recently. + $content_type = ''; + if (isset($file->filemime)) { + $content_type = mime_header_encode($file->filemime); + // Strip new lines for php 8.0 compatibility with headers. + $content_type = str_replace(array("\n\r", "\n", "\r"), '', $content_type); + } + $disposition = ''; + if (isset($file->uri)) { + $disposition = mime_header_encode(basename($file->uri)); + // Strip new lines for php 8.0 compatibility with headers. + $disposition = str_replace(array("\n\r", "\n", "\r"), '', $disposition); + } + $headers = array( - 'Content-Type' => mime_header_encode($file->filemime), - 'Content-Disposition' => 'attachment; filename="' . mime_header_encode(basename($file->uri)) . '"', + 'Content-Type' => $content_type, + 'Content-Disposition' => 'attachment; filename="' . $disposition . '"', 'Content-Length' => $file->filesize, 'Content-Transfer-Encoding' => 'binary', 'Pragma' => 'no-cache', @@ -1260,9 +1273,12 @@ function file_entity_get_upload_validators(array $options = array()) { $validators['file_validate_extensions'] = array(variable_get('file_entity_default_allowed_extensions', 'jpg jpeg gif png txt doc docx xls xlsx pdf ppt pptx pps ppsx odt ods odp mp3 mov mp4 m4a m4v mpeg avi ogg oga ogv weba webp webm')); } - // Cap the upload size according to the system or user defined limit. - $max_filesize = parse_size(file_upload_max_size()); - $file_entity_max_filesize = parse_size(variable_get('file_entity_max_filesize', '')); + // Cap the upload size according to the system or user defined limit. Note: In + // PHP 8 file_upload_max_size() returns a string instead of an integer, so + // cast it to an integer to avoid a critical error; do the same for the + // variable, just in case. + $max_filesize = parse_size(intval(file_upload_max_size())); + $file_entity_max_filesize = parse_size(intval(variable_get('file_entity_max_filesize', ''))); // If the user defined a size limit, use the smaller of the two. if (!empty($file_entity_max_filesize)) { diff --git a/docroot/sites/all/modules/contrib/file_entity/file_entity.test b/docroot/sites/all/modules/contrib/file_entity/file_entity.test index e6a0005c..baafe13c 100644 --- a/docroot/sites/all/modules/contrib/file_entity/file_entity.test +++ b/docroot/sites/all/modules/contrib/file_entity/file_entity.test @@ -136,7 +136,7 @@ class FileEntityFileTypeClassificationTestCase extends DrupalWebTestCase { return array( 'name' => 'File entity classification', 'description' => 'Test existing file entity classification functionality.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } @@ -206,7 +206,7 @@ class FileEntityUnitTestCase extends FileEntityTestHelper { return array( 'name' => 'File entity unit tests', 'description' => 'Test basic file entity functionality.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } @@ -311,7 +311,7 @@ class FileEntityEditTestCase extends FileEntityTestHelper { return array( 'name' => 'File entity edit', 'description' => 'Create a file and test file edit functionality.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } @@ -421,7 +421,7 @@ class FileEntityUploadWizardTestCase extends FileEntityTestHelper { return array( 'name' => 'File entity upload wizard', 'description' => 'Upload a file using the multi-step wizard.', - 'group' => 'File entity', + 'group' => 'file_entity', 'dependencies' => array('token'), ); } @@ -646,7 +646,7 @@ class FileEntityAdminTestCase extends FileEntityTestHelper { return array( 'name' => 'File administration', 'description' => 'Test file administration page functionality.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } @@ -809,7 +809,7 @@ class FileEntityUsageTestCase extends FileEntityTestHelper { return array( 'name' => 'File entity usage', 'description' => 'Create a file and verify its usage.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } @@ -896,7 +896,7 @@ class FileEntityAltTitleTestCase extends FileEntityTestHelper { return array( 'name' => 'File entity alt and title text', 'description' => 'Create an image file with alt and title text.', - 'group' => 'File entity', + 'group' => 'file_entity', 'dependencies' => array('token'), ); } @@ -987,7 +987,7 @@ class FileEntityChangeSchemeTestCase extends FileEntityTestHelper { return array( 'name' => 'Changing file scheme', 'description' => 'Test changing the scheme of a file.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } @@ -1025,7 +1025,7 @@ class FileEntityReplaceTestCase extends FileEntityTestHelper { return array( 'name' => 'File replacement', 'description' => 'Test file replace functionality.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } @@ -1109,7 +1109,7 @@ class FileEntityTokenTestCase extends FileEntityTestHelper { return array( 'name' => 'File entity tokens', 'description' => 'Test the file entity tokens.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } @@ -1167,7 +1167,7 @@ class FileEntityTypeTestCase extends FileEntityTestHelper { return array( 'name' => 'File entity types', 'description' => 'Test the file entity types.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } @@ -1296,7 +1296,7 @@ class FileEntityAccessTestCase extends FileEntityTestHelper { return array( 'name' => 'File entity access', 'description' => 'Test the access aspects of file entity.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } @@ -1639,7 +1639,7 @@ class FileEntityAttributeOverrideTestCase extends FileEntityTestHelper { return array( 'name' => 'File entity attribute override', 'description' => 'Test overriding file entity attributes.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } diff --git a/docroot/sites/all/modules/contrib/file_entity/file_entity.tokens.inc b/docroot/sites/all/modules/contrib/file_entity/file_entity.tokens.inc index e1ae9125..1567bef8 100644 --- a/docroot/sites/all/modules/contrib/file_entity/file_entity.tokens.inc +++ b/docroot/sites/all/modules/contrib/file_entity/file_entity.tokens.inc @@ -114,8 +114,8 @@ function file_entity_token_info() { $entity_type = 'term'; } $info['tokens'][$entity_type][$field_name] = array( - 'name' => $field_info['label'], - 'description' => $field_info['description'], + 'name' => ($field_info) ? $field_info['label'] : '', + 'description' => ($field_info) ? $field_info['description'] : '', 'type' => 'file_field', 'module' => 'file_entity', ); diff --git a/docroot/sites/all/modules/contrib/file_entity/file_entity_views.test b/docroot/sites/all/modules/contrib/file_entity/file_entity_views.test index 5e0bac55..b1a1b916 100644 --- a/docroot/sites/all/modules/contrib/file_entity/file_entity_views.test +++ b/docroot/sites/all/modules/contrib/file_entity/file_entity_views.test @@ -24,7 +24,7 @@ class FileEntityViewsFieldLinkUsageHandlerTest extends FileEntityTestHelper { return array( 'name' => 'File entity views integration: file link usage', 'description' => 'Test file usage Views field.', - 'group' => 'File entity', + 'group' => 'file_entity', ); } diff --git a/docroot/sites/all/modules/contrib/file_entity/tests/file_entity_test.info b/docroot/sites/all/modules/contrib/file_entity/tests/file_entity_test.info index 816d1648..c3f91c16 100644 --- a/docroot/sites/all/modules/contrib/file_entity/tests/file_entity_test.info +++ b/docroot/sites/all/modules/contrib/file_entity/tests/file_entity_test.info @@ -5,8 +5,8 @@ core = 7.x dependencies[] = file_entity hidden = TRUE -; Information added by Drupal.org packaging script on 2020-06-15 -version = "7.x-2.30" +; Information added by Drupal.org packaging script on 2021-11-10 +version = "7.x-2.33" core = "7.x" project = "file_entity" -datestamp = "1592259102" +datestamp = "1636506143"