PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 All 128 releases
← All changes | src/AutoLaunch/functions/plugins.js +30 -17 3.1.4 → 3.2.2 View file →
@@ -1,7 +1,11 @@
1 1 import { recordPluginActivity } from '@shared/api/DataApi';
2 2 import { digest } from '@shared/api/digest';
3 3 import { enableAutoUpdate } from '@shared/api/wp';
4 +import {
5 + failedDependencies,
6 + processWithSecondPass,
7 +} from '@shared/lib/patterns';
4 8 import apiFetch from '@wordpress/api-fetch';
5 9 import { addQueryArgs } from '@wordpress/url';
6 10
7 11 export const getActivePlugins = () =>
@@ -93,21 +97,19 @@
93 97
94 98 try {
95 99 await fn(slug);
96 100 return true;
97 - } catch (_) {
98 - try {
99 - // try once more but get the slug first
100 - const { plugin } = await getPlugin(slug);
101 - await fn(plugin);
102 - return true;
103 - } catch (error) {
101 + } catch (error) {
102 + const report = (e) => {
104 103 digest({
105 - error,
104 + error: e,
106 105 details: { source: 'auto-launch', caller: 'activatePlugin' },
107 106 });
108 107 return false;
109 - }
108 + };
109 + const found = await getPlugin(slug).catch(() => undefined);
110 + if (!found?.plugin) return report(error);
111 + return fn(found.plugin).then(() => true, report);
110 112 }
111 113 };
112 114
113 115 // Exact match, not substring: woocommerce-payments would mask a missing woocommerce.
@@ -159,8 +161,26 @@
159 161 },
160 162 });
161 163 };
162 164
165 +export const reportFailedDependencies = (pages) => {
166 + const failed = [
167 + ...new Set(pages.flatMap(({ patterns }) => failedDependencies(patterns))),
168 + ];
169 + if (!failed.length) return;
170 +
171 + digest({
172 + error: {
173 + message: `Patterns left static after a failed dependency: ${failed.join(', ')}`,
174 + },
175 + details: {
176 + source: 'auto-launch',
177 + caller: 'reportFailedDependencies',
178 + failed,
179 + },
180 + });
181 +};
182 +
163 183 // Currently this only processes patterns with placeholders
164 184 // by swapping out the placeholders with the actual code
165 185 // returns the patterns as blocks with the placeholders replaced
166 186 export const replacePlaceholderPatterns = async (patterns) => {
@@ -195,16 +215,9 @@
195 215 source: 'auto-launch',
196 216 });
197 217 }
198 218
199 - try {
200 - return await processPlaceholders(patterns);
201 - } catch (_e) {
202 - // Try one more time (plugins installed may not be fully loaded)
203 - return await processPlaceholders(patterns)
204 - // If this fails, just return the original patterns
205 - .catch(() => patterns);
206 - }
219 + return await processWithSecondPass(processPlaceholders, patterns);
207 220 };
208 221
209 222 // This endpoint installs pattern dependencies from PHP, outside the queue.
210 223 export const processPlaceholders = async (patterns) => {