Skip to content

ext/curl: Refactor cURL to only use FCC #13291

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

Merged
merged 15 commits into from
May 1, 2024

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jan 31, 2024

Refactor cURL options that use callables to check them on assignment and use the standard FCC instead of its custom struct.

  • Finish conversions
  • Tests for trampolines as callables
  • Test multi handler (with normal callables and trampoline)

@Girgias Girgias force-pushed the curl-fcc-refactoring branch from 69a9320 to 294aed3 Compare February 1, 2024 00:27
@Girgias Girgias force-pushed the curl-fcc-refactoring branch from 294aed3 to 2d54d26 Compare February 6, 2024 14:20
@Girgias Girgias force-pushed the curl-fcc-refactoring branch from 2d54d26 to 724a2d9 Compare April 15, 2024 14:47
@Girgias Girgias marked this pull request as ready for review April 15, 2024 14:47
@Girgias Girgias requested a review from adoy as a code owner April 15, 2024 14:48
@Girgias Girgias force-pushed the curl-fcc-refactoring branch from 724a2d9 to c0b5fd9 Compare April 23, 2024 22:38
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor comments otherwise looks good

efree(mh->handlers.server_push);

if (ZEND_FCC_INITIALIZED(mh->handlers.server_push)) {
zend_fcc_dtor(&mh->handlers.server_push);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other places you set it then to the empty fcc, did you forget to do that here?

case CURLMOPT_PUSHFUNCTION: {
/* See php_curl_set_callable_handler */
if (ZEND_FCC_INITIALIZED(mh->handlers.server_push)) {
zend_fcc_dtor(&mh->handlers.server_push);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be set to the empty fcc?

@Girgias Girgias force-pushed the curl-fcc-refactoring branch from c0b5fd9 to 9ad63b1 Compare April 30, 2024 21:13
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!
Only 2 remarks I have is one that I wrote in the comment, and one that I told you already: zend_fcc_dtor actually does set the fcc to empty, so manually overwriting to empty is not necessary (Sorry!).

@Girgias Girgias force-pushed the curl-fcc-refactoring branch from 9ad63b1 to 431d24a Compare April 30, 2024 23:43
@Girgias Girgias merged commit f4dbe23 into php:master May 1, 2024
9 of 10 checks passed
@Girgias Girgias deleted the curl-fcc-refactoring branch May 1, 2024 14:09
derrabus added a commit to symfony/symfony that referenced this pull request May 3, 2024
…re-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

[HttpClient] Fix cURL default options for PHP 8.4

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | -
| License       | MIT

PHP 8.4 brings a change in ext/curl (php/php-src#13291) that requires `CurlResponse` to be updated. Curl callbacks cannot be set to null anymore and requires real callable.

Here is (one of) the CI error it fixes:

```
10) Symfony\Component\HttpClient\Tests\CurlHttpClientTest::testGzipBroken
Failed asserting that exception of type "TypeError" matches expected exception "Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface". Message was: "curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_PROGRESSFUNCTION, no array or string given" at
/home/runner/work/symfony/symfony/src/Symfony/Component/HttpClient/Response/CurlResponse.php:175
/home/runner/work/symfony/symfony/src/Symfony/Component/HttpClient/Internal/Canary.php:32
/home/runner/work/symfony/symfony/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php:90
/home/runner/work/symfony/symfony/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php:218
/home/runner/work/symfony/symfony/src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php:68
/home/runner/work/symfony/symfony/src/Symfony/Component/HttpClient/Response/CurlResponse.php:232
/home/runner/work/symfony/symfony/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php:1113
```

Commits
-------

cc0b957 [HttpClient] Fix cURL default options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants