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

php_curl missing and curl_exec deactivated #181

Closed
pr0pz opened this issue May 28, 2024 · 20 comments
Closed

php_curl missing and curl_exec deactivated #181

pr0pz opened this issue May 28, 2024 · 20 comments

Comments

@pr0pz
Copy link

pr0pz commented May 28, 2024

Quick summary

After installing the Podlove plugin, I get the error message, that php_curl is not installed and curl_exec is deactivated.

Steps to reproduce

Install Podlove and reload the window - https://wordpress.org/plugins/podlove-podcasting-plugin-for-wordpress/

What you expected to happen

Expected php_curl to be installed.

What actually happened

8giwEOr0

Impact

All

Available workarounds?

No but the app is still usable

Platform

Mac Silicon M1

Logs or notes

No response

@pr0pz pr0pz added [Type] Bug Something isn't working Needs triage Ticket needs to be triaged labels May 28, 2024
@mrfoxtalbot mrfoxtalbot added Triaged and removed Needs triage Ticket needs to be triaged labels Jun 4, 2024
@mrfoxtalbot
Copy link

📌 REPRODUCTION RESULTS
– Replicated

📌 ACTIONS
– Kept priority

@jartes
Copy link

jartes commented Jun 8, 2024

We have another request on 8302777-zd-a8c

This one was for the WPVivid plugin, which requires curl PHP extension.

Copy link

github-actions bot commented Jun 8, 2024

Support References

This comment is automatically generated. Please do not edit it.

  • 8302777-zen
  • 8350827-zen
  • 8428094-zen
  • 8518441-zen

@rw-ye
Copy link

rw-ye commented Jun 18, 2024

Another report here: 8350827-zd-a8c

The user was trying to use the WPVivid plugin as well, which requires curl.

Recommended the AIOWPM plugin in the meantime for exporting from Studio.

@supernovia
Copy link

Another request here:
8428094-zd-a8c

They want to be able to use the Starter Templates Plugin, but we aren't sure yet from the messaging whether cURL is required or just suggested.

@danielbachhuber
Copy link
Contributor

Bumping this to high priority because it's a pretty egregious issue.

@ktyfuller604
Copy link

In this case, they are looking to develop a local plugin that uses cURL to extract data from an external CRM before deploying it to production.

8518441-zd-a8c

@lsl
Copy link

lsl commented Aug 14, 2024

Upstream issue about supporting libcurl in php-wasm: seanmorris/php-wasm#32

@mpkelly
Copy link

mpkelly commented Aug 21, 2024

I changed the status to "Needs core / 3rd party fix" as we're blocked here.

@akirk
Copy link
Member

akirk commented Aug 21, 2024

According to @adamziel in WordPress/wordpress-playground#1008 curl is currently only available in the CLI.

@kozer kozer assigned kozer and unassigned kozer Aug 21, 2024
@brandonpayton
Copy link
Member

brandonpayton commented Aug 21, 2024

@mpkelly Curl support was added for @php-wasm/node in (this PR)[https://github.com/WordPress/wordpress-playground/pull/1273] and included in the v0.7.2 release.

wp-now is currently using @php-wasm/node v0.6.16, which is not built with the curl extension.

@sejas has already created a draft PR for upgrading wp-now to a newer @php-wasm/node release, saying:

It will fix WEBP images, support curl and other fixes features introduced in these versions.

It's not a straightforward upgrade as various API have been changed and, in some cases, consolidated.

A couple of options are:

  1. Consider migrating Studio to using the Playground CLI if possible
  2. Update wp-now to use the latest @php-wasm/node APIs

If updating wp-now, some useful reference points are:

@kozer
Copy link
Contributor

kozer commented Aug 21, 2024

@mpkelly Curl support was added for @php-wasm/node in (this PR)[https://github.com/WordPress/wordpress-playground/pull/1273] and included in the v0.7.2 release.

wp-now is currently using @php-wasm/node v0.6.16, which is not built with the curl extension.

@sejas has already created a draft PR for upgrading wp-now to a newer @php-wasm/node release, saying:

It will fix WBEP images, support curl and other fixes features introduced in these versions.

It's not a straightforward upgrade as various API have been changed and, in some cases, consolidated.

A couple of options are:

  1. Consider migrating Studio to using the Playground CLI if possible
  2. Update wp-now to use the latest @php-wasm/node APIs

If updating wp-now, some useful reference points are:

Thank you very much for your comment!!!
I already found that, and started working on upgrading wp-now.
I tested also spinning a site with playground-cli and found that the problem isn't there. ( And this is what made me trying to start upgrading wp-now. )

Problem is, that studio's wp-now has changes in comparison to what we have in wordpress/playground-tools repo, so it will be easier to just apply how playground-cli handle things in our wp-now version, as it's a relative small part that will be affected ( startWPNow function and how php instantiation is happening in there.).

Finally, I think that updating wp-now it will be good, as it will benefit wp-now in playground-tools repo as well ( we will apply the changes in there as well )

cc: @wojtekn

@brandonpayton
Copy link
Member

Finally, I think that updating wp-now it will be good, as it will benefit wp-now in playground-tools repo as well ( we will apply the changes in there as well )

Thanks for mentioning and working on this! That will be great for existing wp-now users.

@sejas
Copy link
Member

sejas commented Sep 2, 2024

CURL was fixed by upgrading the Playground dependencies on #491 🥳
It will be included in Studio in the next version.

I tested it in trunk with the following code:

function sendCurlRequest($url) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    $response = curl_exec($ch);

    if (curl_errno($ch)) {
        echo 'Curl error: ' . curl_error($ch);
    }

    curl_close($ch);

    return $response;
}

$url = "https://api.wordpress.org/stats/wordpress/1.0/";
$response = sendCurlRequest($url);
echo $response;
Screenshot 2024-09-02 at 17 09 44

@wojtekn wojtekn closed this as completed Sep 10, 2024
@wojtekn
Copy link
Contributor

wojtekn commented Sep 10, 2024

It's fixed in 1.1.1.

@countfak
Copy link

hi,

I get this error if I try to run curl against localhost:

cURL error 55: Send failure: Socket not connected

@wojtekn
Copy link
Contributor

wojtekn commented Sep 16, 2024

@countfak thanks for the report. Would you mind sharing the code snippet? Did you try with 127.0.0.1 instead of localhost?

@countfak
Copy link

@wojtekn I'm getting the same error with 127.0.0.1

this is the code I'm using

$handle = curl_init('http://localhost:3000/'); // tried with 127.0.0.1 too
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_NOBODY, true);
curl_exec($handle);
echo curl_error($handle); // I see the error if I print this
curl_close($handle);

@wojtekn
Copy link
Contributor

wojtekn commented Sep 17, 2024

@countfak thanks for sharing the snippet!

I tested it, and I couldn't reproduce the issue with your snippet on Studio 1.1.2. It didn't show an error either for localhost or 127.0.0.1.

I also tried displaying downloaded content using another snippet, and it worked fine for me for both domain and IP:

$handle = curl_init('http://localhost:8884/license.txt'); // tried with 127.0.0.1 too
$body = curl_exec($handle);
var_dump($body);
curl_close($handle);
die;

I see your snippet uses the http://localhost:3000/ URL. It's not a Studio site URL. Is anything server under that port?

@countfak
Copy link

hey @wojtekn thanks for your help.
I'm running Vite which starts its server on port 3000 (it's just a random port). I'm using it to bundle dependencies, code and assets and serve them accordingly on development. Basically what's explained over here: https://github.com/andrefelipe/vite-php-setup

maybe Studio is not able to access what lives "outside" of it?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests