Skip to content

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Jun 21, 2021

The Requests_Transport_cURL::setup_handle() and Requests_Transport_cURL::format_get() methods, both call the PHP native http_build_query() function.
The second parameter of which is the optional $numeric_prefix parameter which expects a string.

A parameter being optional, however, does not automatically make it nullable.

As of PHP 8.1, passing null to a non-nullable PHP native function will generate a deprecation notice.
In this case, both these function calls yielded a http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated notice.

Changing the null to an empty string fixes this without BC-break.

This change is already covered by tests as 15 of the existing tests failed on these function calls when running the tests on PHP 8.1.

Refs:

The `Requests_Transport_cURL:;setup_handle()` and `Requests_Transport_cURL::format_get()` methods, both call the PHP native `http_build_query()` function.
The second parameter of which is the _optional_ `$numeric_prefix` parameter which expects a `string`.

A parameter being optional, however, does not automatically make it nullable.

As of PHP 8.1, passing `null` to a non-nullable PHP native function will generate a deprecation notice.
In this case, both these function calls yielded a `http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated` notice.

Changing the `null` to an empty string fixes this without BC-break.

This change is already covered by tests as 15 of the existing tests failed on these function calls when running the tests on PHP 8.1.

Refs:
* https://www.php.net/manual/en/function.http-build-query.php
* https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg
@schlessera schlessera merged commit 6c5f62e into develop Jul 30, 2021
@schlessera schlessera deleted the php-8.1/fix/http_build_query-null-to-non-nullable branch July 30, 2021 09:52
@jrfnl jrfnl mentioned this pull request Aug 27, 2021
14 tasks
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.

3 participants