[wp-trac] [WordPress Trac] #50716: PHP Fatal error: Cannot declare class PHPMailer\PHPMailer\PHPMailer

WordPress Trac noreply at wordpress.org
Tue Jul 21 09:36:30 UTC 2020


#50716: PHP Fatal error:  Cannot declare class PHPMailer\PHPMailer\PHPMailer
--------------------------+-----------------------------
 Reporter:  david.binda   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Mail          |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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 https://core.trac.wordpress.org/changeset/48033/#file7
 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 `require`s the file declaring
 the PHPMailer class again ( see
 https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-
 phpmailer.php?rev=48035#L15 ).

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

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50716>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list