[php-src] Issue #15165: There is no built in function for check serialize data like json_validate() came recently
| From: | iftakharul-xs | Date: | Tue, 30 Jul 2024 05:47:21 +0000 |
| Subject: | [php-src] Issue #15165: There is no built in function for check serialize data like json_validate() came recently | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247397@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/15165
Author: iftakharul-xs
### Description
```php
$data = 'some string';
if (is_string($data) && @unserialize($data) !== false) {
var_dump(unserialize($data));
} else {
var_dump('Not a serialized string');
}
```
omitting the error is recommended by some platforms
in a scenario, we're storing the serialized data in database
somehow user altered the serilized data and php default behavior didn't wrok as expected php is
giving this notice
**Notice: unserialize(): Error at offset 0 of 11 bytes in tempCodeRunnerFile.php on line 6**