chrisboulton / php-resque

PHP port of resque (Workers and Queueing)
MIT License
3.43k stars 759 forks source link

Resque::push(..) fails to encode non-UTF-8 values #234

Open StanAngeloff opened 9 years ago

StanAngeloff commented 9 years ago

I ran across this recently and thought I should document it. The Resque::push method uses json_encode and doesn't check its return value. This allows false or an empty string to be rpushed into Redis and the developer is none the wiser.

One such instance where json_encode will fail is if the arguments for a job contain a string which is not properly UTF-8 encoded.

My personal preference is to throw an exception and let the calling code deal with it.

danhunsaker commented 9 years ago

There are a couple of PRs intended to catch issues with adding jobs to the queue and indicate failures to the developer. Any of these has already handled the issue you mention, in the way you describe. When Chris has the time to properly evaluate them, one will be merged and this issue will be resolved.

StanAngeloff commented 9 years ago

For the record, queueing works as expected, however the value pushed in Redis is an empty string. I didn't spot a pull that accounted for this case -- did you have one in mind I can add to my watch list?