• We started getting this error soon after the site got updated to 6.2

    PHP Fatal error: Uncaught WpOrg\Requests\Exception\InvalidArgument: WpOrg\Requests\Requests::request(): Argument #4 ($type) must be of type string, NULL given in /var/www/site.com/wp-includes/Requests/src/Exception/InvalidArgument.php:29

    What’s strange here is in this file /wp-includes/class-wp-http.php on line #217 the ‘method’ gets parsed. So on line #320, the $type variable can not be null.

    But for some reason null value is getting passed in argument #4 on line #396.

    Any idea why this might be happening?

    • This topic was modified 1 year, 7 months ago by Ram Shengale.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Marius L. J.

    (@clorith)

    Hiya,

    Does this error also happen if you disable all plugins or use one of the default themes?

    It may be that something is interacting directly with this code, and not using WordPress’ HTTP API, so that’s a good place to start testing. If the problem is not there when disabling plugins, enabling them one at a time until it happens to identify where the problem comes from would be the next step.

    Pretty much the same error message about an Amazon-related plugin not working now: WpOrg\Requests\Requests::request(): Argument #4 ($type) must be of type string, NULL given

    Thread Starter Ram Shengale

    (@ramshengale)

    I found the issue. This is a stripped down version of the function I had:

    function send_api_request($endpoint, $args, $method = 'POST'){
    $request_url = 'https://api.com/' . $endpoint;
    $request_args = array(
    'method' => $method,
    'body' => $args
    );
    $response = wp_remote_request( $request_url, $request_args);
    }


    I was calling it this way:

    send_api_request('fetch_something', array('foo' => 'bar'), null);

    Now this was working all along. But suddenly stopped working out of nowhere.

    Modifying the function to:

    send_api_request('fetch_something', array('foo' => 'bar'), 'POST');
    or
    send_api_request('fetch_something', array('foo' => 'bar'));
    fixes the issue.

    I understand the null I was passing was restting the value of $method variable. But any idea why this was working earlier?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Strange error with after v6.2 auto-update’ is closed to new replies.