Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 2.7.4 - unreleased

- Fix `spl_object_hash` deprecation on PHP 8.6.

## 2.7.3 - 2025-11-29

- Allow installation with Symfony 8.
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
]
},
"config": {
"sort-packages": true
"sort-packages": true,
"policy": {
"advisories": {
"ignore": ["guzzlehttp/psr7"]
}
}
}
}
2 changes: 1 addition & 1 deletion src/Plugin/RedirectPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl

$uri = $this->createUri($response, $request);
$redirectRequest = $this->buildRedirectRequest($request, $uri, $statusCode);
$chainIdentifier = spl_object_hash((object) $first);
$chainIdentifier = \PHP_VERSION_ID < 70200 ? spl_object_hash((object) $first) : (string) spl_object_id((object) $first);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I am surprised this ever worked. According to docs:

This id can be used as a hash key for storing objects, or for identifying an object, as long as the object is not destroyed. Once the object is destroyed, its hash may be reused for other objects.

And indeed, running:

var_dump(spl_object_hash((object) ['a', 'b']));
var_dump(spl_object_hash((object) ['a', 'b', 'c']));
var_dump(spl_object_hash((object) md5(...)));

Prints the following for me:

string(32) "00000000000000020000000000000000"
string(32) "00000000000000020000000000000000"
string(32) "00000000000000020000000000000000"

https://3v4l.org/KTQqT4#veol


if (!array_key_exists($chainIdentifier, $this->circularDetection)) {
$this->circularDetection[$chainIdentifier] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/RetryPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __construct(array $config = [])

public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
{
$chainIdentifier = spl_object_hash((object) $first);
$chainIdentifier = \PHP_VERSION_ID < 70200 ? spl_object_hash((object) $first) : (string) spl_object_id((object) $first);

return $next($request)->then(function (ResponseInterface $response) use ($request, $next, $first, $chainIdentifier) {
if (!array_key_exists($chainIdentifier, $this->retryStorage)) {
Expand Down