Make WordPress Core

Opened 5 weeks ago

Closed 24 hours ago

Last modified 22 hours ago

#61240 closed enhancement (fixed)

Add e2e test for maintenance mode and other edge cases

Reported by: swissspidy's profile swissspidy Owned by: swissspidy's profile swissspidy
Milestone: 6.6 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests
Focuses: Cc:


In I just reported a fatal error that is hard to discover in regular development, as it only happens in maintenance mode.

Maintenance mode also loads translations using wp_load_translations_early(), which is also tricky to test and had some bugs in the past too.

Similar situations exist in the fatal error handler class, or in wpdb when there is a connection issue.

It should be possible to write e2e tests for such scenarios, for example by placing a .maintenance file in the root or by temporarily changing the database credentials and things like that.

Change History (5)

This ticket was mentioned in PR #6624 on WordPress/wordpress-develop by @swissspidy.

4 weeks ago

  • Keywords has-patch has-unit-tests added; needs-patch removed


  • [x] A test for the fatal error handler
  • [x] A test for maintenance mode
  • [ ] Recovery mode flow
    • Requires sending an email or another way of getting the recovery mode link

Trac ticket:

@swissspidy commented on PR #6624:

9 days ago

The fatal error handler doesn't seem to be working with the local Docker environment. It works when using something like though, so not sure what's going on.

@desrosj This is a long shot, but perhaps you have an idea since you're familiar with the Docker env?

#3 @swissspidy
24 hours ago

  • Owner set to swissspidy
  • Resolution set to fixed
  • Status changed from assigned to closed

In 58430:

Build/Test Tools: add new end-to-end tests for edge cases such as maintenance mode.

Sometimes errors only occur in unusual code paths such as the maintenance mode or installation screens. Due to lack of tests for these scenarios in core, such errors are usually only noticed very late. This change adds new end-to-end (e2e) tests to prevent regressions in the following areas:

  • Maintenance mode (presence of a .maintenance file)
  • Fatal error handler (simulated with an mu-plugin that causes an error)
  • Installation screen (verifying full installation flow & that there are no database errors)

Thanks to these tests, an issue was already found and addressed in the default wp_die handler, as wp_robots_noindex_embeds and wp_robots_noindex_search used to cause PHP warnings due to $wp_query not existing.

In the future, these tests can be extended to also test scenarios like localized error pages via wp_load_translations_early().

Fixes #61240.

#5 @swissspidy
22 hours ago

In 58431:

Build/Test Tools: install additional languages in end-to-end tests.

As a follow-up to [58430], this makes another locale available during the e2e tests, allowing testing of scenarios that require loading translations in the future.

See #61240.

Note: See TracTickets for help on using tickets.