Skip to content

Commit 9ddc72f

Browse files
authored
Fix unserialization in http client (#806)
1 parent 63f2c71 commit 9ddc72f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## v1.12.3
9+
10+
### Fixed
11+
12+
- Fixed issue with unserialization of cached HTTP client requests causing errors
13+
due to uninitialized properties.
14+
815
## v1.12.2
916

1017
### Fixed

src/mantle/http-client/class-response.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,4 +502,24 @@ public function __serialize(): array {
502502
'response' => $this->response,
503503
];
504504
}
505+
506+
/**
507+
* Restore the object from serialized data.
508+
*
509+
* @throws LogicException If the serialized data is invalid.
510+
*
511+
* @param array<string, mixed> $data Serialized data.
512+
*/
513+
public function __unserialize( array $data ): void {
514+
if ( ! isset( $data['response'] ) || ! is_array( $data['response'] ) ) {
515+
throw new LogicException( 'Invalid serialized response data.' );
516+
}
517+
518+
if ( isset( $data['url'] ) ) {
519+
$this->url = is_string( $data['url'] ) ? $data['url'] : null;
520+
}
521+
522+
$this->response = $data['response'];
523+
$this->cached = true;
524+
}
505525
}

0 commit comments

Comments
 (0)