WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 5 months ago

#52753 new defect (bug)

using_index_permalinks() on null

Reported by: arena Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.6
Component: Site Health Keywords: reporter-feedback
Focuses: Cc:

Description

On a plugin, on do_action('plugins_loaded'), this function is activated

<?php
public function plugins_loaded() {
if ( ! class_exists( 'WP_Site_Health' ) ) require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
self::$_tests = WP_Site_Health::get_tests();
}

this code was working in wp 5.5.3 but fails in wp 5.6

In 5.6 returns Call to a member function using_index_permalinks() on null in wp-includes/rest-api.php:403

this code was working in wp 5.5.3 but fails in 5.6
Regards

Change History (2)

#1 @peterwilsoncc
7 months ago

  • Component changed from General to Site Health
  • Severity changed from major to normal

#2 @Clorith
5 months ago

  • Keywords reporter-feedback added

Hiya,

This appears related to the change in asynchronous tests being moved to the REST API, and the calls to rest_url in the test generator function you are calling.

The rest_url function relies on the $wp_rewrite global class when pretty permalinks are enabled, which isn't available as early as the plugins_loaded action, but should instead be used with either the init or wp hook.

Note: See TracTickets for help on using tickets.