Problem/Motivation

The following error is thrown when sending the emails with mailchimp transactional
Error: Call to undefined method Drupal\Core\ProxyClass\File\MimeType\MimeTypeGuesser::guess() in Drupal\mailchimp_transactional\Plugin\Mail\Mail->getAttachmentStruct() (line 280 of modules/contrib/mailchimp_transactional/src/Plugin/Mail/Mail.php) #0 modules/contrib/mailchimp_transactional/src/Plugin/Mail/Mail.php(162): Drupal\mailchimp_transactional\Plugin\Mail\Mail->getAttachmentStruct()

Steps to reproduce

Proposed resolution

Patch to replace guess() with guessMimeType().
Reference: https://www.drupal.org/node/3126004

Remaining tasks

User interface changes

API changes

Data model changes

Command icon 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:

Comments

ramprassad created an issue. See original summary.

ramprassad’s picture

Title: Error: Call to undefined method Drupal\Core\ProxyClass\File\MimeType\MimeTypeGuesser::guess() in Drupal\mailchimp_transactional\Plugi n\Mail\Mail->getAttachmentStruct() (line 280 of /mnt/www/html/mpageeucentrald8/docroot/modules/contrib/mailchimp_transact » Error: Call to undefined method Drupal\Core\ProxyClass\File\MimeType\MimeTypeGuesser::guess() in Drupal\mailchimp_transactional\Plugi n\Mail\Mail->getAttachmentStruct() (line 280 of modules/contrib/mailchimp_transact
ramprassad’s picture

Title: Error: Call to undefined method Drupal\Core\ProxyClass\File\MimeType\MimeTypeGuesser::guess() in Drupal\mailchimp_transactional\Plugi n\Mail\Mail->getAttachmentStruct() (line 280 of modules/contrib/mailchimp_transact » Error: Call to undefined method Drupal\Core\ProxyClass\File\MimeType\MimeTypeGuesser::guess() in Drupal\mailchimp_transactional\Plugi n\Mail\Mail->getAttachmentStruct() (line 280 of modules/contrib/mailchimp_transactional/src/Plugin/Mail/Mail.php
shreya_th’s picture

Assigned: Unassigned » shreya_th
ramprassad’s picture

Issue summary: View changes
StatusFileSize
new620 bytes
dieterholvoet’s picture

Status: Active » Needs work

The minimum supported core version is 9.0.0 and the guessMimeType method was added in 9.1.0, so we'll need to add a conditional:

$guesser = \Drupal::service('file.mime_type.guesser');
if ($guesser instanceof \Symfony\Component\Mime\MimeTypeGuesserInterface) {
  $mime_type = $guesser->guessMimeType($path);
}
else {
  $mime_type = $guesser->guess($path);
}

shreya_th’s picture

Assigned: shreya_th » Unassigned
Status: Needs work » Active
dieterholvoet’s picture

Status: Active » Needs work

My comment hasn't been addressed yet, so setting back to Needs work.

ramprassad’s picture

StatusFileSize
new1.14 KB

Adding the updated patch based on the recent DieterHolvoet's comment above and opened merge request. This can go the version 1.1.x as well.

Regards,
Ramprassad

ramprassad’s picture

Merge request #21 is the valid one.
Merge request #22 was mistakenly raised with the intent to merge to 1.1.x but the branch was not available.

dieterholvoet’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.