wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

RankMath generates an error when using the integration

Open DahmaniAdame opened this issue 2 years ago • 2 comments

Before submitting an issue please check that you’ve completed the following steps:

  • [x] Made sure you’re on the latest version 3.10.9
  • [x] Used the search feature to ensure that the bug hasn’t been reported before

Describe the bug When the RankMath integration is enabled on the Preload feature, \RankMath\Helper will occasionally fail to run and generate the following error on the logs:

Uncaught Error: Class 'RankMath\Helper' not found in /wp-content/plugins/wp-rocket/inc/3rd-party/plugins/seo/rank-math-seo.php:14
Stack trace:
#0 /wp-content/plugins/wp-rocket/inc/3rd-party/3rd-party.php(60): require()
#1 /wp-content/plugins/wp-rocket/inc/main.php(69): require('/www/htdocs/w01...')
#2 /wp-includes/class-wp-hook.php(307): rocket_init('')
#3 /wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
#4 /wp-includes/plugin.php(474): WP_Hook->do_action(Array)
#5 /wp-settings.php(450): do_action('plugins_loaded')
#6 /wp-config.php(120): require_once('/www/htdocs/w01...')
#7 /wp-load.php(50): require_once('/www/htdocs/w01...')
#8 /wp-login.php(12): require('/www/htdocs/w01...')

To Reproduce Steps to reproduce the behavior:

  1. Enable RankMath Sitemap + WP Rocket preload + integration with RankMath
  2. Run a couple of preloads and monitor the logs
  3. See error

Expected behavior We shouldn't get any error on the log even if the class \RankMath\Helper fails.

Screenshots N/A

Additional context Ticket - https://secure.helpscout.net/conversation/1816013983/331594

Since we can't control when the class will fail, we can simply check if the class exists and bail if it doesn't.

if (!class_exists('RankMath\Helper')) {
  return;
}

Acceptance Criteria

  1. Preload working without regression when RankMath Sitemap and WP Rocket + Integration is used
  2. Preload working without regression when RankMath Sitemap is disabled and alo when Rankmath is deactivated
  3. No errors being added to the log after a couple of preloads
  4. The solution should also resolve the following request: https://wp-media.slack.com/archives/C43T1AYMQ/p1713469443317209 (to be confirmed on the customer's website)

Backlog Grooming (for WP Media dev team use only)

  • [ ] Reproduce the problem
  • [ ] Identify the root cause
  • [ ] Scope a solution
  • [ ] Estimate the effort

DahmaniAdame avatar Mar 19 '22 11:03 DahmaniAdame

Related - https://secure.helpscout.net/conversation/1833892152/335095/ @piotrbak any reason why the status is blocked?

DahmaniAdame avatar Apr 03 '22 07:04 DahmaniAdame

@DahmaniAdame We're not touching things related to preload until the rewrite of the preload module. If the problem continues and grows, we might change the priorities though.

piotrbak avatar Apr 04 '22 09:04 piotrbak

Added Test by devs as Test Plan can be found on the fix PR comment. Thank you.

hanna-meda avatar Jun 12 '24 06:06 hanna-meda