playground-tools icon indicating copy to clipboard operation
playground-tools copied to clipboard

Playground plugin: Unable to start a sandbox

Open ironnysh opened this issue 1 year ago • 19 comments

Hi, I'm trying to use the Start a sandbox option of the plugin, and ran into a few errors:

  1. First, there was #208, so I added https://playground.wordpress.net/ to my CSP: ✅

  2. Then, I got this: Error: Could not download "https://MYDOMAIN/wp-admin/admin.php?page=playground&download=1".

    • I changed the path in this line from admin_url('admin.php?page=' . PLAYGROUND_ADMIN_PAGE_SLUG), replacing admin.php with tools.php: ✅
  3. Finally, I got a new error: Error: Could not read "/wordpress/schema/_Schema.sql": There is no such file or directory OR the parent directory does not exist.

Not sure how to solve this one :-)

ironnysh avatar Apr 03 '24 13:04 ironnysh

Just to make sure – are you using the latest v0.0.3 release? https://github.com/WordPress/playground-tools/releases/tag/v0.0.3

Looping in @bgrgicak

adamziel avatar Apr 03 '24 16:04 adamziel

Hi @adamziel, apologies: I missed the notification... I was using a version that said 0.0.4 (before this commit).

So, I downloaded and installed v0.0.3 linked in your comment above, and got a new error: Refused to load blob:https://MYDOMAIN/27719ee4-d593-44c7-9758-327a8181aba1 because it does not appear in the worker-src directive of the Content Security Policy.

I updated the plugin to 0.1.0 (via the WordPress admin), and then the site broke—got "the white screen of death" :-) That's what it says in the error_log file:

[05-Apr-2024 09:17:58 UTC] PHP Warning:  require(/home/MYUSER/MYDOMAIN/wp-content/plugins/playground/src/playground-export.php): Failed to open stream: No such file or directory in /home/MYUSER/MYDOMAIN/wp-content/plugins/playground/playground.php on line 29
[05-Apr-2024 09:17:58 UTC] PHP Fatal error:  Uncaught Error: Failed opening required '/home/MYUSER/MYDOMAIN/wp-content/plugins/playground/src/playground-export.php' (include_path='.:/opt/alt/php80/usr/share/pear:/opt/alt/php80/usr/share/php:/usr/share/pear:/usr/share/php') in /home/MYUSER/MYDOMAIN/wp-content/plugins/playground/playground.php:29
Stack trace:
#0 /home/MYUSER/MYDOMAIN/wp-settings.php(517): include_once()
#1 /home/MYUSER/MYDOMAIN/wp-config.php(100): require_once('/home/MYUSER/...')
#2 /home/MYUSER/MYDOMAIN/wp-load.php(50): require_once('/home/MYUSER/...')
#3 /home/MYUSER/MYDOMAIN/wp-blog-header.php(13): require_once('/home/MYUSER/...')
#4 /home/MYUSER/MYDOMAIN/index.php(17): require('/home/MYUSER/...')
#5 {main}
  thrown in /home/MYUSER/MYDOMAIN/wp-content/plugins/playground/playground.php on line 29

I'm on WordPress 6.5, PHP 8.3.

ironnysh avatar Apr 05 '24 09:04 ironnysh

@ironnysh could you please update to 0.1.1? I forgot to add a file to the latest version and it should be fixed now.

bgrgicak avatar Apr 05 '24 10:04 bgrgicak

Alright, it's working on my local machine. I wonder if it has something to do with the fact that my live site is running in a sub-folder (...MYDOMAIN/wptests...)

ironnysh avatar Apr 05 '24 10:04 ironnysh

@bgrgicak, yay! It doesn't "brake" the site :-)

However, when I go into Tools > Sandbox Site I see a clean install. My changes aren't reflected there. The console still shows the error I got before: Error: Could not read "/wordpress/schema/_Schema.sql": There is no such file or directory OR the parent directory does not exist.

ironnysh avatar Apr 05 '24 10:04 ironnysh

yay! It doesn't "brake" the site :-)

Sorry about that :sweat:

Error: Could not read "/wordpress/schema/_Schema.sql": There is no such file or directory OR the parent directory does not exist.

This error means the SQL export failed. Do you have any errors in your debug.log?

bgrgicak avatar Apr 05 '24 11:04 bgrgicak

So, latest update :-)

  1. No more error message when running the latest version of the plugin (from the directory).

  2. When I click Tools > Sandbox Site on the live, sub-folder-based site (...MYDOMAIN/wptests...), I get a clean install. My changes aren't reflected.

  3. When I click Tools > Sandbox Site on the live, non sub-folder site, everything works as expected (I got a bunch of other errors, but they might be related to the specific setup I have)

ironnysh avatar Apr 05 '24 12:04 ironnysh

Thank you for all your feedback, I really appreciate it!

TBH I never tested sites in subfolders. I can take a look at it next week.

bgrgicak avatar Apr 05 '24 12:04 bgrgicak

Sure thing :-)

No rush... I was just curious about the plugin, so installed it on my experiments site.

ironnysh avatar Apr 05 '24 12:04 ironnysh

Start a sandbox option of the plugin

@ironnysh can you please link to this info? I've been in the docs for almost a week straight and hadn't seen the option for sandbox mode and want to know how it works! Thanks for all you are doing in the space!

flexseth avatar Apr 05 '24 22:04 flexseth

Hey @flexseth, it's a feature of the new Playground plugin, which I'm guessing isn't documented yet.

Ditto ;-)

ironnysh avatar Apr 06 '24 08:04 ironnysh

Hey @flexseth, it's a feature of the new Playground plugin, which I'm guessing isn't documented yet.

Ditto ;-)

Wow I've been working on the Playground docs for a week straight now and still find new things :)

Adding it to the list of things to document, a good candidate for the Yoast Contributor Day on April 18th!

flexseth avatar Apr 09 '24 19:04 flexseth

Tagging Yoast Online Contributor Day to get this mentioned as an issue over there!

  • https://github.com/WordPress/wordpress-playground/issues/1185

flexseth avatar Apr 11 '24 21:04 flexseth

@ironnysh would you have time to take a look at this? I'm not sure when I would be able to prioritize it.

bgrgicak avatar May 17 '24 08:05 bgrgicak

Hi @bgrgicak, sorry for my late response.

Are we talking about the issue itself or the addition to the documentation? :-)

ironnysh avatar May 21 '24 15:05 ironnysh

I was thinking of the issue When I click Tools > Sandbox Site on the live, sub-folder-based site (...MYDOMAIN/wptests...), I get a clean install. My changes aren't reflected.

bgrgicak avatar May 22 '24 03:05 bgrgicak

@bgrgicak --I ran another test of the “sub-folder site” in an Incognito window.

  • The themes and plugins are there, but none is activated.
  • The posts, pages, and media aren't there.
  • Changes I make in the Settings menu (wp-admin/options-xxx.php) aren't reflected.

The only error I see in the console is this: index.js:311 [22-May-2024 14:43:01 UTC] PHP Deprecated: http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated in /internal/shared/mu-plugins/playground-includes/wp_http_fetch.php on line 53

ironnysh avatar May 22 '24 14:05 ironnysh

index.js:311 [22-May-2024 14:43:01 UTC] PHP Deprecated: http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated in /internal/shared/mu-plugins/playground-includes/wp_http_fetch.php on line 53

This error was fixed today https://github.com/WordPress/wordpress-playground/pull/1458 Would you mind taking another look?

What PHP version is that server using?

bgrgicak avatar May 23 '24 06:05 bgrgicak

I still see this error.

After adding this to the CSP: worker-src 'self' blob:

I get hundreds of duplicated JS errors (they weren't there before, and fire after the Sandbox tries to execute the SQL):

Event handler of <some> event must be added on the initial evaluation of worker script.
sw.js:53 Event handler of 'message' event must be added on the initial evaluation of worker script.
(anonymous) @ sw.js:53
awaitReply @ sw.js:53
getScopedWpDetails @ sw.js:97
await in getScopedWpDetails (async)
n @ sw.js:53
handleRequest @ sw.js:53
(anonymous) @ sw.js:53

sw.js:53 Event handler of 'message' event must be added on the initial evaluation of worker script.
(anonymous) @ sw.js:53
awaitReply @ sw.js:53
convertFetchEventToPHPRequest @ sw.js:53
await in convertFetchEventToPHPRequest (async)
n @ sw.js:53
await in n (async)
handleRequest @ sw.js:53
(anonymous) @ sw.js:53

What PHP version is that server using?

8.3.

ironnysh avatar May 23 '24 09:05 ironnysh