#54825 closed defect (bug) (fixed)
Heartbeat minimalInterval option causing incorrect value of mainInterval
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Autosave | Keywords: | has-patch needs-testing dev-reviewed |
Focuses: | javascript | 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 tosettings.minimalInterval
- After that, if
settings.minimalInterval
is superior tosettings.mainInterval
(which is likely always the case with the multiplication), the new value ofsettings.mainInterval
issettings.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 usingoptions.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; }
Attachments (1)
Change History (9)
This ticket was mentioned in PR #2361 on WordPress/wordpress-develop by Tabrisrp.
3 years ago
#2
- Keywords has-patch added
#5
@
3 years ago
- Keywords dev-feedback added
The PR provided by @tabrisrp looks good to me and fixes the underlined issue.
If think it could use a second pair of eyes, just to check the overall logic, then we can ship it.
#6
@
3 years ago
- Keywords dev-reviewed added; dev-feedback removed
54825.diff is @tabrisrp's pull request with the code moved a few lines to group the conversions to milliseconds together.
@audrasjb I agree, the logic looks good. I've marked dev reviewed as a result.
#7
@
3 years ago
- Owner set to peterwilsoncc
- Resolution set to fixed
- Status changed from new to closed
In 53226:
peterwilsoncc commented on PR #2361:
3 years ago
#8
Committed in https://core.trac.wordpress.org/changeset/53226 with some slight shuffling of the code.
Move the
minimalInterval
valu conversion to microseconds later to avoid setting an incorrect value ofmainInterval
whenmainInterval
is inferior tominimalInterval
Trac ticket: https://core.trac.wordpress.org/ticket/54825