@wp-playground/wordpress 3.1.16 → 3.1.19
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 +20 -20
- package/index.js +92 -81
- package/index.js.map +1 -1
- package/package.json +7 -7
- package/wp-config.d.ts +3 -2
package/index.cjs
CHANGED
|
@@ -469,21 +469,21 @@ class WP_Config_Transformer {
|
|
|
469
469
|
&& ( T_WHITESPACE === $token[0] || T_COMMENT === $token[0] || T_DOC_COMMENT === $token[0] );
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
|
-
`;async function g(t,e){const n=r.joinPaths(e,"wp-config.php")
|
|
473
|
-
$wp_config_path = ${a.wpConfigPath};
|
|
474
|
-
$transformer = WP_Config_Transformer::from_file($wp_config_path);
|
|
475
|
-
foreach ( ${a.constants} as $name => $value ) {
|
|
476
|
-
if ( ! $transformer->constant_exists( $name ) ) {
|
|
477
|
-
$transformer->define_constant($name, $value);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
$transformer->to_file($wp_config_path);
|
|
481
|
-
`})).errors.length>0)throw new Error("Failed to auto-configure wp-config.php.")}async function I(t,e,n){const i=r.phpVars({wpConfigPath:e,constants:n});if((await t.run({code:`${$}
|
|
472
|
+
`;async function g(t,e){const n=r.joinPaths(e,"wp-config.php");!t.fileExists(n)&&t.fileExists(r.joinPaths(e,"wp-config-sample.php"))&&await t.writeFile(n,await t.readFileAsBuffer(r.joinPaths(e,"wp-config-sample.php"))),t.fileExists(n)&&await x(t,n,{DB_NAME:"wordpress"})}async function I(t,e,n){const i=r.phpVars({wpConfigPath:e,constants:n});if((await t.run({code:`${$}
|
|
482
473
|
$wp_config_path = ${i.wpConfigPath};
|
|
483
474
|
$transformer = WP_Config_Transformer::from_file($wp_config_path);
|
|
484
475
|
$transformer->define_constants(${i.constants});
|
|
485
476
|
$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
|
|
477
|
+
`})).errors.length>0)throw new Error("Failed to rewrite constants in wp-config.php.")}async function x(t,e,n){const i=Object.keys(n),a=r.phpVars({wpConfigPath:e,constantNames:i}),s=await t.run({code:`${$}
|
|
478
|
+
$transformer = WP_Config_Transformer::from_file(${a.wpConfigPath});
|
|
479
|
+
$missing = [];
|
|
480
|
+
foreach (${a.constantNames} as $name) {
|
|
481
|
+
if (!$transformer->constant_exists($name)) {
|
|
482
|
+
$missing[] = $name;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
echo json_encode($missing);
|
|
486
|
+
`});if(s.errors.length>0)throw new Error("Failed to check wp-config.php for constants.");let l;try{l=JSON.parse(s.text)}catch{throw new Error(`Failed to parse wp-config.php constant check output: ${s.text}`)}for(const o of l)await t.defineConstant(o,n[o])}async function L(t){const e=await w(t);return await m(e,t),e}async function m(t,e){var l,o;const n=await t.getPrimaryPhp();if((l=e.hooks)!=null&&l.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(n),e.wordPressZip&&await R(n,await e.wordPressZip),e.constants)for(const c in e.constants)n.defineConstant(c,e.constants[c]);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 v(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 h(t,{usesSqlite:i,hasCustomDatabasePath:s});try{await f(n)}catch(c){throw s||await u(t),c}s||await u(t)}else if(a==="install-from-existing-files-if-needed"){if(await h(t,{usesSqlite:i,hasCustomDatabasePath:s}),!await P(n))try{await f(n)}catch(c){throw s||await u(t),c}s||await u(t)}return t}async function h(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&&!C(i))throw new Error("Error connecting to the MySQL database.")}async function u(t){const e=await t.getPrimaryPhp();if(await W(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 l=await t.createPhpRuntime(s),o=new d.PHP(l);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 c in t.constants)o.defineConstant(c,t.constants[c]);return s&&!o.isFile("/internal/.boot-files-written")&&(await T(o),await d.writeFiles(o,"/",t.createFiles||{}),await E(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 f(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"&&_.logger.warn("Failed to default to pretty permalinks after WP install.")}function k(t){return{type:"internal-redirect",uri:"/index.php"}}function
|
|
517
|
+
`,env:{DOCUMENT_ROOT:t.documentRoot}})).text!=="1"&&_.logger.warn("Failed to default to pretty permalinks after WP install.")}function k(t){return{type:"internal-redirect",uri:"/index.php"}}function C(t){const e=r.joinPaths(t.documentRoot,"wp-config.php");if(!t.isFile(e))return!1;const n=t.readFileAsText(e),i=n.match(/define\s*\(\s*['"]DB_NAME['"]\s*,\s*['"]([^'"]*)['"]/),a=n.match(/define\s*\(\s*['"]DB_USER['"]\s*,\s*['"]([^'"]*)['"]/);return!i||!a?!1:i[1]!=="database_name_here"&&a[1]!=="username_here"}async function W(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 O(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
|
|
@@ -855,18 +855,18 @@ class WP_Config_Transformer {
|
|
|
855
855
|
}
|
|
856
856
|
return false;
|
|
857
857
|
});
|
|
858
|
-
})();`)}async function
|
|
858
|
+
})();`)}async function E(t,e="/phpinfo.php"){await t.writeFile("/internal/shared/preload/phpinfo.php",`<?php
|
|
859
859
|
// Render PHPInfo if the requested page is /phpinfo.php
|
|
860
860
|
if ( isset($_SERVER['REQUEST_URI']) && ${r.phpVar(e)} === $_SERVER['REQUEST_URI'] ) {
|
|
861
861
|
phpinfo();
|
|
862
862
|
exit;
|
|
863
863
|
}
|
|
864
|
-
`)}async function
|
|
864
|
+
`)}async function v(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"))),l=r.joinPaths(await t.documentRoot,"wp-content/db.php"),o=`<?php
|
|
865
865
|
// Do not preload this if WordPress comes with a custom db.php file.
|
|
866
|
-
if(file_exists(${r.phpVar(
|
|
866
|
+
if(file_exists(${r.phpVar(l)})) {
|
|
867
867
|
return;
|
|
868
868
|
}
|
|
869
|
-
?>`,
|
|
869
|
+
?>`,c="/internal/shared/mu-plugins/sqlite-database-integration.php";await t.writeFile(c,o+s),await t.writeFile("/internal/shared/preload/0-sqlite.php",o+`<?php
|
|
870
870
|
|
|
871
871
|
/**
|
|
872
872
|
* Loads the SQLite integration plugin before WordPress is loaded
|
|
@@ -916,7 +916,7 @@ class Playground_SQLite_Integration_Loader {
|
|
|
916
916
|
$GLOBALS['wpdb']->$name = $value;
|
|
917
917
|
}
|
|
918
918
|
protected function load_sqlite_integration() {
|
|
919
|
-
require_once ${r.phpVar(
|
|
919
|
+
require_once ${r.phpVar(c)};
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
922
|
/**
|
|
@@ -947,5 +947,5 @@ if(!function_exists('mysqli_connect')) {
|
|
|
947
947
|
var_dump(isset($wpdb));
|
|
948
948
|
die("SQLite integration not loaded " . get_class($wpdb));
|
|
949
949
|
}
|
|
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,
|
|
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,l)=>{if(l.isDir(a)&&l.isDir(s))for(const o of l.listFiles(a)){const c=r.joinPaths(a,o),S=r.joinPaths(s,o);i(c,S,l)}else{if(l.fileExists(s)){const o=a.replace(/^\/tmp\/unzipped-wordpress\//,"/");_.logger.warn(`Cannot unzip WordPress files at ${s}: ${o} already exists.`);return}l.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 q=p.createMemoizedFetch(fetch),A="https://github.com/WordPress/WordPress/archive/refs/heads/master.zip";async function U(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:`${A}?ts=${i}`,version:"trunk",source:"inferred"}}let n=await(await q("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=L;exports.defineWpConfigConstants=I;exports.ensureWpConfig=g;exports.getFileNotFoundActionForWordPress=k;exports.getLoadedWordPressVersion=O;exports.preloadPhpInfoRoute=E;exports.preloadSqliteIntegration=v;exports.resolveWordPressRelease=U;exports.setupPlatformLevelMuPlugins=T;exports.unzipWordPress=R;exports.versionStringToLoadedWordPressVersion=y;exports.wordPressRewriteRules=b;
|
|
951
951
|
//# sourceMappingURL=index.cjs.map
|
package/index.js
CHANGED
|
@@ -475,32 +475,17 @@ class WP_Config_Transformer {
|
|
|
475
475
|
}
|
|
476
476
|
`;
|
|
477
477
|
async function I(t, e) {
|
|
478
|
-
const n = s(e, "wp-config.php")
|
|
479
|
-
|
|
480
|
-
};
|
|
481
|
-
if (!t.fileExists(n) && t.fileExists(s(e, "wp-config-sample.php")) && await t.writeFile(
|
|
478
|
+
const n = s(e, "wp-config.php");
|
|
479
|
+
!t.fileExists(n) && t.fileExists(s(e, "wp-config-sample.php")) && await t.writeFile(
|
|
482
480
|
n,
|
|
483
481
|
await t.readFileAsBuffer(
|
|
484
482
|
s(e, "wp-config-sample.php")
|
|
485
483
|
)
|
|
486
|
-
),
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
if ((await t.run({
|
|
490
|
-
code: `${m}
|
|
491
|
-
$wp_config_path = ${a.wpConfigPath};
|
|
492
|
-
$transformer = WP_Config_Transformer::from_file($wp_config_path);
|
|
493
|
-
foreach ( ${a.constants} as $name => $value ) {
|
|
494
|
-
if ( ! $transformer->constant_exists( $name ) ) {
|
|
495
|
-
$transformer->define_constant($name, $value);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
$transformer->to_file($wp_config_path);
|
|
499
|
-
`
|
|
500
|
-
})).errors.length > 0)
|
|
501
|
-
throw new Error("Failed to auto-configure wp-config.php.");
|
|
484
|
+
), t.fileExists(n) && await x(t, n, {
|
|
485
|
+
DB_NAME: "wordpress"
|
|
486
|
+
});
|
|
502
487
|
}
|
|
503
|
-
async function
|
|
488
|
+
async function V(t, e, n) {
|
|
504
489
|
const i = $({ wpConfigPath: e, constants: n });
|
|
505
490
|
if ((await t.run({
|
|
506
491
|
code: `${m}
|
|
@@ -512,19 +497,45 @@ async function j(t, e, n) {
|
|
|
512
497
|
})).errors.length > 0)
|
|
513
498
|
throw new Error("Failed to rewrite constants in wp-config.php.");
|
|
514
499
|
}
|
|
515
|
-
async function
|
|
516
|
-
const e = await
|
|
517
|
-
|
|
500
|
+
async function x(t, e, n) {
|
|
501
|
+
const i = Object.keys(n), a = $({ wpConfigPath: e, constantNames: i }), o = await t.run({
|
|
502
|
+
code: `${m}
|
|
503
|
+
$transformer = WP_Config_Transformer::from_file(${a.wpConfigPath});
|
|
504
|
+
$missing = [];
|
|
505
|
+
foreach (${a.constantNames} as $name) {
|
|
506
|
+
if (!$transformer->constant_exists($name)) {
|
|
507
|
+
$missing[] = $name;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
echo json_encode($missing);
|
|
511
|
+
`
|
|
512
|
+
});
|
|
513
|
+
if (o.errors.length > 0)
|
|
514
|
+
throw new Error("Failed to check wp-config.php for constants.");
|
|
515
|
+
let l;
|
|
516
|
+
try {
|
|
517
|
+
l = JSON.parse(o.text);
|
|
518
|
+
} catch {
|
|
519
|
+
throw new Error(
|
|
520
|
+
`Failed to parse wp-config.php constant check output: ${o.text}`
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
for (const r of l)
|
|
524
|
+
await t.defineConstant(r, n[r]);
|
|
525
|
+
}
|
|
526
|
+
async function Z(t) {
|
|
527
|
+
const e = await C(t);
|
|
528
|
+
return await L(e, t), e;
|
|
518
529
|
}
|
|
519
|
-
async function
|
|
520
|
-
var
|
|
530
|
+
async function L(t, e) {
|
|
531
|
+
var l, r;
|
|
521
532
|
const n = await t.getPrimaryPhp();
|
|
522
|
-
if ((
|
|
523
|
-
for (const
|
|
524
|
-
n.defineConstant(
|
|
533
|
+
if ((l = e.hooks) != null && l.beforeWordPressFiles && await e.hooks.beforeWordPressFiles(n), e.wordPressZip && await M(n, await e.wordPressZip), e.constants)
|
|
534
|
+
for (const c in e.constants)
|
|
535
|
+
n.defineConstant(c, e.constants[c]);
|
|
525
536
|
e.dataSqlPath && (n.defineConstant("DB_DIR", y(e.dataSqlPath)), n.defineConstant("DB_FILE", b(e.dataSqlPath))), n.defineConstant("WP_HOME", e.siteUrl), n.defineConstant("WP_SITEURL", e.siteUrl), await I(n, t.documentRoot), (r = e.hooks) != null && r.beforeDatabaseSetup && await e.hooks.beforeDatabaseSetup(n);
|
|
526
537
|
let i = !1;
|
|
527
|
-
e.sqliteIntegrationPluginZip && (i = !0, await
|
|
538
|
+
e.sqliteIntegrationPluginZip && (i = !0, await D(
|
|
528
539
|
n,
|
|
529
540
|
await e.sqliteIntegrationPluginZip
|
|
530
541
|
));
|
|
@@ -538,8 +549,8 @@ async function x(t, e) {
|
|
|
538
549
|
});
|
|
539
550
|
try {
|
|
540
551
|
await h(n);
|
|
541
|
-
} catch (
|
|
542
|
-
throw o || await u(t),
|
|
552
|
+
} catch (c) {
|
|
553
|
+
throw o || await u(t), c;
|
|
543
554
|
}
|
|
544
555
|
o || await u(t);
|
|
545
556
|
} else if (a === "install-from-existing-files-if-needed") {
|
|
@@ -549,8 +560,8 @@ async function x(t, e) {
|
|
|
549
560
|
}), !await w(n))
|
|
550
561
|
try {
|
|
551
562
|
await h(n);
|
|
552
|
-
} catch (
|
|
553
|
-
throw o || await u(t),
|
|
563
|
+
} catch (c) {
|
|
564
|
+
throw o || await u(t), c;
|
|
554
565
|
}
|
|
555
566
|
o || await u(t);
|
|
556
567
|
}
|
|
@@ -567,12 +578,12 @@ async function _(t, {
|
|
|
567
578
|
t.documentRoot,
|
|
568
579
|
"wp-content/mu-plugins/sqlite-database-integration"
|
|
569
580
|
);
|
|
570
|
-
if (!i.isDir(a) && !e && !n && !
|
|
581
|
+
if (!i.isDir(a) && !e && !n && !A(i))
|
|
571
582
|
throw new Error("Error connecting to the MySQL database.");
|
|
572
583
|
}
|
|
573
584
|
async function u(t) {
|
|
574
585
|
const e = await t.getPrimaryPhp();
|
|
575
|
-
if (await
|
|
586
|
+
if (await W(e))
|
|
576
587
|
return;
|
|
577
588
|
if (e.isFile("/internal/shared/preload/0-sqlite.php"))
|
|
578
589
|
throw new Error("Error connecting to the SQLite database.");
|
|
@@ -582,13 +593,13 @@ async function u(t) {
|
|
|
582
593
|
);
|
|
583
594
|
throw e.isDir(i) ? new Error("Error connecting to the SQLite database.") : new Error("Error connecting to the MySQL database.");
|
|
584
595
|
}
|
|
585
|
-
async function
|
|
596
|
+
async function C(t) {
|
|
586
597
|
const e = t.spawnHandler ?? T;
|
|
587
598
|
async function n(a, o = !1) {
|
|
588
|
-
const
|
|
599
|
+
const l = await t.createPhpRuntime(o), r = new v(l);
|
|
589
600
|
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
|
-
for (const
|
|
591
|
-
r.defineConstant(
|
|
601
|
+
for (const c in t.constants)
|
|
602
|
+
r.defineConstant(c, t.constants[c]);
|
|
592
603
|
return o && /**
|
|
593
604
|
* Only the first PHP instance of the first worker created
|
|
594
605
|
* during WordPress boot writes these files – otherwise we'll keep
|
|
@@ -599,7 +610,7 @@ async function L(t) {
|
|
|
599
610
|
* mechanism. It works, because secondary workers are only booted
|
|
600
611
|
* once the primary worker has fully booted.
|
|
601
612
|
*/
|
|
602
|
-
!r.isFile("/internal/.boot-files-written") && (await
|
|
613
|
+
!r.isFile("/internal/.boot-files-written") && (await N(r), await f(r, "/", t.createFiles || {}), await F(
|
|
603
614
|
r,
|
|
604
615
|
s(new URL(t.siteUrl).pathname, "phpinfo.php")
|
|
605
616
|
), await f(r, "/internal", {
|
|
@@ -616,9 +627,9 @@ async function L(t) {
|
|
|
616
627
|
const i = new E({
|
|
617
628
|
documentRoot: t.documentRoot || "/wordpress",
|
|
618
629
|
absoluteUrl: t.siteUrl,
|
|
619
|
-
rewriteRules:
|
|
630
|
+
rewriteRules: q,
|
|
620
631
|
pathAliases: t.pathAliases,
|
|
621
|
-
getFileNotFoundAction: t.getFileNotFoundAction ??
|
|
632
|
+
getFileNotFoundAction: t.getFileNotFoundAction ?? O,
|
|
622
633
|
cookieStore: t.cookieStore,
|
|
623
634
|
/**
|
|
624
635
|
* If maxPhpInstances is 1, the PHPRequestHandler constructor needs
|
|
@@ -714,13 +725,13 @@ async function h(t) {
|
|
|
714
725
|
}
|
|
715
726
|
})).text !== "1" && g.warn("Failed to default to pretty permalinks after WP install.");
|
|
716
727
|
}
|
|
717
|
-
function
|
|
728
|
+
function O(t) {
|
|
718
729
|
return {
|
|
719
730
|
type: "internal-redirect",
|
|
720
731
|
uri: "/index.php"
|
|
721
732
|
};
|
|
722
733
|
}
|
|
723
|
-
function
|
|
734
|
+
function A(t) {
|
|
724
735
|
const e = s(t.documentRoot, "wp-config.php");
|
|
725
736
|
if (!t.isFile(e)) return !1;
|
|
726
737
|
const n = t.readFileAsText(e), i = n.match(
|
|
@@ -730,7 +741,7 @@ function O(t) {
|
|
|
730
741
|
);
|
|
731
742
|
return !i || !a ? !1 : i[1] !== "database_name_here" && a[1] !== "username_here";
|
|
732
743
|
}
|
|
733
|
-
async function
|
|
744
|
+
async function W(t) {
|
|
734
745
|
return (await t.run({
|
|
735
746
|
code: `<?php
|
|
736
747
|
ob_start();
|
|
@@ -749,7 +760,7 @@ async function A(t) {
|
|
|
749
760
|
}
|
|
750
761
|
})).text === "1";
|
|
751
762
|
}
|
|
752
|
-
async function
|
|
763
|
+
async function Y(t) {
|
|
753
764
|
const { php: e, reap: n } = await t.instanceManager.acquirePHPInstance();
|
|
754
765
|
try {
|
|
755
766
|
const a = (await e.run({
|
|
@@ -760,12 +771,12 @@ async function Z(t) {
|
|
|
760
771
|
})).text;
|
|
761
772
|
if (!a)
|
|
762
773
|
throw new Error("Unable to read loaded WordPress version.");
|
|
763
|
-
return
|
|
774
|
+
return U(a);
|
|
764
775
|
} finally {
|
|
765
776
|
n();
|
|
766
777
|
}
|
|
767
778
|
}
|
|
768
|
-
function
|
|
779
|
+
function U(t) {
|
|
769
780
|
if (/-(alpha|beta|RC)\d*-\d+$/.test(t))
|
|
770
781
|
return "trunk";
|
|
771
782
|
if (/-(beta|RC)\d*$/.test(t))
|
|
@@ -773,7 +784,7 @@ function W(t) {
|
|
|
773
784
|
const i = t.match(/^(\d+\.\d+)(?:\.\d+)?$/);
|
|
774
785
|
return i !== null ? i[1] : t;
|
|
775
786
|
}
|
|
776
|
-
const
|
|
787
|
+
const q = [
|
|
777
788
|
/**
|
|
778
789
|
* Substitutes the multisite WordPress rewrite rule:
|
|
779
790
|
*
|
|
@@ -789,7 +800,7 @@ const U = [
|
|
|
789
800
|
replacement: "$2"
|
|
790
801
|
}
|
|
791
802
|
];
|
|
792
|
-
async function
|
|
803
|
+
async function N(t) {
|
|
793
804
|
await t.mkdir("/internal/shared/mu-plugins"), await t.writeFile(
|
|
794
805
|
"/internal/shared/preload/env.php",
|
|
795
806
|
`<?php
|
|
@@ -1148,7 +1159,7 @@ async function F(t, e = "/phpinfo.php") {
|
|
|
1148
1159
|
`
|
|
1149
1160
|
);
|
|
1150
1161
|
}
|
|
1151
|
-
async function
|
|
1162
|
+
async function D(t, e) {
|
|
1152
1163
|
await t.isDir("/tmp/sqlite-database-integration") && await t.rmdir("/tmp/sqlite-database-integration", {
|
|
1153
1164
|
recursive: !0
|
|
1154
1165
|
}), await t.mkdir("/tmp/sqlite-database-integration"), await p(t, e, "/tmp/sqlite-database-integration");
|
|
@@ -1162,13 +1173,13 @@ async function N(t, e) {
|
|
|
1162
1173
|
).replace(
|
|
1163
1174
|
"'{SQLITE_PLUGIN}'",
|
|
1164
1175
|
d(s(n, "load.php"))
|
|
1165
|
-
),
|
|
1176
|
+
), l = s(await t.documentRoot, "wp-content/db.php"), r = `<?php
|
|
1166
1177
|
// Do not preload this if WordPress comes with a custom db.php file.
|
|
1167
|
-
if(file_exists(${d(
|
|
1178
|
+
if(file_exists(${d(l)})) {
|
|
1168
1179
|
return;
|
|
1169
1180
|
}
|
|
1170
|
-
?>`,
|
|
1171
|
-
await t.writeFile(
|
|
1181
|
+
?>`, c = "/internal/shared/mu-plugins/sqlite-database-integration.php";
|
|
1182
|
+
await t.writeFile(c, r + o), await t.writeFile(
|
|
1172
1183
|
"/internal/shared/preload/0-sqlite.php",
|
|
1173
1184
|
r + `<?php
|
|
1174
1185
|
|
|
@@ -1220,7 +1231,7 @@ class Playground_SQLite_Integration_Loader {
|
|
|
1220
1231
|
$GLOBALS['wpdb']->$name = $value;
|
|
1221
1232
|
}
|
|
1222
1233
|
protected function load_sqlite_integration() {
|
|
1223
|
-
require_once ${d(
|
|
1234
|
+
require_once ${d(c)};
|
|
1224
1235
|
}
|
|
1225
1236
|
}
|
|
1226
1237
|
/**
|
|
@@ -1257,7 +1268,7 @@ if(!function_exists('mysqli_connect')) {
|
|
|
1257
1268
|
`
|
|
1258
1269
|
);
|
|
1259
1270
|
}
|
|
1260
|
-
async function
|
|
1271
|
+
async function M(t, e) {
|
|
1261
1272
|
t.mkdir("/tmp/unzipped-wordpress"), await p(t, e, "/tmp/unzipped-wordpress"), t.fileExists("/tmp/unzipped-wordpress/wordpress.zip") && await p(
|
|
1262
1273
|
t,
|
|
1263
1274
|
"/tmp/unzipped-wordpress/wordpress.zip",
|
|
@@ -1273,14 +1284,14 @@ async function D(t, e) {
|
|
|
1273
1284
|
) && (n = s(n, o));
|
|
1274
1285
|
}
|
|
1275
1286
|
}
|
|
1276
|
-
const i = (a, o,
|
|
1277
|
-
if (
|
|
1278
|
-
for (const r of
|
|
1279
|
-
const
|
|
1280
|
-
i(
|
|
1287
|
+
const i = (a, o, l) => {
|
|
1288
|
+
if (l.isDir(a) && l.isDir(o))
|
|
1289
|
+
for (const r of l.listFiles(a)) {
|
|
1290
|
+
const c = s(a, r), k = s(o, r);
|
|
1291
|
+
i(c, k, l);
|
|
1281
1292
|
}
|
|
1282
1293
|
else {
|
|
1283
|
-
if (
|
|
1294
|
+
if (l.fileExists(o)) {
|
|
1284
1295
|
const r = a.replace(
|
|
1285
1296
|
/^\/tmp\/unzipped-wordpress\//,
|
|
1286
1297
|
"/"
|
|
@@ -1290,7 +1301,7 @@ async function D(t, e) {
|
|
|
1290
1301
|
);
|
|
1291
1302
|
return;
|
|
1292
1303
|
}
|
|
1293
|
-
|
|
1304
|
+
l.mv(a, o);
|
|
1294
1305
|
}
|
|
1295
1306
|
};
|
|
1296
1307
|
i(n, t.documentRoot, t), t.fileExists(n) && t.rmdir(n, { recursive: !0 }), !t.fileExists(s(t.documentRoot, "wp-config.php")) && t.fileExists(s(t.documentRoot, "wp-config-sample.php")) && t.writeFile(
|
|
@@ -1300,8 +1311,8 @@ async function D(t, e) {
|
|
|
1300
1311
|
)
|
|
1301
1312
|
);
|
|
1302
1313
|
}
|
|
1303
|
-
const
|
|
1304
|
-
async function
|
|
1314
|
+
const G = P(fetch), H = "https://github.com/WordPress/WordPress/archive/refs/heads/master.zip";
|
|
1315
|
+
async function K(t = "latest") {
|
|
1305
1316
|
if (t === null)
|
|
1306
1317
|
t = "latest";
|
|
1307
1318
|
else if (t.startsWith("https://") || t.startsWith("http://")) {
|
|
@@ -1317,12 +1328,12 @@ async function Y(t = "latest") {
|
|
|
1317
1328
|
} else if (t === "trunk" || t === "nightly") {
|
|
1318
1329
|
const i = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
1319
1330
|
return {
|
|
1320
|
-
releaseUrl: `${
|
|
1331
|
+
releaseUrl: `${H}?ts=${i}`,
|
|
1321
1332
|
version: "trunk",
|
|
1322
1333
|
source: "inferred"
|
|
1323
1334
|
};
|
|
1324
1335
|
}
|
|
1325
|
-
let n = await (await
|
|
1336
|
+
let n = await (await G(
|
|
1326
1337
|
"https://api.wordpress.org/core/version-check/1.7/?channel=beta"
|
|
1327
1338
|
)).json();
|
|
1328
1339
|
n = n.offers.filter(
|
|
@@ -1355,19 +1366,19 @@ async function Y(t = "latest") {
|
|
|
1355
1366
|
};
|
|
1356
1367
|
}
|
|
1357
1368
|
export {
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1369
|
+
C as bootRequestHandler,
|
|
1370
|
+
L as bootWordPress,
|
|
1371
|
+
Z as bootWordPressAndRequestHandler,
|
|
1372
|
+
V as defineWpConfigConstants,
|
|
1362
1373
|
I as ensureWpConfig,
|
|
1363
|
-
|
|
1364
|
-
|
|
1374
|
+
O as getFileNotFoundActionForWordPress,
|
|
1375
|
+
Y as getLoadedWordPressVersion,
|
|
1365
1376
|
F as preloadPhpInfoRoute,
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1377
|
+
D as preloadSqliteIntegration,
|
|
1378
|
+
K as resolveWordPressRelease,
|
|
1379
|
+
N as setupPlatformLevelMuPlugins,
|
|
1380
|
+
M as unzipWordPress,
|
|
1381
|
+
U as versionStringToLoadedWordPressVersion,
|
|
1382
|
+
q as wordPressRewriteRules
|
|
1372
1383
|
};
|
|
1373
1384
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/wordpress",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.19",
|
|
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": "be542ee28a5966eeb28154cd8e3723db5ff9df07",
|
|
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.19",
|
|
49
|
+
"@php-wasm/util": "3.1.19",
|
|
50
|
+
"@php-wasm/logger": "3.1.19",
|
|
51
|
+
"@wp-playground/common": "3.1.19",
|
|
52
|
+
"@php-wasm/node": "3.1.19"
|
|
53
53
|
},
|
|
54
54
|
"packageManager": "npm@10.9.2",
|
|
55
55
|
"overrides": {
|
package/wp-config.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { UniversalPHP } from '@php-wasm/universal';
|
|
2
2
|
/**
|
|
3
|
-
* Ensures that
|
|
3
|
+
* Ensures that "wp-config.php" exists and required constants are defined.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* - Copies "wp-config-sample.php" to "wp-config.php" if it doesn't exist.
|
|
6
|
+
* - Defines fallback values for missing constants without modifying "wp-config.php".
|
|
6
7
|
*
|
|
7
8
|
* @param php The PHP instance.
|
|
8
9
|
* @param documentRoot The path to the document root.
|