Skip to content

Commit 03013a2

Browse files
author
iitenkida7
committed
Cast Content-Length header value to string to avoid psr7 deprecation
guzzlehttp/psr7 2.11 deprecates passing a non-string to MessageInterface::withHeader(), and 3.0 will require string|string[]. mb_strlen() returns an int, so every request with a body emits: Passing int to MessageInterface::withHeader() is deprecated; guzzlehttp/psr7 3.0 requires string|string[]. Cast the value to string to silence the deprecation and stay forward-compatible with psr7 3.0.
1 parent 3c41a5e commit 03013a2

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

88
## Unreleased
9+
- [Patch] Cast `Content-Length` header value to `string` in `Http::request()` to avoid a `guzzlehttp/psr7` 2.11 deprecation (`Passing int to MessageInterface::withHeader() is deprecated`) and stay compatible with `guzzlehttp/psr7` 3.0
910

1011
## v6.1.1 - 2026-03-02
1112
- [#456](https://github.com/Shopify/shopify-api-php/pull/456) [Patch] Update firebase/php-jwt to ^7.0 to address security vulnerability (GHSA-2x45-7fc3-mxwq)

src/Clients/Http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected function request(
207207
$request = $request
208208
->withBody($stream)
209209
->withHeader(HttpHeaders::CONTENT_TYPE, $dataType)
210-
->withHeader(HttpHeaders::CONTENT_LENGTH, mb_strlen($bodyString));
210+
->withHeader(HttpHeaders::CONTENT_LENGTH, (string) mb_strlen($bodyString));
211211
}
212212

213213
$currentTries = 0;

0 commit comments

Comments
 (0)