@wp-playground/wordpress 3.1.13 → 3.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +33 -8
- package/index.cjs.map +1 -1
- package/index.js +53 -28
- package/index.js.map +1 -1
- package/package.json +7 -7
package/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@php-wasm/util"),p=require("@wp-playground/common"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@php-wasm/util"),p=require("@wp-playground/common"),f=require("@php-wasm/logger"),d=require("@php-wasm/universal"),$=`<?php
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Transforms the "wp-config.php" file.
|
|
@@ -483,7 +483,7 @@ class WP_Config_Transformer {
|
|
|
483
483
|
$transformer = WP_Config_Transformer::from_file($wp_config_path);
|
|
484
484
|
$transformer->define_constants(${i.constants});
|
|
485
485
|
$transformer->to_file($wp_config_path);
|
|
486
|
-
`})).errors.length>0)throw new Error("Failed to rewrite constants in wp-config.php.")}async function x(t){const e=await w(t);return await m(e,t),e}async function m(t,e){var c,o;const n=await t.getPrimaryPhp();if((c=e.hooks)!=null&&c.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(n),e.wordPressZip&&await R(n,await e.wordPressZip),e.constants)for(const l in e.constants)n.defineConstant(l,e.constants[l]);e.dataSqlPath&&(n.defineConstant("DB_DIR",r.dirname(e.dataSqlPath)),n.defineConstant("DB_FILE",r.basename(e.dataSqlPath))),n.defineConstant("WP_HOME",e.siteUrl),n.defineConstant("WP_SITEURL",e.siteUrl),await g(n,t.documentRoot),(o=e.hooks)!=null&&o.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(n);let i=!1;e.sqliteIntegrationPluginZip&&(i=!0,await
|
|
486
|
+
`})).errors.length>0)throw new Error("Failed to rewrite constants in wp-config.php.")}async function x(t){const e=await w(t);return await m(e,t),e}async function m(t,e){var c,o;const n=await t.getPrimaryPhp();if((c=e.hooks)!=null&&c.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(n),e.wordPressZip&&await R(n,await e.wordPressZip),e.constants)for(const l in e.constants)n.defineConstant(l,e.constants[l]);e.dataSqlPath&&(n.defineConstant("DB_DIR",r.dirname(e.dataSqlPath)),n.defineConstant("DB_FILE",r.basename(e.dataSqlPath))),n.defineConstant("WP_HOME",e.siteUrl),n.defineConstant("WP_SITEURL",e.siteUrl),await g(n,t.documentRoot),(o=e.hooks)!=null&&o.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(n);let i=!1;e.sqliteIntegrationPluginZip&&(i=!0,await E(n,await e.sqliteIntegrationPluginZip));const a=e.wordpressInstallMode??"download-and-install",s=!!e.dataSqlPath;if(["download-and-install","install-from-existing-files"].includes(a)){await _(t,{usesSqlite:i,hasCustomDatabasePath:s});try{await h(n)}catch(l){throw s||await u(t),l}s||await u(t)}else if(a==="install-from-existing-files-if-needed"){if(await _(t,{usesSqlite:i,hasCustomDatabasePath:s}),!await P(n))try{await h(n)}catch(l){throw s||await u(t),l}s||await u(t)}return t}async function _(t,{usesSqlite:e,hasCustomDatabasePath:n}){const i=await t.getPrimaryPhp();if(i.isFile("/internal/shared/preload/0-sqlite.php"))return;const a=r.joinPaths(t.documentRoot,"wp-content/mu-plugins/sqlite-database-integration");if(!i.isDir(a)&&!e&&!n)throw new Error("Error connecting to the MySQL database.")}async function u(t){const e=await t.getPrimaryPhp();if(await L(e))return;if(e.isFile("/internal/shared/preload/0-sqlite.php"))throw new Error("Error connecting to the SQLite database.");const i=r.joinPaths(t.documentRoot,"wp-content/mu-plugins/sqlite-database-integration");throw e.isDir(i)?new Error("Error connecting to the SQLite database."):new Error("Error connecting to the MySQL database.")}async function w(t){const e=t.spawnHandler??d.sandboxedSpawnHandlerFactory;async function n(a,s=!1){const c=await t.createPhpRuntime(s),o=new d.PHP(c);if(t.sapiName&&o.setSapiName(t.sapiName),a&&(o.requestHandler=a),t.phpIniEntries&&d.setPhpIniEntries(o,t.phpIniEntries),o.defineConstant("WP_SQLITE_AST_DRIVER",!0),t.constants)for(const l in t.constants)o.defineConstant(l,t.constants[l]);return s&&!o.isFile("/internal/.boot-files-written")&&(await T(o),await d.writeFiles(o,"/",t.createFiles||{}),await v(o,r.joinPaths(new URL(t.siteUrl).pathname,"phpinfo.php")),await d.writeFiles(o,"/internal",{".boot-files-written":""})),e&&await o.setSpawnHandler(e(a?()=>a.instanceManager.acquirePHPInstance():void 0)),o.enableRuntimeRotation({recreateRuntime:t.createPhpRuntime,maxRequests:400}),t.onPHPInstanceCreated&&await t.onPHPInstanceCreated(o,{isPrimary:s}),o}const i=new d.PHPRequestHandler({documentRoot:t.documentRoot||"/wordpress",absoluteUrl:t.siteUrl,rewriteRules:b,pathAliases:t.pathAliases,getFileNotFoundAction:t.getFileNotFoundAction??k,cookieStore:t.cookieStore,php:t.maxPhpInstances===1?await n(void 0,!0):void 0,phpFactory:t.maxPhpInstances!==1?async({isPrimary:a})=>n(i,a):void 0,maxPhpInstances:t.maxPhpInstances});return i}async function P(t){return(await t.run({code:`<?php
|
|
487
487
|
ob_start();
|
|
488
488
|
$wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
|
|
489
489
|
if (!file_exists($wp_load)) {
|
|
@@ -494,7 +494,7 @@ class WP_Config_Transformer {
|
|
|
494
494
|
ob_clean();
|
|
495
495
|
echo is_blog_installed() ? '1' : '0';
|
|
496
496
|
ob_end_flush();
|
|
497
|
-
`,env:{DOCUMENT_ROOT:t.documentRoot}})).text==="1"}async function
|
|
497
|
+
`,env:{DOCUMENT_ROOT:t.documentRoot}})).text==="1"}async function h(t){var i;const e=await d.withPHPIniValues(t,{disable_functions:"fsockopen",allow_url_fopen:"0"},async()=>await t.request({url:"/wp-admin/install.php?step=2",method:"POST",body:{language:"en",prefix:"wp_",weblog_title:"My WordPress Website",user_name:"admin",admin_password:"password",admin_password2:"password",Submit:"Install WordPress",pw_weak:"1",admin_email:"admin@localhost.com"}}));if(!await P(t))throw new Error(`Failed to install WordPress – installer responded with "${(i=e.text)==null?void 0:i.substring(0,100)}"`);(await t.run({code:`<?php
|
|
498
498
|
ob_start();
|
|
499
499
|
$wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
|
|
500
500
|
if (!file_exists($wp_load)) {
|
|
@@ -514,7 +514,7 @@ class WP_Config_Transformer {
|
|
|
514
514
|
echo '0';
|
|
515
515
|
}
|
|
516
516
|
ob_end_flush();
|
|
517
|
-
`,env:{DOCUMENT_ROOT:t.documentRoot}})).text!=="1"&&
|
|
517
|
+
`,env:{DOCUMENT_ROOT:t.documentRoot}})).text!=="1"&&f.logger.warn("Failed to default to pretty permalinks after WP install.")}function k(t){return{type:"internal-redirect",uri:"/index.php"}}async function L(t){return(await t.run({code:`<?php
|
|
518
518
|
ob_start();
|
|
519
519
|
$wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
|
|
520
520
|
if (!file_exists($wp_load)) {
|
|
@@ -525,7 +525,7 @@ class WP_Config_Transformer {
|
|
|
525
525
|
ob_clean();
|
|
526
526
|
echo $wpdb->check_connection( false ) ? '1' : '0';
|
|
527
527
|
ob_end_flush();
|
|
528
|
-
`,env:{DOCUMENT_ROOT:t.documentRoot}})).text==="1"}async function
|
|
528
|
+
`,env:{DOCUMENT_ROOT:t.documentRoot}})).text==="1"}async function C(t){const{php:e,reap:n}=await t.instanceManager.acquirePHPInstance();try{const a=(await e.run({code:`<?php
|
|
529
529
|
require '${t.documentRoot}/wp-includes/version.php';
|
|
530
530
|
echo $wp_version;
|
|
531
531
|
`})).text;if(!a)throw new Error("Unable to read loaded WordPress version.");return y(a)}finally{n()}}function y(t){if(/-(alpha|beta|RC)\d*-\d+$/.test(t))return"trunk";if(/-(beta|RC)\d*$/.test(t))return"beta";const i=t.match(/^(\d+\.\d+)(?:\.\d+)?$/);return i!==null?i[1]:t}const b=[{match:new RegExp("^(/[_0-9a-zA-Z-]+)?(/wp-(content|admin|includes)/.*)"),replacement:"$2"}];async function T(t){await t.mkdir("/internal/shared/mu-plugins"),await t.writeFile("/internal/shared/preload/env.php",`<?php
|
|
@@ -710,6 +710,31 @@ class WP_Config_Transformer {
|
|
|
710
710
|
return $interval;
|
|
711
711
|
});
|
|
712
712
|
`),await t.writeFile("/internal/shared/mu-plugins/0-playground.php",`<?php
|
|
713
|
+
|
|
714
|
+
// Save WordPress environment information to a file.
|
|
715
|
+
add_action('wp_loaded', function() {
|
|
716
|
+
if (defined('DB_ENGINE') && DB_ENGINE === 'sqlite') {
|
|
717
|
+
$db_info = array(
|
|
718
|
+
'type' => 'sqlite',
|
|
719
|
+
'path' => FQDB,
|
|
720
|
+
'driver_path' => defined('WP_MYSQL_ON_SQLITE_LOADER_PATH')
|
|
721
|
+
? WP_MYSQL_ON_SQLITE_LOADER_PATH
|
|
722
|
+
: dirname(SQLITE_MAIN_FILE) . '/wp-pdo-mysql-on-sqlite.php',
|
|
723
|
+
);
|
|
724
|
+
} else {
|
|
725
|
+
$db_info = array(
|
|
726
|
+
'type' => 'mysql',
|
|
727
|
+
// TODO: Save MySQL connection config.
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
$wp_env = array('db' => $db_info);
|
|
731
|
+
$wp_env_php = sprintf('<?php return %s;', var_export($wp_env, true));
|
|
732
|
+
$wp_env_file = '/internal/shared/wp-env.php';
|
|
733
|
+
if (!file_exists($wp_env_file) || file_get_contents($wp_env_file) !== $wp_env_php ) {
|
|
734
|
+
file_put_contents($wp_env_file, $wp_env_php);
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
|
|
713
738
|
// Needed because gethostbyname( 'wordpress.org' ) returns
|
|
714
739
|
// a private network IP address for some reason.
|
|
715
740
|
add_filter( 'allowed_redirect_hosts', function( $deprecated = '' ) {
|
|
@@ -830,13 +855,13 @@ class WP_Config_Transformer {
|
|
|
830
855
|
}
|
|
831
856
|
return false;
|
|
832
857
|
});
|
|
833
|
-
})();`)}async function
|
|
858
|
+
})();`)}async function v(t,e="/phpinfo.php"){await t.writeFile("/internal/shared/preload/phpinfo.php",`<?php
|
|
834
859
|
// Render PHPInfo if the requested page is /phpinfo.php
|
|
835
860
|
if ( isset($_SERVER['REQUEST_URI']) && ${r.phpVar(e)} === $_SERVER['REQUEST_URI'] ) {
|
|
836
861
|
phpinfo();
|
|
837
862
|
exit;
|
|
838
863
|
}
|
|
839
|
-
`)}async function
|
|
864
|
+
`)}async function E(t,e){await t.isDir("/tmp/sqlite-database-integration")&&await t.rmdir("/tmp/sqlite-database-integration",{recursive:!0}),await t.mkdir("/tmp/sqlite-database-integration"),await p.unzipFile(t,e,"/tmp/sqlite-database-integration");const n="/internal/shared/sqlite-database-integration",i=`/tmp/sqlite-database-integration/${(await t.listFiles("/tmp/sqlite-database-integration"))[0]}`;await t.mv(i,n),await t.defineConstant("SQLITE_MAIN_FILE","1");const s=(await t.readFileAsText(r.joinPaths(n,"db.copy"))).replace("'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",r.phpVar(n)).replace("'{SQLITE_PLUGIN}'",r.phpVar(r.joinPaths(n,"load.php"))),c=r.joinPaths(await t.documentRoot,"wp-content/db.php"),o=`<?php
|
|
840
865
|
// Do not preload this if WordPress comes with a custom db.php file.
|
|
841
866
|
if(file_exists(${r.phpVar(c)})) {
|
|
842
867
|
return;
|
|
@@ -922,5 +947,5 @@ if(!function_exists('mysqli_connect')) {
|
|
|
922
947
|
var_dump(isset($wpdb));
|
|
923
948
|
die("SQLite integration not loaded " . get_class($wpdb));
|
|
924
949
|
}
|
|
925
|
-
`)}async function R(t,e){t.mkdir("/tmp/unzipped-wordpress"),await p.unzipFile(t,e,"/tmp/unzipped-wordpress"),t.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await p.unzipFile(t,"/tmp/unzipped-wordpress/wordpress.zip","/tmp/unzipped-wordpress");let n=t.fileExists("/tmp/unzipped-wordpress/wordpress")?"/tmp/unzipped-wordpress/wordpress":t.fileExists("/tmp/unzipped-wordpress/build")?"/tmp/unzipped-wordpress/build":"/tmp/unzipped-wordpress";if(!t.fileExists(r.joinPaths(n,"wp-config-sample.php"))){const a=t.listFiles(n);if(a.length){const s=a[0];t.fileExists(r.joinPaths(n,s,"wp-config-sample.php"))&&(n=r.joinPaths(n,s))}}const i=(a,s,c)=>{if(c.isDir(a)&&c.isDir(s))for(const o of c.listFiles(a)){const l=r.joinPaths(a,o),S=r.joinPaths(s,o);i(l,S,c)}else{if(c.fileExists(s)){const o=a.replace(/^\/tmp\/unzipped-wordpress\//,"/");
|
|
950
|
+
`)}async function R(t,e){t.mkdir("/tmp/unzipped-wordpress"),await p.unzipFile(t,e,"/tmp/unzipped-wordpress"),t.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await p.unzipFile(t,"/tmp/unzipped-wordpress/wordpress.zip","/tmp/unzipped-wordpress");let n=t.fileExists("/tmp/unzipped-wordpress/wordpress")?"/tmp/unzipped-wordpress/wordpress":t.fileExists("/tmp/unzipped-wordpress/build")?"/tmp/unzipped-wordpress/build":"/tmp/unzipped-wordpress";if(!t.fileExists(r.joinPaths(n,"wp-config-sample.php"))){const a=t.listFiles(n);if(a.length){const s=a[0];t.fileExists(r.joinPaths(n,s,"wp-config-sample.php"))&&(n=r.joinPaths(n,s))}}const i=(a,s,c)=>{if(c.isDir(a)&&c.isDir(s))for(const o of c.listFiles(a)){const l=r.joinPaths(a,o),S=r.joinPaths(s,o);i(l,S,c)}else{if(c.fileExists(s)){const o=a.replace(/^\/tmp\/unzipped-wordpress\//,"/");f.logger.warn(`Cannot unzip WordPress files at ${s}: ${o} already exists.`);return}c.mv(a,s)}};i(n,t.documentRoot,t),t.fileExists(n)&&t.rmdir(n,{recursive:!0}),!t.fileExists(r.joinPaths(t.documentRoot,"wp-config.php"))&&t.fileExists(r.joinPaths(t.documentRoot,"wp-config-sample.php"))&&t.writeFile(r.joinPaths(t.documentRoot,"wp-config.php"),t.readFileAsText(r.joinPaths(t.documentRoot,"/wp-config-sample.php")))}const W=p.createMemoizedFetch(fetch),O="https://github.com/WordPress/WordPress/archive/refs/heads/master.zip";async function q(t="latest"){if(t===null)t="latest";else if(t.startsWith("https://")||t.startsWith("http://")){const i=await crypto.subtle.digest("SHA-1",new TextEncoder().encode(t)),a=Array.from(new Uint8Array(i)).map(s=>s.toString(16).padStart(2,"0")).join("");return{releaseUrl:t,version:"custom-"+a.substring(0,8),source:"inferred"}}else if(t==="trunk"||t==="nightly"){const i=new Date().toISOString().split("T")[0];return{releaseUrl:`${O}?ts=${i}`,version:"trunk",source:"inferred"}}let n=await(await W("https://api.wordpress.org/core/version-check/1.7/?channel=beta")).json();n=n.offers.filter(i=>i.response==="autoupdate");for(const i of n){if(t==="beta"&&(i.version.includes("beta")||i.version.includes("RC")))return{releaseUrl:i.download,version:i.version,source:"api"};if(t==="latest"&&!i.version.includes("beta")&&!i.version.includes("RC"))return{releaseUrl:i.download,version:i.version,source:"api"};if(i.version.substring(0,t.length)===t)return{releaseUrl:i.download,version:i.version,source:"api"}}return t.match(/^\d+\.\d+\.0$/)&&(t=t.split(".").slice(0,2).join(".")),{releaseUrl:`https://wordpress.org/wordpress-${t}.zip`,version:t,source:"inferred"}}exports.bootRequestHandler=w;exports.bootWordPress=m;exports.bootWordPressAndRequestHandler=x;exports.defineWpConfigConstants=I;exports.ensureWpConfig=g;exports.getFileNotFoundActionForWordPress=k;exports.getLoadedWordPressVersion=C;exports.preloadPhpInfoRoute=v;exports.preloadSqliteIntegration=E;exports.resolveWordPressRelease=q;exports.setupPlatformLevelMuPlugins=T;exports.unzipWordPress=R;exports.versionStringToLoadedWordPressVersion=y;exports.wordPressRewriteRules=b;
|
|
926
951
|
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":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
|
1
1
|
import { phpVars as $, joinPaths as s, dirname as y, basename as b, phpVar as d } from "@php-wasm/util";
|
|
2
2
|
import { createMemoizedFetch as P, unzipFile as p } from "@wp-playground/common";
|
|
3
3
|
import { logger as g } from "@php-wasm/logger";
|
|
4
|
-
import { sandboxedSpawnHandlerFactory as T, PHPRequestHandler as E, PHP as v, setPhpIniEntries as
|
|
4
|
+
import { sandboxedSpawnHandlerFactory as T, PHPRequestHandler as E, PHP as v, setPhpIniEntries as S, writeFiles as _, withPHPIniValues as R } from "@php-wasm/universal";
|
|
5
5
|
const m = `<?php
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -500,7 +500,7 @@ async function I(t, e) {
|
|
|
500
500
|
})).errors.length > 0)
|
|
501
501
|
throw new Error("Failed to auto-configure wp-config.php.");
|
|
502
502
|
}
|
|
503
|
-
async function
|
|
503
|
+
async function Q(t, e, n) {
|
|
504
504
|
const i = $({ wpConfigPath: e, constants: n });
|
|
505
505
|
if ((await t.run({
|
|
506
506
|
code: `${m}
|
|
@@ -512,8 +512,8 @@ async function j(t, e, n) {
|
|
|
512
512
|
})).errors.length > 0)
|
|
513
513
|
throw new Error("Failed to rewrite constants in wp-config.php.");
|
|
514
514
|
}
|
|
515
|
-
async function
|
|
516
|
-
const e = await
|
|
515
|
+
async function j(t) {
|
|
516
|
+
const e = await L(t);
|
|
517
517
|
return await x(e, t), e;
|
|
518
518
|
}
|
|
519
519
|
async function x(t, e) {
|
|
@@ -532,23 +532,23 @@ async function x(t, e) {
|
|
|
532
532
|
if (["download-and-install", "install-from-existing-files"].includes(
|
|
533
533
|
a
|
|
534
534
|
)) {
|
|
535
|
-
await
|
|
535
|
+
await f(t, {
|
|
536
536
|
usesSqlite: i,
|
|
537
537
|
hasCustomDatabasePath: o
|
|
538
538
|
});
|
|
539
539
|
try {
|
|
540
|
-
await
|
|
540
|
+
await h(n);
|
|
541
541
|
} catch (l) {
|
|
542
542
|
throw o || await u(t), l;
|
|
543
543
|
}
|
|
544
544
|
o || await u(t);
|
|
545
545
|
} else if (a === "install-from-existing-files-if-needed") {
|
|
546
|
-
if (await
|
|
546
|
+
if (await f(t, {
|
|
547
547
|
usesSqlite: i,
|
|
548
548
|
hasCustomDatabasePath: o
|
|
549
549
|
}), !await w(n))
|
|
550
550
|
try {
|
|
551
|
-
await
|
|
551
|
+
await h(n);
|
|
552
552
|
} catch (l) {
|
|
553
553
|
throw o || await u(t), l;
|
|
554
554
|
}
|
|
@@ -556,7 +556,7 @@ async function x(t, e) {
|
|
|
556
556
|
}
|
|
557
557
|
return t;
|
|
558
558
|
}
|
|
559
|
-
async function
|
|
559
|
+
async function f(t, {
|
|
560
560
|
usesSqlite: e,
|
|
561
561
|
hasCustomDatabasePath: n
|
|
562
562
|
}) {
|
|
@@ -582,11 +582,11 @@ async function u(t) {
|
|
|
582
582
|
);
|
|
583
583
|
throw e.isDir(i) ? new Error("Error connecting to the SQLite database.") : new Error("Error connecting to the MySQL database.");
|
|
584
584
|
}
|
|
585
|
-
async function
|
|
585
|
+
async function L(t) {
|
|
586
586
|
const e = t.spawnHandler ?? T;
|
|
587
587
|
async function n(a, o = !1) {
|
|
588
588
|
const c = await t.createPhpRuntime(o), r = new v(c);
|
|
589
|
-
if (t.sapiName && r.setSapiName(t.sapiName), a && (r.requestHandler = a), t.phpIniEntries &&
|
|
589
|
+
if (t.sapiName && r.setSapiName(t.sapiName), a && (r.requestHandler = a), t.phpIniEntries && S(r, t.phpIniEntries), r.defineConstant("WP_SQLITE_AST_DRIVER", !0), t.constants)
|
|
590
590
|
for (const l in t.constants)
|
|
591
591
|
r.defineConstant(l, t.constants[l]);
|
|
592
592
|
return o && /**
|
|
@@ -599,10 +599,10 @@ async function C(t) {
|
|
|
599
599
|
* mechanism. It works, because secondary workers are only booted
|
|
600
600
|
* once the primary worker has fully booted.
|
|
601
601
|
*/
|
|
602
|
-
!r.isFile("/internal/.boot-files-written") && (await
|
|
602
|
+
!r.isFile("/internal/.boot-files-written") && (await q(r), await _(r, "/", t.createFiles || {}), await U(
|
|
603
603
|
r,
|
|
604
604
|
s(new URL(t.siteUrl).pathname, "phpinfo.php")
|
|
605
|
-
), await
|
|
605
|
+
), await _(r, "/internal", {
|
|
606
606
|
".boot-files-written": ""
|
|
607
607
|
})), e && await r.setSpawnHandler(
|
|
608
608
|
e(
|
|
@@ -618,7 +618,7 @@ async function C(t) {
|
|
|
618
618
|
absoluteUrl: t.siteUrl,
|
|
619
619
|
rewriteRules: W,
|
|
620
620
|
pathAliases: t.pathAliases,
|
|
621
|
-
getFileNotFoundAction: t.getFileNotFoundAction ??
|
|
621
|
+
getFileNotFoundAction: t.getFileNotFoundAction ?? C,
|
|
622
622
|
cookieStore: t.cookieStore,
|
|
623
623
|
/**
|
|
624
624
|
* If maxPhpInstances is 1, the PHPRequestHandler constructor needs
|
|
@@ -655,9 +655,9 @@ async function w(t) {
|
|
|
655
655
|
}
|
|
656
656
|
})).text === "1";
|
|
657
657
|
}
|
|
658
|
-
async function
|
|
658
|
+
async function h(t) {
|
|
659
659
|
var i;
|
|
660
|
-
const e = await
|
|
660
|
+
const e = await R(
|
|
661
661
|
t,
|
|
662
662
|
{
|
|
663
663
|
disable_functions: "fsockopen",
|
|
@@ -714,7 +714,7 @@ async function _(t) {
|
|
|
714
714
|
}
|
|
715
715
|
})).text !== "1" && g.warn("Failed to default to pretty permalinks after WP install.");
|
|
716
716
|
}
|
|
717
|
-
function
|
|
717
|
+
function C(t) {
|
|
718
718
|
return {
|
|
719
719
|
type: "internal-redirect",
|
|
720
720
|
uri: "/index.php"
|
|
@@ -750,12 +750,12 @@ async function V(t) {
|
|
|
750
750
|
})).text;
|
|
751
751
|
if (!a)
|
|
752
752
|
throw new Error("Unable to read loaded WordPress version.");
|
|
753
|
-
return
|
|
753
|
+
return A(a);
|
|
754
754
|
} finally {
|
|
755
755
|
n();
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
|
-
function
|
|
758
|
+
function A(t) {
|
|
759
759
|
if (/-(alpha|beta|RC)\d*-\d+$/.test(t))
|
|
760
760
|
return "trunk";
|
|
761
761
|
if (/-(beta|RC)\d*$/.test(t))
|
|
@@ -779,7 +779,7 @@ const W = [
|
|
|
779
779
|
replacement: "$2"
|
|
780
780
|
}
|
|
781
781
|
];
|
|
782
|
-
async function
|
|
782
|
+
async function q(t) {
|
|
783
783
|
await t.mkdir("/internal/shared/mu-plugins"), await t.writeFile(
|
|
784
784
|
"/internal/shared/preload/env.php",
|
|
785
785
|
`<?php
|
|
@@ -970,6 +970,31 @@ async function A(t) {
|
|
|
970
970
|
), await t.writeFile(
|
|
971
971
|
"/internal/shared/mu-plugins/0-playground.php",
|
|
972
972
|
`<?php
|
|
973
|
+
|
|
974
|
+
// Save WordPress environment information to a file.
|
|
975
|
+
add_action('wp_loaded', function() {
|
|
976
|
+
if (defined('DB_ENGINE') && DB_ENGINE === 'sqlite') {
|
|
977
|
+
$db_info = array(
|
|
978
|
+
'type' => 'sqlite',
|
|
979
|
+
'path' => FQDB,
|
|
980
|
+
'driver_path' => defined('WP_MYSQL_ON_SQLITE_LOADER_PATH')
|
|
981
|
+
? WP_MYSQL_ON_SQLITE_LOADER_PATH
|
|
982
|
+
: dirname(SQLITE_MAIN_FILE) . '/wp-pdo-mysql-on-sqlite.php',
|
|
983
|
+
);
|
|
984
|
+
} else {
|
|
985
|
+
$db_info = array(
|
|
986
|
+
'type' => 'mysql',
|
|
987
|
+
// TODO: Save MySQL connection config.
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
$wp_env = array('db' => $db_info);
|
|
991
|
+
$wp_env_php = sprintf('<?php return %s;', var_export($wp_env, true));
|
|
992
|
+
$wp_env_file = '/internal/shared/wp-env.php';
|
|
993
|
+
if (!file_exists($wp_env_file) || file_get_contents($wp_env_file) !== $wp_env_php ) {
|
|
994
|
+
file_put_contents($wp_env_file, $wp_env_php);
|
|
995
|
+
}
|
|
996
|
+
});
|
|
997
|
+
|
|
973
998
|
// Needed because gethostbyname( 'wordpress.org' ) returns
|
|
974
999
|
// a private network IP address for some reason.
|
|
975
1000
|
add_filter( 'allowed_redirect_hosts', function( $deprecated = '' ) {
|
|
@@ -1099,7 +1124,7 @@ async function A(t) {
|
|
|
1099
1124
|
})();`
|
|
1100
1125
|
);
|
|
1101
1126
|
}
|
|
1102
|
-
async function
|
|
1127
|
+
async function U(t, e = "/phpinfo.php") {
|
|
1103
1128
|
await t.writeFile(
|
|
1104
1129
|
"/internal/shared/preload/phpinfo.php",
|
|
1105
1130
|
`<?php
|
|
@@ -1320,19 +1345,19 @@ async function Z(t = "latest") {
|
|
|
1320
1345
|
};
|
|
1321
1346
|
}
|
|
1322
1347
|
export {
|
|
1323
|
-
|
|
1348
|
+
L as bootRequestHandler,
|
|
1324
1349
|
x as bootWordPress,
|
|
1325
|
-
|
|
1326
|
-
|
|
1350
|
+
j as bootWordPressAndRequestHandler,
|
|
1351
|
+
Q as defineWpConfigConstants,
|
|
1327
1352
|
I as ensureWpConfig,
|
|
1328
|
-
|
|
1353
|
+
C as getFileNotFoundActionForWordPress,
|
|
1329
1354
|
V as getLoadedWordPressVersion,
|
|
1330
|
-
|
|
1355
|
+
U as preloadPhpInfoRoute,
|
|
1331
1356
|
F as preloadSqliteIntegration,
|
|
1332
1357
|
Z as resolveWordPressRelease,
|
|
1333
|
-
|
|
1358
|
+
q as setupPlatformLevelMuPlugins,
|
|
1334
1359
|
N as unzipWordPress,
|
|
1335
|
-
|
|
1360
|
+
A as versionStringToLoadedWordPressVersion,
|
|
1336
1361
|
W as wordPressRewriteRules
|
|
1337
1362
|
};
|
|
1338
1363
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/wordpress",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.15",
|
|
4
4
|
"description": "WordPress-related plumbing for WordPress Playground",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"access": "public",
|
|
36
36
|
"directory": "../../../dist/packages/playground/wordpress"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "65a430c046c86341e7dc3cf6f30c9a5aeb8aa67d",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"express": "4.22.0",
|
|
41
41
|
"fast-xml-parser": "^5.5.1",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"wasm-feature-detect": "1.8.0",
|
|
46
46
|
"ws": "8.18.3",
|
|
47
47
|
"yargs": "17.7.2",
|
|
48
|
-
"@php-wasm/universal": "3.1.
|
|
49
|
-
"@php-wasm/util": "3.1.
|
|
50
|
-
"@php-wasm/logger": "3.1.
|
|
51
|
-
"@wp-playground/common": "3.1.
|
|
52
|
-
"@php-wasm/node": "3.1.
|
|
48
|
+
"@php-wasm/universal": "3.1.15",
|
|
49
|
+
"@php-wasm/util": "3.1.15",
|
|
50
|
+
"@php-wasm/logger": "3.1.15",
|
|
51
|
+
"@wp-playground/common": "3.1.15",
|
|
52
|
+
"@php-wasm/node": "3.1.15"
|
|
53
53
|
},
|
|
54
54
|
"packageManager": "npm@10.9.2",
|
|
55
55
|
"overrides": {
|