Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#41903 closed defect (bug) (invalid)

Unable to deactivate Heartbeat API

Reported by: markbowenpiano's profile markbowenpiano Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8.1
Component: Editor Keywords:
Focuses: administration, performance Cc:

Description

Hi,

In a vanilla install of WordPress 4.8.1 I am unable to disable the Heartbeat API using the following code placed into the 2017 themes functions.php file :

add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}

I also found this code online and tried it too :

add_action( 'init', function () {
	wp_deregister_script('heartbeat');
}, 1 );

Neither of which turn off the Heartbeat API as far as I can tell. I am very very new to WordPress so might be wrong on this but if the Heartbeat API is what is responsible for letting a user know that another user is editing a post then it is indeed NOT being turned off with either of the code snippets above as I am still getting those messages in the admin panel.

The reason I am trying to turn it off (even on a vanilla install) is that I have a live site on a SiteGround server which is having the admin-ajax.php file hit a massive amount of times and if it weren't for the caching on the site then we would be using over 3 times the amount of CPU seconds in a day so I need to find a way to turn it off as we don't need to be told when someone is already editing a post.

Not sure exactly what else the Heartbeat API is used for though?

I'm wondering if the examples online are therefore incorrect or whether indeed the Heartbeat API just can't be turned off easily?

Thanks,

Mark

Change History (5)

#1 @markbowenpiano
6 years ago

  • Severity changed from normal to major

#2 @JPry
6 years ago

  • Keywords close added
  • Resolution set to invalid
  • Severity changed from major to normal
  • Status changed from new to closed

Hi @markbowenpiano,

Welcome to Trac! The purpose of Trac is the development of the core WordPress codebase. To get support with the issue you've described, you should use the Support Forums. You'll be able to get assistance with your issue from volunteers there, as well as the answers to the questions you've asked.

#3 follow-up: @markbowenpiano
6 years ago

Hi &JPry,

Sorry for that. I had thought (obviously wrongly) that this was for WordPress bugs. Very new to WordPress so may have misread that when posting the ticket.

Is there a place for bugs to be reported then as this is definitely not working (well I mean unable to be disabled) on a vanilla install and I've tested on 4 completely different hosts now.

I had actually posted in the support forums but got nothing back there and to be honest I never do so not sure if I'm doing something wrong with the way I'm asking the questions.

If I could possibly quickly ask if it is even possible to turn off the Heartbeat and if it is then I can ask elsewhere or even hire a developer to see why it won't turn off.

Many thanks.

Mark

#4 in reply to: ↑ 3 @JPry
6 years ago

Replying to markbowenpiano:

Sorry for that. I had thought (obviously wrongly) that this was for WordPress bugs. Very new to WordPress so may have misread that when posting the ticket.

This is indeed for WordPress bugs, but in this particular case the bug is with either your site or your code rather than with WordPress itself. Using the steps that you described, I was able to deregister the Heartbeat API.

If I could possibly quickly ask if it is even possible to turn off the Heartbeat and if it is then I can ask elsewhere or even hire a developer to see why it won't turn off.

It is possible to turn off the Heartbeat API, but it is there for a reason. Determining whether a post is already being edited is one of its uses but it is not the only use.

Your code appears to be correct, so I can't say why it's not being disabled. It may be a good idea to look for a plugin that can help you control the Heartbeat API with more detail.

#5 in reply to: ↑ description @SergeyBiryukov
6 years ago

  • Component changed from General to Editor
  • Keywords close removed
  • Milestone Awaiting Review deleted

Replying to markbowenpiano:

I am very very new to WordPress so might be wrong on this but if the Heartbeat API is what is responsible for letting a user know that another user is editing a post then it is indeed NOT being turned off with either of the code snippets above as I am still getting those messages in the admin panel.

Disabling Heartbeat API does not remove "This content is currently locked" dialogs.

Not sure exactly what else the Heartbeat API is used for though?

It makes various autosave tasks and authentication checks run more smoothly.

Note: See TracTickets for help on using tickets.