Support

Home Forums Event Espresso Premium Missing permalinks after shutdown and wp_loaded actions

Missing permalinks after shutdown and wp_loaded actions

Posted: January 29, 2024 at 8:17 am


Noah Ottenstein

January 29, 2024 at 8:17 am

I’m having issues with a website running EE4 where the registration links periodically show a 404. I’ve followed the instructions from https://eventespresso.com/topic/event-slug-404-error-page/ to enable logging of permalink flush requests and have collected data from the past few months. It seems like flush_rewrite_rules() is being called during the “shutdown” and “wp_loaded” hooks and the registration/* permalinks are missing at those points. It is not clear from the stacktrace which plugin is responsible for running these actions.

Here is an example of the stack trace. The ‘rewrite_array’ is missing the “registration/” paths.

#0 /wp-site/wp-includes/class-wp-hook.php(324): fpas_log_rewrite_rules_array(Array)
#1 /wp-site/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array)
#2 /wp-site/wp-includes/class-wp-rewrite.php(1473): apply_filters('rewrite_rules_a...', Array)
#3 /wp-site/wp-includes/class-wp-rewrite.php(1509): WP_Rewrite->rewrite_rules()
#4 /wp-site/wp-includes/class-wp-rewrite.php(1884): WP_Rewrite->refresh_rewrite_rules()
#5 /wp-site/wp-includes/rewrite.php(282): WP_Rewrite->flush_rules(true)
#6 /wp-site/wp-includes/class-wp-hook.php(324): flush_rewrite_rules('')
#7 /wp-site/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#8 /wp-site/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#9 /wp-site/wp-includes/load.php(1260): do_action('shutdown')
#10 [internal function]: shutdown_action_hook()
#11 {main}

Is it possible to have event espresso add the permalinks on the shutdown action? Please let me know if you need any other info. Thanks!


Tony

  • Support Staff

January 29, 2024 at 9:39 am

Hi there,

If you make the same change mentioned here:

https://eventespresso.com/topic/event-slug-404-error-page/#post-318420

Only using ‘registration’ as the slug:

'EE-Check' => isset($rewrite_array['registration/?$']) ? 'true' : 'false'

It will show the correct value in the logs when EE’s rewrite rules are missing.

I’m fairly certain EE already runs on the shutdown hook but I’ll double check this with out developers.

Note, these are often difficult to track down, it’s not caused by EE specifically (otherwise everyone would run into it) but a combination of EE another some code/another plugin/theme… so this is going to take some troubleshooting to narrow down.


Noah Ottenstein

January 29, 2024 at 10:49 am

thank you. I’ve updated the logging with the correct code for the EE_check. Please let me know if EE runs on the shutdown hook.


Tony

  • Support Staff

January 31, 2024 at 5:31 am

Hi there,

So I checked into this and EE loads the CPT’s on the plugins_loaded action at priority 5.

We do try to limit the requests that EE loads on so it only loads when it is actually intended to be used and something there may be getting messed up.

You could try logging the request itself when the rewrite rules are missing and see if that adds any more details for this. The EE_check is now correct, right?

If so, you can add something like this:

if( isset($rewrite_array['registration/?$']) ){
    return $rewrite_array;
}

(If the E rewrite rule is set, return the rewrite rules as we don’t need to log them)

Add that right above $e = new \Exception;

Then… in the call to ee_write_log, add this:

'request' => $_REQUEST,

Manually flush your permalinks in Dashboard -> Settings -> Permalinks to double check no fatals are thrown and then wait for this to happen again and check the log file, an details on the specific request there?


Noah Ottenstein

January 31, 2024 at 8:19 am

I updated the EE_check yesterday to it accurately reflected whether registration/?$ was in the rewrite array. It did not catch any issues yet.
I’ve updated the rewrite_rules_array hook to log only when registration is missing and to log the request. Flushing the permalinks works without errors so I will post back here when I log the problem again.
Thanks!


Tony

  • Support Staff

January 31, 2024 at 9:02 am

You’re most welcome, these can often be a little difficult to track down so just need to keep chipping away.

The support post ‘Missing permalinks after shutdown and wp_loaded actions’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso