Skip to content

Commit 9abe020

Browse files
committed
Move backfilling out of boot and into worker-thread
The boot process doesn't need to know about web-related compromises. That can be handled by the process that invokes bootWordPress().
1 parent 9b2c8dc commit 9abe020

File tree

2 files changed

+1
-46
lines changed

2 files changed

+1
-46
lines changed

packages/playground/remote/src/lib/worker-thread.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { PHPWorker } from '@php-wasm/universal';
3939
import {
4040
bootWordPress,
4141
getLoadedWordPressVersion,
42+
isSupportedWordPressVersion,
4243
} from '@wp-playground/wordpress';
4344
import { wpVersionToStaticAssetsDirectory } from '@wp-playground/wordpress-builds';
4445
import { logger } from '@php-wasm/logger';

packages/playground/wordpress/src/boot.ts

-46
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ import {
1818
wordPressRewriteRules,
1919
} from '.';
2020
import { joinPaths } from '@php-wasm/util';
21-
import { logger } from '@php-wasm/logger';
22-
import { removeURLScope } from '@php-wasm/scopes';
23-
import {
24-
getLoadedWordPressVersion,
25-
isSupportedWordPressVersion,
26-
} from './version-detect';
27-
import { wpVersionToStaticAssetsDirectory } from '@wp-playground/wordpress-builds';
2821

2922
export type PhpIniOptions = Record<string, string>;
3023
export type Hook = (php: PHP) => void | Promise<void>;
@@ -199,45 +192,6 @@ export async function bootWordPress(options: BootOptions) {
199192

200193
// @TODO Assert WordPress core files are in place
201194

202-
const remoteAssetListPath = joinPaths(
203-
requestHandler.documentRoot,
204-
'wordpress-remote-asset-paths'
205-
);
206-
// Use a common WP static asset to guess whether we are using a minified WP build.
207-
const commonStaticAssetPath = joinPaths(
208-
requestHandler.documentRoot,
209-
'wp-admin/css/common.css'
210-
);
211-
if (
212-
!php.fileExists(remoteAssetListPath) &&
213-
!php.fileExists(commonStaticAssetPath)
214-
) {
215-
// We are missing the remote asset listing and a common static file.
216-
// This looks like a minified WP build missing a remote asset listing.
217-
const loadedWordPressVersion = await getLoadedWordPressVersion(
218-
requestHandler
219-
);
220-
if (isSupportedWordPressVersion(loadedWordPressVersion)) {
221-
const unscopedBaseUrl = removeURLScope(
222-
new URL(requestHandler.absoluteUrl)
223-
);
224-
const wpStaticAssetsDir = wpVersionToStaticAssetsDirectory(
225-
loadedWordPressVersion
226-
);
227-
const listUrl = `${unscopedBaseUrl.href}/${wpStaticAssetsDir}/wordpress-remote-asset-paths`;
228-
try {
229-
const remoteAssetPaths = await fetch(listUrl).then((res) =>
230-
res.text()
231-
);
232-
php.writeFile(remoteAssetListPath, remoteAssetPaths);
233-
} catch (e) {
234-
logger.warn(
235-
`Failed to fetch remote asset paths from ${listUrl}`
236-
);
237-
}
238-
}
239-
}
240-
241195
// Run "before database" hooks to mount/copy more files in
242196
if (options.hooks?.beforeDatabaseSetup) {
243197
await options.hooks.beforeDatabaseSetup(php);

0 commit comments

Comments
 (0)