WordPress.org

Make WordPress Core

Opened 6 weeks ago

Closed 6 weeks ago

#54612 closed defect (bug) (fixed)

Disable WP_CRON when installing PHPUnit tests

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

Description

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

Download all attachments as: .zip

Change History (4)

@Chouby
6 weeks ago

#1 @sabernhardt
6 weeks ago

  • Component changed from General to Build/Test Tools

#2 @SergeyBiryukov
6 weeks ago

  • Milestone changed from Awaiting Review to 5.9

#3 @SergeyBiryukov
6 weeks 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.