studio icon indicating copy to clipboard operation
studio copied to clipboard

php_curl missing and curl_exec deactivated

Open pr0pz opened this issue 1 year ago • 13 comments

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 avatar May 28 '24 16:05 pr0pz

📌 REPRODUCTION RESULTS – Replicated

📌 ACTIONS – Kept priority

  • Related to https://github.com/Automattic/studio/issues/61
  • Discussed in p1716879810244969/1716879787.384059-slack-C06DRMD6VPZ and p1714654185889809/1714653771.175899-slack-C06DRMD6VPZ

mrfoxtalbot avatar Jun 04 '24 14:06 mrfoxtalbot

We have another request on 8302777-zd-a8c

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

jartes avatar Jun 08 '24 12:06 jartes

Support References

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

  • [ ] 8302777-zen
  • [ ] 8350827-zen
  • [ ] 8428094-zen
  • [ ] 8518441-zen

github-actions[bot] avatar Jun 08 '24 12:06 github-actions[bot]

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.

rw-ye avatar Jun 18 '24 04:06 rw-ye

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.

supernovia avatar Jul 02 '24 20:07 supernovia

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

danielbachhuber avatar Jul 02 '24 22:07 danielbachhuber

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

ktyfuller604 avatar Jul 23 '24 19:07 ktyfuller604

Upstream issue about supporting libcurl in php-wasm: https://github.com/seanmorris/php-wasm/issues/32

lsl avatar Aug 14 '24 06:08 lsl

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

mpkelly avatar Aug 21 '24 04:08 mpkelly

According to @adamziel in https://github.com/WordPress/wordpress-playground/issues/1008 curl is currently only available in the CLI.

akirk avatar Aug 21 '24 11:08 akirk

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

brandonpayton avatar Aug 21 '24 15:08 brandonpayton

@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

kozer avatar Aug 21 '24 15:08 kozer

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.

brandonpayton avatar Aug 21 '24 16:08 brandonpayton

CURL was fixed by upgrading the Playground dependencies on https://github.com/Automattic/studio/pull/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

sejas avatar Sep 02 '24 16:09 sejas

It's fixed in 1.1.1.

wojtekn avatar Sep 10 '24 09:09 wojtekn

hi,

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

cURL error 55: Send failure: Socket not connected

countfak avatar Sep 16 '24 10:09 countfak

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

wojtekn avatar Sep 16 '24 11:09 wojtekn

@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);

countfak avatar Sep 16 '24 12:09 countfak

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

wojtekn avatar Sep 17 '24 12:09 wojtekn

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?

countfak avatar Sep 17 '24 13:09 countfak

@countfak I've checked another snippet to fetch the license file in the Studio site from the site served by Local, and it worked fine:

$handle = curl_init('http://test-api.local/license.txt');
$body = curl_exec($handle);
var_dump($body);
curl_close($handle);
die;

wojtekn avatar Sep 24 '24 07:09 wojtekn

This remains a mystery.

I always get cURL error 55: Send failure: Socket not connected if I try to use curl to get something on localhost that is not served by Studio.

In my case, since I just need to return true or false whether I'm on localhost or not, I ended up doing a simple check on $_SERVER['HTTP_HOST'].

countfak avatar Oct 25 '24 23:10 countfak