Make WordPress Core

Opened 4 years ago

Closed 2 years ago

Last modified 17 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
4 years ago

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

#2 @Clorith
4 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
2 years 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
17 months ago

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

Version 0, edited 17 months ago by pfefferle (next)
Note: See TracTickets for help on using tickets.