WordPress / playground-tools

GNU General Public License v2.0
138 stars 39 forks source link

Playground plugin: Unable to start a sandbox #213

Open ironnysh opened 6 months ago

ironnysh commented 6 months ago

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 :-)

adamziel commented 6 months ago

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

ironnysh commented 5 months ago

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.

bgrgicak commented 5 months ago

@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.

ironnysh commented 5 months ago

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 commented 5 months ago

@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.

bgrgicak commented 5 months ago

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?

ironnysh commented 5 months ago

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)

bgrgicak commented 5 months ago

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.

ironnysh commented 5 months ago

Sure thing :-)

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

flexseth commented 5 months ago

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!

ironnysh commented 5 months ago

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

Ditto ;-)

flexseth commented 5 months ago

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 commented 5 months ago

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

bgrgicak commented 4 months ago

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

ironnysh commented 4 months ago

Hi @bgrgicak, sorry for my late response.

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

bgrgicak commented 4 months ago

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.

ironnysh commented 4 months ago

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

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

bgrgicak commented 4 months ago

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?

ironnysh commented 4 months ago

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.