Skip to content

Commit

Permalink
[BUGFIX] Catch E_WARNING when unserialize() fails
Browse files Browse the repository at this point in the history
Since PHP 8.3, unserialize() throws an E_WARNING instead of E_NOTICE.
This leads to an error when viewing crawler information for pages
and when crawling sites:

> PHP Warning: unserialize(): Error at offset 0 of 122 bytes
> in typo3conf/ext/crawler/Classes/Converter/JsonCompatibilityConverter.php line 39

Resolves: tomasnorre#1087
  • Loading branch information
cweiske committed Jan 14, 2025
1 parent 0b137a0 commit 670dd21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Fixed
* Fixed query building when using _ADDTABLE parameter [@hawkeye1909](https://github.com/hawkeye1909)
* Typecast PageTS Crawler Configuration `force_ssl` to `int`
* Catch E_WARNING when unserialize() fails [cweiske](https://github.com/cweiske)

### Deprecated

Expand Down
6 changes: 5 additions & 1 deletion Classes/Converter/JsonCompatibilityConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class JsonCompatibilityConverter
*/
public function convert(string $dataString)
{
$unserialized = unserialize($dataString, ['allowed_classes' => false]);
try {
$unserialized = unserialize($dataString, ['allowed_classes' => false]);
} catch (\Throwable) {
$unserialized = false;
}
if (is_object($unserialized)) {
throw new \Exception('Objects are not allowed: ' . var_export($unserialized, true), 1593758307);
}
Expand Down

0 comments on commit 670dd21

Please sign in to comment.