Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#50716 closed defect (bug) (fixed)

PHP Fatal error: Cannot declare class PHPMailer\PHPMailer\PHPMailer

Reported by: davidbinda's profile david.binda Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: Mail Keywords:
Focuses: Cc:


With PHPMailer living in a new directory, including the wp-includes/class-phpmailer.php from code may result in a fatal error, ie.: when running the phpunit.

The change in requires once the PHPMailer class directly, so the class gets declared. In case there is a plugin requiring the wp-includes/class-phpmailer.php (even when require_once is used), the file requires the file declaring the PHPMailer class again ( see ).

I believe that require_once in wp-includes/class-phpmailer.php should be used in order to prevent mentioned fatal errors.

Attachments (1)

50716.diff (594 bytes) - added by david.binda 4 years ago.

Download all attachments as: .zip

Change History (4)

4 years ago

#1 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 5.5

#2 @SergeyBiryukov
4 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 48530:

Mail: Make sure the PHPMailer class is only required once if a plugin requires wp-includes/class-phpmailer.php directly.

Follow-up to [48033].

Props david.binda.
Fixes #50716. See #41750.

#3 @SergeyBiryukov
3 years ago

In 50022:

Mail: Make sure the SMTP class is only required once if a plugin requires wp-includes/class-smtp.php directly.

Follow-up to [48033], [48530].

Props oellin, greatsaltlake, audrasjb.
Fixes #52369. See #50716, #41750.

Note: See TracTickets for help on using tickets.