Closed igor-krein closed 2 years ago
@igor-krein This is a php bug and not a specific laravel bug.
The \Serializable
interface shouldn't be used anymore sense it has been superseded by __serialize
and __unserialize
magic methods.
And as I can see you are using PHP 8.1 which means you should see deprecation warnings in your log files.
@morloderex Thanks, wasn't aware of that (we are upgrading PHP as well along with Laravel; also, I didn't see any warnings yet, which is strange).
I'll try to get rid of \Serializable
and then notify here separately.
@morloderex Just checked, and looks like this is the solution I need.
Think, I can close the issue now. Thanks again.
Description:
If a job class implements PHP's Serializable interface, and doesn't implement \Illuminate\Contracts\Queue\ShouldBeEncrypted interface, the job's payload unserialization fails.
Notes
I believe, the problem exists since Laravel 8; it's just I am upgrading from Laravel 7 to 9. Also, I suspect the bug is pretty rare.
The problematic piece of code is located at line 96 of Illuminate/Queue/CallQueuedHandler.php, where it is being determined whether the job is encrypted or not.
Condition
if (str_starts_with($data['command'], 'O:'))
works for regular classes, but for those that implement Serializable interface, serialize function generates strings started with 'C:'.See: https://www.phpinternalsbook.com/php5/classes_objects/serialization.html
Steps To Reproduce:
dispatch job
run queue worker (php artisan queue:work)