php-resque icon indicating copy to clipboard operation
php-resque copied to clipboard

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

Open StanAngeloff opened this issue 10 years ago • 2 comments

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.

StanAngeloff avatar Mar 04 '15 13:03 StanAngeloff

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.

danhunsaker avatar Mar 04 '15 19:03 danhunsaker

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?

StanAngeloff avatar Mar 04 '15 20:03 StanAngeloff