Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#54612 closed defect (bug) (fixed)

Disable WP_CRON when installing PHPUnit tests

Reported by: chouby's profile Chouby Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.9 Priority: normal
Severity: normal Version: 3.7
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:


While running PHPunit tests for one of my plugins with PHP 8.1, I noticed deprecation notices in the Requests library during the WordPress installation process. These notices reveal in fact that an http request is always fired by a cron task during the WordPress installation.

In bootstrap.php, we can find these lines:

 * Cron tries to make an HTTP request to the site, which always fails,
 * because tests are run in CLI mode only.
define( 'DISABLE_WP_CRON', true );

However the constant is not passed to the install.php script.
I propose to add this constant in this script too.

Attachments (1)

54612.patch (448 bytes) - added by Chouby 2 years ago.

Download all attachments as: .zip

Change History (4)

2 years ago

#1 @sabernhardt
2 years ago

  • Component changed from General to Build/Test Tools

#2 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 5.9

#3 @SergeyBiryukov
2 years ago

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

In 52359:

Build/Test Tools: Disable WP Cron when installing PHPUnit tests.

During the WordPress installation process when running the test suite, an HTTP request was always fired by a cron task and failed, because tests are run in CLI mode only.

To avoid that, the DISABLE_WP_CRON constant was previously added to the bootstrap.php file. However, the constant is not passed to the install.php script. This commit makes a similar change to install.php.

Follow-up to [760/tests], [872/tests].

Props Chouby.
Fixes #54612.

Note: See TracTickets for help on using tickets.