Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error because of lack of cURL and allow_url_fopen #1008

Closed
jdevalk opened this issue Feb 6, 2024 · 7 comments · Fixed by #1935
Closed

Error because of lack of cURL and allow_url_fopen #1008

jdevalk opened this issue Feb 6, 2024 · 7 comments · Fixed by #1935
Labels
[Feature] PHP.wasm [Type] Enhancement New feature or request [Type] Reliability Playground uptime, reliability, not crashing

Comments

@jdevalk
Copy link
Contributor

jdevalk commented Feb 6, 2024

When you try to use the Plausible WordPress plugin on the WordPress playground, you get the following fatal error:

Fatal error: Uncaught RuntimeException: Plausible\Analytics\WP\Client\Lib\GuzzleHttp requires cURL, the allow_url_fopen ini setting, or a custom HTTP handler. in /wordpress/wp-content/plugins/plausible-analytics/src/Client/lib/Lib/GuzzleHttp/Utils.php:105 Stack trace:
#0 /wordpress/wp-content/plugins/plausible-analytics/src/Client/lib/Lib/GuzzleHttp/HandlerStack.php(49): Plausible\Analytics\WP\Client\Lib\GuzzleHttp\Utils::chooseHandler()
#1 /wordpress/wp-content/plugins/plausible-analytics/src/Client/lib/Lib/GuzzleHttp/Client.php(53): Plausible\Analytics\WP\Client\Lib\GuzzleHttp\HandlerStack::create()
#2 /wordpress/wp-content/plugins/plausible-analytics/src/Client.php(36): Plausible\Analytics\WP\Client\Lib\GuzzleHttp\Client->__construct()
#3 /wordpress/wp-content/plugins/plausible-analytics/src/Admin/Provisioning.php(40): Plausible\Analytics\WP\Client->__construct()
#4 /wordpress/wp-content/plugins/plausible-analytics/src/Plugin.php(42): Plausible\Analytics\WP\Admin\Provisioning->__construct()
#5 /wordpress/wp-includes/class-wp-hook.php(3): Plausible\Analytics\WP\Plugin->register_services('')
#6 /wordpress/wp-includes/class-wp-hook.php(3): WP_Hook->apply_filters(NULL, Array)
#7 /wordpress/wp-includes/plugin.php(2): WP_Hook->do_action(Array)
#8 /wordpress/wp-settings.php(2): do_action('plugins_loaded')
#9 /wordpress/wp-config.php(99): require_once('/wordpress/wp-s...')
#10 /wordpress/wp-load.php(2): require_once('/wordpress/wp-c...')
#11 /wordpress/wp-admin/admin.php(2): require_once('/wordpress/wp-l...')
#12 /wordpress/wp-admin/index.php(2): require_once('/wordpress/wp-a...')
#13 {main} thrown in /wordpress/wp-content/plugins/plausible-analytics/src/Client/lib/Lib/GuzzleHttp/Utils.php on line 105

With networking enabled, maybe allow_url_fopen should be true?

I've also filed an issue with Plausible who should catch this fatal error.

@adamziel adamziel added [Type] Enhancement New feature or request [Feature] PHP.wasm [Type] Reliability Playground uptime, reliability, not crashing labels Feb 9, 2024
@CodyReichert
Copy link

CodyReichert commented Feb 27, 2024

I don't think I'm providing any new info here, but wanted to chime in that I have the same issue when adding a blueprint for SimplyRETS. We use curl when available or fall back to file_get_contents.

cURL isn't enabled and file_get_contents() returns the following error:

Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /wordpress/wp-content/plugins/simply-rets/simply-rets-api-helper.php on line 287

Warning: file_get_contents(https://...<url>): Failed to open stream: no suitable wrapper could be found in /wordpress/wp-content/plugins/simply-rets/simply-rets-api-helper.php on line 287

Really cool work so far though, I'm looking forward to this support.

@jcvignoli
Copy link

jcvignoli commented Mar 1, 2024

With my plugin, which also needs CuRL, I get a different message:

PHP Fatal error: Uncaught Error: Call to undefined function Imdb\curl_init() in /wordpress/wp-content/plugins/lumiere-movies/vendor/jcvignoli/imdbphp/src/Imdb/Request.php:37

Seems like php extension CuRL is missing.

@adamziel
Copy link
Collaborator

adamziel commented Mar 4, 2024

Libcurl and stream wrappers are indeed not supported at the moment. This issue explores the challenge:

#85

To bring some good news, I got a basic file_get_contents("https://mysite.com") support to work in #1051, and the technique used would unblock libcurl support, too. Note that PR is focused on another topic and needs a lot of cleaning up as it's an amalgamate of many different explorations.

@adamziel
Copy link
Collaborator

adamziel commented Mar 7, 2024

I've extracted the HTTPS support, which is a pre-requisite to supporting libcurl, to a separate PR where it can be discussed and iterated on #1093.

@mhsdef
Copy link

mhsdef commented Jun 20, 2024

Yeah, we're going to need libcurl too for heavy adoption in WPVIP.

@adamziel adamziel moved this to Future work in Playground Board Jun 30, 2024
@adamziel
Copy link
Collaborator

adamziel commented Jul 1, 2024

@mhsdef libcurl is supported in Playground CLI now, we'll update this issue once it's also available in the browser.

adamziel added a commit that referenced this issue Oct 23, 2024
Enables the CURL PHP extension on playground.wordpress.net when
networking is enabled.

The heavy lifting was done in #1926. All this PR does is:

* Enables the curl extension
* Rebuilds PHP.wasm for the web
* Enables curl_exec and curl_multiexec functions in web browsers
* Unrelated – adds a JSPI vs Asyncify indication to the SAPI name so
  that we can easily learn which PHP.wasm build Playground is running.

Related to #85
Closes #1008

 ## Testing instrucions

Confirm the new E2E tests are sound and that they work in CI. You could
also try installing a CURL-reliant plugin such as Plausible and confirm
it installs without the fatal errors reported in #1008
@adamziel
Copy link
Collaborator

Curl is available in web browsers since #1935. I've confirmed the https://wordpress.org/plugins/plausible-analytics/ plugin installs cleanly – although that might also be thanks to their work after @jdevalk reported the crash. Either way, curl is in place! The typical web CORS limitations apply as all network calls are handled using fetch() – to solve for that in the medium term, we're figuring out a generalized CORS proxy for Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] PHP.wasm [Type] Enhancement New feature or request [Type] Reliability Playground uptime, reliability, not crashing
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants