Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#50380 closed defect (bug) (fixed)

Check if _deprecated_file function exists in class-phpmailer.php

Reported by: timothyblynjacobs's profile TimothyBlynJacobs Owned by: timothyblynjacobs's profile TimothyBlynJacobs
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.5
Component: Mail Keywords: has-patch has-dev-note
Focuses: Cc:


The class-phpmailer.php library is loaded early in the tests bootstrap, before wp-settings.php is loaded. This means that the _deprecated_file function is not available at this point. Core's test bootstrap was updated at the same time to point to the new file location which means it hasn't run into this issue. However, any other bootstraps, like wp-phpunit ( which is used by Gutenberg ) likely have not been updated.

This causes errors like:

Fatal error: Uncaught Error: Call to undefined function _deprecated_file() in /var/www/html/wp-includes/class-phpmailer.php:6

We could provide compatibility for those alternate test runners by first checking if the _deprecated_file function exists before calling it.

Attachments (1)

50380.diff (966 bytes) - added by TimothyBlynJacobs 4 years ago.

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 5.5

#2 @TimothyBlynJacobs
4 years ago

To note, I haven't been able to actually test that fixes the Gutenberg issue since everything is brought in dynamically, testing it is difficult. But I think it should.

#3 @SergeyBiryukov
4 years ago

  • Keywords has-patch commit added; 2nd-opinion removed

Makes sense to me, let's try and see if that fixes the Gutenberg build.

This ticket was mentioned in Slack in #core-editor by timothybjacobs. View the logs.

4 years ago

#5 @TimothyBlynJacobs
4 years ago

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

In 48034:

External Libraries: Skip deprecated file warning for PHPMailer if the API is not loaded.

In [48033] the "class-phpmailer.php" file was deprecated. In test suites, this file is loaded before WordPress in order to setup a mock PHPMailer instance. This means that for test suites that are still loading that file, they'll experience fatal errors due to the undefined "_deprecated_file" function.

This commit skips issuing the deprecated file warning if the "_deprecated_file" function is not available.

Fixes #50380.

#6 @desrosj
4 years ago

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