Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High CPU usage related to 3.12 in dashboard only #5354

Closed
4 tasks
piotrbak opened this issue Aug 26, 2022 · 10 comments · Fixed by #5360
Closed
4 tasks

High CPU usage related to 3.12 in dashboard only #5354

piotrbak opened this issue Aug 26, 2022 · 10 comments · Fixed by #5360
Assignees
Labels
module: user interface priority: 🔥critical The plugin or the website are unusable, it affects a significant number of customers severity: critical Defect that prevents the testing/use of the software
Milestone

Comments

@piotrbak
Copy link
Contributor

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

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

Describe the bug
It looks we have kind of loop in dashboard caused by incompatibility with 3rd parties. Notices are displayed in a loop until the timeout/fatal error happens.

To Reproduce
We still don't know how to reproduce it. For now suspected conflicts are:

  • Ninja Forms
  • WPML
  • Extra Product Options for WooCommerce

Screenshots
image

Additional context
Add any other context about the problem here.

Backlog Grooming (for WP Media dev team use only)

  • Reproduce the problem
  • Identify the root cause
  • Scope a solution
  • Estimate the effort
@piotrbak piotrbak added priority: 🔥critical The plugin or the website are unusable, it affects a significant number of customers needs: grooming severity: critical Defect that prevents the testing/use of the software module: user interface labels Aug 26, 2022
@piotrbak piotrbak added this to the 3.12.0.4 milestone Aug 26, 2022
@alfonso100
Copy link
Contributor

@alfonso100
Copy link
Contributor

alfonso100 commented Aug 26, 2022

Another case, is related to Ninja Forms.
Disabling ninja forms, or WP Rocket fixes the issue
After enabling WP Rocket, there is a timeout followed by a 524 error from cloudflare

https://secure.helpscout.net/conversation/1988914598/363935?folderId=2683093

update: the proposed fix worked on this case

@alfonso100
Copy link
Contributor

This can be reproduced by installing WP Rocket 3.12.0.3 and Ninja Forms
https://wordpress.org/plugins/ninja-forms/

QO960oE

https://i.imgur.com/QO960oE.png

@alfonso100
Copy link
Contributor

Another one, related to Ninja Forms:
https://secure.helpscout.net/conversation/1990404557/364233?folderId=273761

@piotrbak
Copy link
Contributor Author

piotrbak commented Aug 26, 2022

Problem seems to be related to those specific lines, commenting them out fixes it:

'maybe_display_preload_notice',
'maybe_display_as_missed_tables_notice',

Solution proposed by @Tabrisrp is to change those lines to:

 [ 'maybe_display_preload_notice' ],
 [ 'maybe_display_as_missed_tables_notice' ],

It fixes the problem, we need further investigation why it happens only on a very small minority of users.

@DahmaniAdame
Copy link
Contributor

Related - https://secure.helpscout.net/conversation/1990404062/364232/
Fixed by updating

'maybe_display_preload_notice',
'maybe_display_as_missed_tables_notice',
as provided by the PHP.

@piotrbak piotrbak changed the title [WIP] High CPU usage related to 3.12 in dashboard only High CPU usage related to 3.12 in dashboard only Aug 27, 2022
@alfonso100
Copy link
Contributor

@engahmeds3ed
Copy link
Contributor

Starting from those two lines:

'admin_notices' => [
'maybe_display_preload_notice',
'maybe_display_as_missed_tables_notice',
],

So when we add the subscriber in the event manager class here:

$this->add_subscriber_callback( $subscriber, $hook_name, $parameters );

and will pass the following values

  ["subscriber"] => string(41) "WP_Rocket\Engine\Preload\Admin\Subscriber"

  ["hook_name"] => string(13) "admin_notices"

  ["parameters"] => array (
    0 => 'maybe_display_preload_notice',
    1 => 'maybe_display_as_missed_tables_notice',
  )

Then it'll get into the following condition

$this->add_callback( $hook_name, [ $subscriber, $parameters[0] ], isset( $parameters[1] ) ? $parameters[1] : 10, isset( $parameters[2] ) ? $parameters[2] : 1 );

and based on that, the values that will be passed to add_callback method are as follows:-

$hook_name => admin_notices

$callback => [subscriber, 'maybe_display_preload_notice']

$priority => 'maybe_display_as_missed_tables_notice'

$accepted_args => default value is 1

Notice that this priority has a string value and this should be number and this is the problem.

the problem is on this line from WP core

https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-hook.php#L85

So the question is why with some plugins we see this problem like ninjaforms?
the answer took me a lot of time to know as below:

I logged the admin_notices callbacks from WP core and I found as in the following screenshot

image

this callback has more than 25500 lines and this is extremely big number
the problem with ksort, it takes a lot of time when the keys are not numbers as in this case
if u want to make sure of what I mentioned, simply change this line to be any number

'maybe_display_as_missed_tables_notice',

Also as @Mai-Saad mentioned, the issue is happening only with PHP >= 8

I'm going to create a PR for this now.

@engahmeds3ed engahmeds3ed self-assigned this Aug 29, 2022
@alfonso100
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: user interface priority: 🔥critical The plugin or the website are unusable, it affects a significant number of customers severity: critical Defect that prevents the testing/use of the software
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants