Skip to content

Commit 623934d

Browse files
authored
Merge pull request #1684 from WordPress/release/3.6.1
Merge 3.6.1 release changes back into `trunk`
2 parents 20a038f + 8ee549f commit 623934d

File tree

3 files changed

+48
-16
lines changed

3 files changed

+48
-16
lines changed

plugins/performance-lab/includes/admin/plugin-activate-ajax.js

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@
77
const { i18n, a11y, apiFetch } = wp;
88
const { __ } = i18n;
99

10+
// Queue to hold pending activation requests.
11+
const activationQueue = [];
12+
let isProcessingActivation = false;
13+
1014
/**
11-
* Handles click events on elements with the class 'perflab-install-active-plugin'.
12-
*
13-
* This asynchronous function listens for click events on the document and executes
14-
* the provided callback function if triggered.
15+
* Enqueues plugin activation requests and starts processing if not already in progress.
1516
*
16-
* @param {MouseEvent} event - The click event object that is triggered when the user clicks on the document.
17-
*
18-
* @return {Promise<void>} The asynchronous function returns a promise that resolves to void.
17+
* @param {MouseEvent} event - The click event object.
1918
*/
20-
async function handlePluginActivationClick( event ) {
21-
const target = /** @type {HTMLElement} */ ( event.target );
22-
19+
function enqueuePluginActivation( event ) {
2320
// Prevent the default link behavior.
2421
event.preventDefault();
2522

23+
const target = /** @type {HTMLElement} */ ( event.target );
24+
2625
if (
2726
target.classList.contains( 'updating-message' ) ||
2827
target.classList.contains( 'disabled' )
@@ -31,12 +30,37 @@
3130
}
3231

3332
target.classList.add( 'updating-message' );
33+
target.textContent = __( 'Waiting…', 'performance-lab' );
34+
35+
const pluginSlug = target.dataset.pluginSlug;
36+
37+
activationQueue.push( { target, pluginSlug } );
38+
39+
// Start processing the queue if not already doing so.
40+
if ( ! isProcessingActivation ) {
41+
handlePluginActivation();
42+
}
43+
}
44+
45+
/**
46+
* Handles activation of feature/plugin using queue based approach.
47+
*
48+
* @return {Promise<void>} The asynchronous function returns a promise that resolves to void.
49+
*/
50+
async function handlePluginActivation() {
51+
if ( 0 === activationQueue.length ) {
52+
isProcessingActivation = false;
53+
return;
54+
}
55+
56+
isProcessingActivation = true;
57+
58+
const { target, pluginSlug } = activationQueue.shift();
59+
3460
target.textContent = __( 'Activating…', 'performance-lab' );
3561

3662
a11y.speak( __( 'Activating…', 'performance-lab' ) );
3763

38-
const pluginSlug = target.dataset.pluginSlug;
39-
4064
try {
4165
// Activate the plugin/feature via the REST API.
4266
await apiFetch( {
@@ -76,13 +100,15 @@
76100

77101
target.classList.remove( 'updating-message' );
78102
target.textContent = __( 'Activate', 'performance-lab' );
103+
} finally {
104+
handlePluginActivation();
79105
}
80106
}
81107

82108
// Attach the event listeners.
83109
document
84110
.querySelectorAll( '.perflab-install-active-plugin' )
85111
.forEach( ( item ) => {
86-
item.addEventListener( 'click', handlePluginActivationClick );
112+
item.addEventListener( 'click', enqueuePluginActivation );
87113
} );
88114
} )();

plugins/performance-lab/load.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: Performance plugin from the WordPress Performance Team, which is a collection of standalone performance features.
66
* Requires at least: 6.5
77
* Requires PHP: 7.2
8-
* Version: 3.6.0
8+
* Version: 3.6.1
99
* Author: WordPress Performance Team
1010
* Author URI: https://make.wordpress.org/performance/
1111
* License: GPLv2 or later
@@ -19,7 +19,7 @@
1919
exit; // Exit if accessed directly.
2020
}
2121

22-
define( 'PERFLAB_VERSION', '3.6.0' );
22+
define( 'PERFLAB_VERSION', '3.6.1' );
2323
define( 'PERFLAB_MAIN_FILE', __FILE__ );
2424
define( 'PERFLAB_PLUGIN_DIR_PATH', plugin_dir_path( PERFLAB_MAIN_FILE ) );
2525
define( 'PERFLAB_SCREEN', 'performance-lab' );

plugins/performance-lab/readme.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Contributors: wordpressdotorg
44
Tested up to: 6.7
5-
Stable tag: 3.6.0
5+
Stable tag: 3.6.1
66
License: GPLv2 or later
77
License URI: https://www.gnu.org/licenses/gpl-2.0.html
88
Tags: performance, site health, measurement, optimization, diagnostics
@@ -71,6 +71,12 @@ Contributions are always welcome! Learn more about how to get involved in the [C
7171

7272
== Changelog ==
7373

74+
= 3.6.1 =
75+
76+
**Bug Fixes**
77+
78+
* Fix race condition bug where activating multiple features sequentially could fail to activate some features. ([#1675](https://github.com/WordPress/performance/pull/1675))
79+
7480
= 3.6.0 =
7581

7682
**Enhancements**

0 commit comments

Comments
 (0)