Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#50379 closed defect (bug) (fixed)

PHPMailer update introduces minor backcompat issue with phpmailerException and SMTP

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

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';

and

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 6 years ago.

Download all attachments as: .zip

Change History (8)

#1 @Otto42
6 years ago

  • Description modified (diff)

#2 @SergeyBiryukov
6 years ago

  • Milestone Awaiting Review → 5.5

#3 @SergeyBiryukov
6 years ago

  • Keywords has-patch added

#4 @SergeyBiryukov
6 years ago

  • Owner set to SergeyBiryukov
  • Status new → accepted

#5 @SergeyBiryukov
6 years ago

  • Resolution → fixed
  • Status accepted → 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
6 years ago

  • Keywords needs-dev-note added

#7 @desrosj
6 years ago

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