From 059cab0e715fa2d55aa1c7341f46dd98efa8fc31 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Wed, 20 Apr 2022 05:53:25 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@53226 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/wp/heartbeat.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/js/_enqueues/wp/heartbeat.js b/src/js/_enqueues/wp/heartbeat.js index 4f71c1cab4..c6950ef7df 100644 --- a/src/js/_enqueues/wp/heartbeat.js +++ b/src/js/_enqueues/wp/heartbeat.js @@ -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.