Skip to content

Update Playground and PHP-wasm packages to 1.0.27 - #959

Merged
bgrgicak merged 7 commits into
trunkfrom
update/playground-and-phpwasm-packages-to-v1.0.27
Feb 28, 2025
Merged

Update Playground and PHP-wasm packages to 1.0.27#959
bgrgicak merged 7 commits into
trunkfrom
update/playground-and-phpwasm-packages-to-v1.0.27

Conversation

@bgrgicak

@bgrgicak bgrgicak commented Feb 20, 2025

Copy link
Copy Markdown
Contributor

Related issues

Proposed Changes

  • Update @wp-playground and @php-wasm packages to the latest version
  • Remove cookie polyfill as the feature was implemented in Playground
  • Remove DNS mu-plugin as the feature was implemented in Playground
  • Add Jest mocks for fetch and crypto.subtle.generateKey

Testing Instructions

  • CI

Manual testing

  • Run npm install && npm start
  • Test critical flows
    • starting a site
    • run a CLI command
    • export/import site
    • sync to WP.com

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@bgrgicak

bgrgicak commented Feb 20, 2025

Copy link
Copy Markdown
Contributor Author

TODO:

@bgrgicak
bgrgicak marked this pull request as ready for review February 25, 2025 08:44
@bgrgicak

Copy link
Copy Markdown
Contributor Author

I tested Total and free size of filesystem reported in sites doesn't match actual values and it won't be fixed by this update.

@wojtekn would you prefer for me to focus on Total and free size of filesystem or WebAssembly.instantiate(): Out of memory?

@wojtekn

wojtekn commented Feb 26, 2025

Copy link
Copy Markdown
Contributor

I tested #341 and it won't be fixed by this update.

Does it mean that the Emscripten fix didn't help? Or that it's not included in 1.0.27?

@wojtekn would you prefer for me to focus on Total and free size of filesystem or https://github.com/Automattic/dotcom-forge/issues/8308#issuecomment-2639451259?

Sounds like a good next issue 👍

@bgrgicak

Copy link
Copy Markdown
Contributor Author

Does it mean that the Emscripten fix didn't help? Or that it's not included in 1.0.27?

The fix didn't work, but I don't know exactly why. The patch we added to Emscripten was used to build Playground.
I assume this is related to PHP-wasm Node and not Emscripten anymore, but I need to do some research first to confirm that.

@wojtekn wojtekn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I couldn't find any issues. I checked, among other things:

  • Studio site working through Ngrok tunnel
  • WP Admin auto-login
  • Signing in to multiple Studio sites at once
  • Switching PHP versions for Studio site
// Polyfill for DNS features which are not currently supported by @php-wasm/node.
// See https://github.com/WordPress/wordpress-playground/issues/1042
// These specific features are polyfilled so the Jetpack plugin loads correctly, but others should be added as needed.
if ( ! defined( 'DNS_NS' ) ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was added in Playground, correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we added it in Playground. I also tested it locally to make sure.

@@ -1,10 +0,0 @@
diff --git a/node_modules/@php-wasm/universal/index.cjs b/node_modules/@php-wasm/universal/index.cjs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are removing the patch that was added in #532 and setting the cookieStore to false as we don't want to use Playground cookie store for Playground running from CLI. This allows the browser to manage the cookies.

@bgrgicak
bgrgicak merged commit eae94f9 into trunk Feb 28, 2025
@bgrgicak
bgrgicak deleted the update/playground-and-phpwasm-packages-to-v1.0.27 branch February 28, 2025 09:29
@ivan-ottinger

Copy link
Copy Markdown
Contributor

I have manually tested the changes and haven't found any regressions. 👌🏼

Tested the following:

  • WordPress.com push / pull
  • export / import
  • creating, staring and stopping sites
  • logging into WP Admin
  • changing PHP version
  • creating / updating preview sites

@sejas sejas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested core Studio features and confirmed that the start, stop, auto-login, image upload, permalinks, and site creation functions are all working as expected.

Thanks for upgrading the Playground dependencies and using the A8C repo.

Comment thread jest-setup.ts
Comment on lines +34 to +36
Object.defineProperty( global.crypto, 'subtle', {
value: { generateKey: jest.fn() },
} );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is another solution mentioned on jsdom/jsdom#1612, and I can confirm that it works correctly and all tests pass.

import { webcrypto } from 'node:crypto';
...
Object.defineProperty( globalThis, 'crypto', {
	value: webcrypto,
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants