WordPress.org

Make WordPress Core

Opened 7 days ago

#54825 new defect (bug)

Heartbeat minimalInterval option causing incorrect value of mainInterval

Reported by: tabrisrp Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

Looking at the code of heartbeat.js, I think there is a bug in it when minimalInterval is used.

In the initialize function:

  • If options.minimalInterval is set, and is between 0 and 120, it's multiplicated by 1000 and assigned to settings.minimalInterval
  • After that, if settings.minimalInterval is superior to settings.mainInterval (which is likely always the case with the multiplication), the new value of settings.mainInterval is settings.minimalInterval
  • And then a bit further down, the value of settings.mainInterval is multiplied by 1000 to convert to microseconds. But it was already the case when using options.minimalInterval, so the value ends up being incorrect 120 000 000 microseconds instead of the expected 120 000 ms

As settings.minimalInterval is used against values in microseconds in other parts, a solution could be to do the following when assigning the value to mainInterval:

if ( settings.minimalInterval && settings.mainInterval < settings.minimalInterval ) {
	settings.mainInterval = settings.minimalInterval / 1000;
}

Change History (0)

Note: See TracTickets for help on using tickets.