Make WordPress Core

Opened 3 years ago

Closed 21 months ago

Last modified 10 months ago

#52753 closed defect (bug) (invalid)

using_index_permalinks() on null

Reported by: arena's profile arena Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.6
Component: Site Health Keywords:
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 (4)

#1 @peterwilsoncc
3 years ago

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

#2 @Clorith
3 years 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.

#3 @Clorith
21 months ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Since we've not head anything here in a while, I'm closing the ticket as invalid based on my previous comment about load-timing, but the ticket can still be responded to, and information still be provided if there are other scenarios that should be considered, or there is something we might have missed here.

#4 @pfefferle
10 months ago

We just recently ran into the same issue with the ActivityPub plugin: https://github.com/Automattic/wordpress-activitypub/issues/375

But as @Clorith said, it is a problem from the load order, changing from plugins_loaded to init solves the issue.

Last edited 10 months ago by pfefferle (previous) (diff)
Note: See TracTickets for help on using tickets.