WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 11 months ago

#42960 new enhancement

get_page_permastruct call causes 500 error.

Reported by: wcwilson1950 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Rewrite Rules Keywords: reporter-feedback close
Focuses: Cc:
PR Number:

Description

This was discussed in #7589. I can't seem to find the plugin that is causing this problem. Obviously somebody is making the call to get_page_permastruct before $wp_rewrite is being initialized; in my case it's on logout and trying to redirect to the logout page.

It would be a help to wrap the call to $wp_rewrite->get_page_permastruct() on line 356, with an if statement that tests for null $wp_rewrite. The rest of the code functions if that approach is taken.

if (!empty($wp_rewrite)) {

$link = $wp_rewrite->get_page_permastruct();

}

Attachments (1)

blebootcamp_error_logs-2017-12-21_20-26-04.txt (75.9 KB) - added by wcwilson1950 2 years ago.
Production error log with error.

Download all attachments as: .zip

Change History (3)

@wcwilson1950
2 years ago

Production error log with error.

#1 @dd32
2 years ago

  • Keywords reporter-feedback close added

Before we consider changing this, we'd need to know what/where is calling the function.

You may wish to add logging into the function on your site to detect it:

if ( empty($wp_rewrite) ) {
    trigger_error( __FUNCTION__ . " Called too early by " . wp_debug_backtrace_summary(), E_USER_ERROR );
}

However, In general, we wouldn't change this as in this case, a PHP fatal error is the correct result. Fix the plugin/theme/other code which is calling the function too early instead.
Unless the error is being generated by a use-case which is significantly common, we're not going to change it.

#2 @pento
11 months ago

  • Version trunk deleted
Note: See TracTickets for help on using tickets.