@wp-playground/wordpress 0.9.27 → 0.9.28

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.
Files changed (2) hide show
  1. package/index.js +16 -5
  2. package/package.json +6 -6
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{joinPaths as o,phpVar as s}from"@php-wasm/util";import{unzipFile as l}from"@wp-playground/common";import{PHPRequestHandler as c,withPHPIniValues as f,PHP as w,setPhpIniEntries as g,writeFiles as _,proxyFileSystem as m,rotatePHPRuntime as h}from"@php-wasm/universal";async function T(e){async function r(i,d){const n=new w(await e.createPhpRuntime());return e.sapiName&&n.setSapiName(e.sapiName),i&&(n.requestHandler=i),e.phpIniEntries&&g(n,e.phpIniEntries),d?(await L(n),await _(n,"/",e.createFiles||{}),await E(n,o(new URL(e.siteUrl).pathname,"phpinfo.php"))):m(await i.getPrimaryPhp(),n,["/tmp",i.documentRoot,"/internal/shared"]),e.spawnHandler&&await n.setSpawnHandler(e.spawnHandler(i.processManager)),h({php:n,cwd:i.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),n}const a=new c({phpFactory:async({isPrimary:i})=>r(a,i),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:y,getFileNotFoundAction:e.getFileNotFoundAction??P}),t=await a.getPrimaryPhp();if(e.hooks?.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(t),e.wordPressZip&&await R(t,await e.wordPressZip),e.constants)for(const i in e.constants)t.defineConstant(i,e.constants[i]);if(t.defineConstant("WP_HOME",e.siteUrl),t.defineConstant("WP_SITEURL",e.siteUrl),e.hooks?.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(t),e.sqliteIntegrationPluginZip&&await S(t,await e.sqliteIntegrationPluginZip),await u(t)||await $(t),!await u(t))throw new Error("WordPress installation has failed.");return a}async function u(e){return(await e.run({code:`<?php
1
+ import{joinPaths as o,phpVar as s}from"@php-wasm/util";import{unzipFile as l}from"@wp-playground/common";import{PHPRequestHandler as c,withPHPIniValues as f,PHP as w,setPhpIniEntries as g,writeFiles as _,proxyFileSystem as m,rotatePHPRuntime as h}from"@php-wasm/universal";async function T(e){async function a(i,d){const n=new w(await e.createPhpRuntime());return e.sapiName&&n.setSapiName(e.sapiName),i&&(n.requestHandler=i),e.phpIniEntries&&g(n,e.phpIniEntries),d?(await L(n),await _(n,"/",e.createFiles||{}),await E(n,o(new URL(e.siteUrl).pathname,"phpinfo.php"))):m(await i.getPrimaryPhp(),n,["/tmp",i.documentRoot,"/internal/shared"]),e.spawnHandler&&await n.setSpawnHandler(e.spawnHandler(i.processManager)),h({php:n,cwd:i.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),n}const r=new c({phpFactory:async({isPrimary:i})=>a(r,i),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:y,getFileNotFoundAction:e.getFileNotFoundAction??P}),t=await r.getPrimaryPhp();if(e.hooks?.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(t),e.wordPressZip&&await R(t,await e.wordPressZip),e.constants)for(const i in e.constants)t.defineConstant(i,e.constants[i]);if(t.defineConstant("WP_HOME",e.siteUrl),t.defineConstant("WP_SITEURL",e.siteUrl),e.hooks?.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(t),e.sqliteIntegrationPluginZip&&await S(t,await e.sqliteIntegrationPluginZip),await u(t)||await $(t),!await u(t))throw new Error("WordPress installation has failed.");return r}async function u(e){return(await e.run({code:`<?php
2
2
  require '${e.documentRoot}/wp-load.php';
3
3
  echo is_blog_installed() ? '1' : '0';
4
4
  `})).text==="1"}async function $(e){await f(e,{disable_functions:"fsockopen",allow_url_fopen:"0"},async()=>await e.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"}}))}function P(e){return{type:"internal-redirect",uri:"/index.php"}}async function x(e){const t=(await(await e.getPrimaryPhp()).run({code:`<?php
@@ -61,6 +61,17 @@ import{joinPaths as o,phpVar as s}from"@php-wasm/util";import{unzipFile as l}fro
61
61
  $playground_consts = array_keys($playground_consts);
62
62
  }
63
63
  set_error_handler(function($severity, $message, $file, $line) use($playground_consts) {
64
+ /**
65
+ * We're forced to use this deprecated hook to ensure SSL operations work without
66
+ * the kitchen-sink bundled. See https://github.com/WordPress/wordpress-playground/pull/1504
67
+ * for more context.
68
+ */
69
+ if (
70
+ strpos($message, "Hook http_api_transports is deprecated") !== false ||
71
+ strpos($message, "Hook http_api_transports is <strong>deprecated</strong>") !== false
72
+ ) {
73
+ return;
74
+ }
64
75
  /**
65
76
  * This is a temporary workaround to hide the 32bit integer warnings that
66
77
  * appear when using various time related function, such as strtotime and mktime.
@@ -100,13 +111,13 @@ import{joinPaths as o,phpVar as s}from"@php-wasm/util";import{unzipFile as l}fro
100
111
  }
101
112
  return false;
102
113
  });
103
- })();`)}async function E(e,r="/phpinfo.php"){await e.writeFile("/internal/shared/preload/phpinfo.php",`<?php
114
+ })();`)}async function E(e,a="/phpinfo.php"){await e.writeFile("/internal/shared/preload/phpinfo.php",`<?php
104
115
  // Render PHPInfo if the requested page is /phpinfo.php
105
- if ( ${s(r)} === $_SERVER['REQUEST_URI'] ) {
116
+ if ( ${s(a)} === $_SERVER['REQUEST_URI'] ) {
106
117
  phpinfo();
107
118
  exit;
108
119
  }
109
- `)}async function S(e,r){await e.isDir("/tmp/sqlite-database-integration")&&await e.rmdir("/tmp/sqlite-database-integration",{recursive:!0}),await e.mkdir("/tmp/sqlite-database-integration"),await l(e,r,"/tmp/sqlite-database-integration");const a="/internal/shared/sqlite-database-integration";await e.mv("/tmp/sqlite-database-integration/sqlite-database-integration-main",a),await e.defineConstant("SQLITE_MAIN_FILE","1");const i=(await e.readFileAsText(o(a,"db.copy"))).replace("'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",s(a)).replace("'{SQLITE_PLUGIN}'",s(o(a,"load.php"))),d=o(await e.documentRoot,"wp-content/db.php"),n=`<?php
120
+ `)}async function S(e,a){await e.isDir("/tmp/sqlite-database-integration")&&await e.rmdir("/tmp/sqlite-database-integration",{recursive:!0}),await e.mkdir("/tmp/sqlite-database-integration"),await l(e,a,"/tmp/sqlite-database-integration");const r="/internal/shared/sqlite-database-integration";await e.mv("/tmp/sqlite-database-integration/sqlite-database-integration-main",r),await e.defineConstant("SQLITE_MAIN_FILE","1");const i=(await e.readFileAsText(o(r,"db.copy"))).replace("'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",s(r)).replace("'{SQLITE_PLUGIN}'",s(o(r,"load.php"))),d=o(await e.documentRoot,"wp-content/db.php"),n=`<?php
110
121
  // Do not preload this if WordPress comes with a custom db.php file.
111
122
  if(file_exists(${s(d)})) {
112
123
  return;
@@ -183,4 +194,4 @@ if(!function_exists('mysqli_connect')) {
183
194
  var_dump(isset($wpdb));
184
195
  die("SQLite integration not loaded " . get_class($wpdb));
185
196
  }
186
- `)}async function R(e,r){e.mkdir("/tmp/unzipped-wordpress"),await l(e,r,"/tmp/unzipped-wordpress"),e.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await l(e,"/tmp/unzipped-wordpress/wordpress.zip","/tmp/unzipped-wordpress");const a=e.fileExists("/tmp/unzipped-wordpress/wordpress")?"/tmp/unzipped-wordpress/wordpress":e.fileExists("/tmp/unzipped-wordpress/build")?"/tmp/unzipped-wordpress/build":"/tmp/unzipped-wordpress";e.mv(a,e.documentRoot),!e.fileExists(o(e.documentRoot,"wp-config.php"))&&e.fileExists(o(e.documentRoot,"wp-config-sample.php"))&&e.writeFile(o(e.documentRoot,"wp-config.php"),e.readFileAsText(o(e.documentRoot,"/wp-config-sample.php")))}export{T as bootWordPress,P as getFileNotFoundActionForWordPress,x as getLoadedWordPressVersion,E as preloadPhpInfoRoute,S as preloadSqliteIntegration,L as setupPlatformLevelMuPlugins,R as unzipWordPress,b as versionStringToLoadedWordPressVersion,y as wordPressRewriteRules};
197
+ `)}async function R(e,a){e.mkdir("/tmp/unzipped-wordpress"),await l(e,a,"/tmp/unzipped-wordpress"),e.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await l(e,"/tmp/unzipped-wordpress/wordpress.zip","/tmp/unzipped-wordpress");const r=e.fileExists("/tmp/unzipped-wordpress/wordpress")?"/tmp/unzipped-wordpress/wordpress":e.fileExists("/tmp/unzipped-wordpress/build")?"/tmp/unzipped-wordpress/build":"/tmp/unzipped-wordpress";e.mv(r,e.documentRoot),!e.fileExists(o(e.documentRoot,"wp-config.php"))&&e.fileExists(o(e.documentRoot,"wp-config-sample.php"))&&e.writeFile(o(e.documentRoot,"wp-config.php"),e.readFileAsText(o(e.documentRoot,"/wp-config-sample.php")))}export{T as bootWordPress,P as getFileNotFoundActionForWordPress,x as getLoadedWordPressVersion,E as preloadPhpInfoRoute,S as preloadSqliteIntegration,L as setupPlatformLevelMuPlugins,R as unzipWordPress,b as versionStringToLoadedWordPressVersion,y as wordPressRewriteRules};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-playground/wordpress",
3
- "version": "0.9.27",
3
+ "version": "0.9.28",
4
4
  "description": "WordPress-related plumbing for WordPress Playground",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,16 +28,16 @@
28
28
  "access": "public",
29
29
  "directory": "../../../dist/packages/playground/wordpress"
30
30
  },
31
- "gitHead": "a0856a3e94aec6e95add6e828d66cc90ff47ff95",
31
+ "gitHead": "15d87898b0a7f8a0cf322425923336df1d84843b",
32
32
  "dependencies": {
33
33
  "comlink": "^4.4.1",
34
34
  "express": "4.19.2",
35
35
  "ini": "4.1.2",
36
36
  "ws": "8.18.0",
37
37
  "yargs": "17.7.2",
38
- "@php-wasm/universal": "0.9.27",
39
- "@php-wasm/util": "0.9.27",
40
- "@wp-playground/common": "0.9.27",
41
- "@php-wasm/node": "0.9.27"
38
+ "@php-wasm/universal": "0.9.28",
39
+ "@php-wasm/util": "0.9.28",
40
+ "@wp-playground/common": "0.9.28",
41
+ "@php-wasm/node": "0.9.28"
42
42
  }
43
43
  }