[wp-trac] [WordPress Trac] #28618: Allow PHPMailer class to be reliably overriden

WordPress Trac noreply at wordpress.org
Mon Jun 23 21:46:30 UTC 2014


#28618: Allow PHPMailer class to be reliably overriden
-------------------------+-----------------------------
 Reporter:  leewillis77  |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Mail         |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 The WordPress unit test suite currently overrides the global $phpmailer
 variable with its own MockMailer class. (See
 https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/bootstrap.php#L48)

 This achieves the desired effect, but is potentially unreliable.

 If the global $phpmailer object gets unset, or overridden (For example by
 a buggy, or otherwise badly behaving plugin), then the code in wp-
 includes/pluggable.php will create a new instance of PHPMailer without any
 way for code to override that - see
 https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/pluggable.php#L264

 The end result would be that a site that shouldn't be sending emails will
 potentially become one that will.

 Potential patch attached. This includes the change to pluggable.php to
 filter the object after creation, and addition to the test suite to use
 it.

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


More information about the wp-trac mailing list