Autosave: Compare heartbeat intervals in same unit.

Move the conversion of `minimalInterval` to milliseconds to be grouped with the other time conversions from seconds to milliseconds.

This fixes a bug in which the minimal and main intervals were compared after the former had been converted to milliseconds but the latter had not. This could cause the heatbeat interval to blow out to unexpectedly high values if the minimal interval was set.

Props tabrisrp, sabernhardt, SergeyBiryukov, audrasjb.
Fixes #54825.


Built from https://develop.svn.wordpress.org/trunk@53226


git-svn-id: http://core.svn.wordpress.org/trunk@52815 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2022-04-20 05:55:06 +00:00
parent 40942c2695
commit 1b5dd9b426
3 changed files with 6 additions and 3 deletions

View File

@ -155,7 +155,7 @@
*/
if ( options.minimalInterval ) {
options.minimalInterval = parseInt( options.minimalInterval, 10 );
settings.minimalInterval = options.minimalInterval > 0 && options.minimalInterval <= 600 ? options.minimalInterval * 1000 : 0;
settings.minimalInterval = options.minimalInterval > 0 && options.minimalInterval <= 600 ? options.minimalInterval : 0;
}
if ( settings.minimalInterval && settings.mainInterval < settings.minimalInterval ) {
@ -176,6 +176,9 @@
// Convert to milliseconds.
settings.mainInterval = settings.mainInterval * 1000;
settings.originalInterval = settings.mainInterval;
if ( settings.minimalInterval ) {
settings.minimalInterval = settings.minimalInterval * 1000;
}
/*
* Switch the interval to 120 seconds by using the Page Visibility API.

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-beta2-53225';
$wp_version = '6.0-beta2-53226';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.