Skip to content

$http_response_header and $php_errormsg cause deprecation warnings in PHP 8.5 #52

@MPE02

Description

@MPE02

We are using this SDK with PHP 8.5 and getting deprecation warnings during autoloading.

The problem is in src/OneflowSDK.php in the request() method:

  // line ~283
  if ($response === false) throw new Exception("Problem reading data from $url, $php_errormsg");
  // line ~285
  preg_match('{HTTP\/\S*\s(\d{3})}', $http_response_header[0], $match);

$php_errormsg was removed in PHP 8.0. $http_response_header is deprecated in PHP 8.5.

The fix for both:

  // replace $php_errormsg with:
  $lastError = error_get_last();
  throw new Exception("Problem reading data from $url, " . ($lastError['message'] ?? ''));
  // replace $http_response_header with:
  $meta = stream_get_meta_data($fp);
  preg_match('{HTTP\/\S*\s(\d{3})}', $meta['wrapper_data'][0], $match);

Also ini_set("track_errors", "on") at the top of that method can be removed, it was removed in PHP 8.0 as well.

Are you still maintaining this package? Happy to open a PR with the fix if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions