Make WordPress Core

Opened 17 months ago

Closed 17 months ago

Last modified 16 months ago

#50379 closed defect (bug) (fixed)

PHPMailer update introduces minor backcompat issue with phpmailerException and SMTP

Reported by: Otto42 Owned by: SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: External Libraries Keywords: has-patch has-dev-note
Focuses: Cc:

Description (last modified by Otto42)

[48033] for #41750 replaces the old PHPMailer with the newer version.

In place of the old version, the class-phpmailer.php and class-smtp.php files are deprecated and load the new code, along with adding a class alias.

However, the old class-phpmailer.php file defined both the PHPMailer class, and the phpmailerException class. This means the new one should too.

Recommend adding this to class-phpmailer.php:

require __DIR__ . '/PHPMailer/Exception.php';


class_alias( PHPMailer\PHPMailer\Exception::class, 'phpmailerException' );

Similarly, the class-smtp.php is now loading the new file, but it is missing the class alias to account for the namespace. So it should probably have this in it:

class_alias( PHPMailer\PHPMailer\SMTP::class, 'SMTP' );

These aliases would only be needed if these files were loaded, any plugin that relies on them should update to the more direct file includes, and account for the namespaces themselves at that time. The aliases are therefore only for backwards compatibility.

Attachments (1)

50379.diff (1.4 KB) - added by SergeyBiryukov 17 months ago.

Download all attachments as: .zip

Change History (8)

#1 @Otto42
17 months ago

  • Description modified (diff)

#2 @SergeyBiryukov
17 months ago

  • Milestone changed from Awaiting Review to 5.5

#3 @SergeyBiryukov
17 months ago

  • Keywords has-patch added

#4 @SergeyBiryukov
17 months ago

  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

#5 @SergeyBiryukov
17 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 48035:

External Libraries: Add class aliases for phpmailerException and SMTP to deprecated files to account for the new namespace.

This ensures backward compatibility with plugins using the old class-phpmailer.php or class-smtp.php files.

Follow-up to [48033].

Props Otto42.
Fixes #50379. See #41750.

#6 @desrosj
16 months ago

  • Keywords needs-dev-note added

#7 @desrosj
16 months ago

  • Keywords has-dev-note added; needs-dev-note removed
Note: See TracTickets for help on using tickets.