Administration: Remove `wp-auth-check` from the Heartbeat API.

As of [27153], wp-auth-check is returned on all heartbeats without the need for data from client-side. This also means that the timing and scheduling of this request data is ineffectual.

Fixes #50305.

Props dsixinetu, azaozz, whyisjake.


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


git-svn-id: http://core.svn.wordpress.org/trunk@47823 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
whyisjake 2020-06-16 07:09:09 +00:00
parent 8a6cc1a810
commit bdb1fe0d7e
4 changed files with 3 additions and 43 deletions

View File

@ -6,7 +6,7 @@
/* global adminpage */
(function($){
var wrap, next;
var wrap;
/**
* Shows the authentication form popup.
@ -110,18 +110,6 @@
});
}
/**
* Schedules when the next time the authentication check will be done.
*
* @since 3.6.0
* @private
*/
function schedule() {
// In seconds, default 3 min.
var interval = parseInt( window.authcheckL10n.interval, 10 ) || 180;
next = ( new Date() ).getTime() + ( interval * 1000 );
}
/**
* Binds to the Heartbeat Tick event.
*
@ -138,31 +126,13 @@
*/
$( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
if ( 'wp-auth-check' in data ) {
schedule();
if ( ! data['wp-auth-check'] && wrap.hasClass('hidden') ) {
show();
} else if ( data['wp-auth-check'] && ! wrap.hasClass('hidden') ) {
hide();
}
}
/**
* Binds to the Heartbeat Send event.
*
* @ignore
*
* @since 3.6.0
*
* @param {Object} e The heartbeat-send event that has been triggered.
* @param {Object} data Response data.
*/
}).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
if ( ( new Date() ).getTime() > next ) {
data['wp-auth-check'] = true;
}
}).ready( function() {
schedule();
/**
* Hides the authentication form popup when the close icon is clicked.

View File

@ -1,2 +1,2 @@
/*! This file is auto-generated */
!function(h){var d,t;function i(){h(window).off("beforeunload.wp-auth-check"),"undefined"==typeof adminpage||"post-php"!==adminpage&&"post-new-php"!==adminpage||"undefined"==typeof wp||!wp.heartbeat||(h(document).off("heartbeat-tick.wp-auth-check"),wp.heartbeat.connectNow()),d.fadeOut(200,function(){d.addClass("hidden").css("display",""),h("#wp-auth-check-frame").remove(),h("body").removeClass("modal-open")})}function n(){var e=parseInt(window.authcheckL10n.interval,10)||180;t=(new Date).getTime()+1e3*e}h(document).on("heartbeat-tick.wp-auth-check",function(e,a){"wp-auth-check"in a&&(n(),!a["wp-auth-check"]&&d.hasClass("hidden")?function(){var e,t=h("#wp-auth-check"),n=h("#wp-auth-check-form"),c=d.find(".wp-auth-fallback-expired"),o=!1;n.length&&(h(window).on("beforeunload.wp-auth-check",function(e){e.originalEvent.returnValue=window.authcheckL10n.beforeunload}),(e=h('<iframe id="wp-auth-check-frame" frameborder="0">').attr("title",c.text())).on("load",function(){var e,a;o=!0,n.removeClass("loading");try{e=(a=h(this).contents().find("body")).height()}catch(e){return d.addClass("fallback"),t.css("max-height",""),n.remove(),void c.focus()}e?a&&a.hasClass("interim-login-success")?i():t.css("max-height",e+40+"px"):a&&a.length||(d.addClass("fallback"),t.css("max-height",""),n.remove(),c.focus())}).attr("src",n.data("src")),n.append(e)),h("body").addClass("modal-open"),d.removeClass("hidden"),e?(e.focus(),setTimeout(function(){o||(d.addClass("fallback"),n.remove(),c.focus())},1e4)):c.focus()}():a["wp-auth-check"]&&!d.hasClass("hidden")&&i())}).on("heartbeat-send.wp-auth-check",function(e,a){(new Date).getTime()>t&&(a["wp-auth-check"]=!0)}).ready(function(){n(),(d=h("#wp-auth-check-wrap")).find(".wp-auth-check-close").on("click",function(){i()})})}(jQuery);
!function(h){var d;function s(){h(window).off("beforeunload.wp-auth-check"),"undefined"==typeof adminpage||"post-php"!==adminpage&&"post-new-php"!==adminpage||"undefined"==typeof wp||!wp.heartbeat||(h(document).off("heartbeat-tick.wp-auth-check"),wp.heartbeat.connectNow()),d.fadeOut(200,function(){d.addClass("hidden").css("display",""),h("#wp-auth-check-frame").remove(),h("body").removeClass("modal-open")})}h(document).on("heartbeat-tick.wp-auth-check",function(e,a){"wp-auth-check"in a&&(!a["wp-auth-check"]&&d.hasClass("hidden")?function(){var e,t=h("#wp-auth-check"),c=h("#wp-auth-check-form"),n=d.find(".wp-auth-fallback-expired"),o=!1;c.length&&(h(window).on("beforeunload.wp-auth-check",function(e){e.originalEvent.returnValue=window.authcheckL10n.beforeunload}),(e=h('<iframe id="wp-auth-check-frame" frameborder="0">').attr("title",n.text())).on("load",function(){var e,a;o=!0,c.removeClass("loading");try{e=(a=h(this).contents().find("body")).height()}catch(e){return d.addClass("fallback"),t.css("max-height",""),c.remove(),void n.focus()}e?a&&a.hasClass("interim-login-success")?s():t.css("max-height",e+40+"px"):a&&a.length||(d.addClass("fallback"),t.css("max-height",""),c.remove(),n.focus())}).attr("src",c.data("src")),c.append(e)),h("body").addClass("modal-open"),d.removeClass("hidden"),e?(e.focus(),setTimeout(function(){o||(d.addClass("fallback"),c.remove(),n.focus())},1e4)):n.focus()}():a["wp-auth-check"]&&!d.hasClass("hidden")&&s())}).ready(function(){(d=h("#wp-auth-check-wrap")).find(".wp-auth-check-close").on("click",function(){s()})})}(jQuery);

View File

@ -719,16 +719,6 @@ function wp_default_scripts( $scripts ) {
'authcheckL10n',
array(
'beforeunload' => __( 'Your session has expired. You can log in again from this page or go to the login page.' ),
/**
* Filters the authentication check interval.
*
* @since 3.6.0
*
* @param int $interval The interval in which to check a user's authentication.
* Default 3 minutes in seconds, or 180.
*/
'interval' => apply_filters( 'wp_auth_check_interval', 3 * MINUTE_IN_SECONDS ),
)
);

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48055';
$wp_version = '5.5-alpha-48056';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.