plupload jsonrpc error handling

This is the place to discuss bugs that have been found in the most recent version of PivotX. Posting bugs will ensure that the Development Team is aware of them and that they will be addressed when resources are available.

plupload jsonrpc error handling

Postby janniz » Fri Jun 10, 2011 7:54 am


looking deep into "pivotx/fileupload.php" I've found that server side jsonrpc errors are not handled by plupload "by design"

In this scenario all those die("jsonrpc") in fileupload.php are pretty useless to me... are they handled elsewhere in pivotx code ? I looked to sources but I've not found where they could be handled.

The suggested method (explained in the URL pasted above) is to handle them in the FileUploaded javascript bind:

[code removed - to make the thread easier to read]

Currently I'm using pivotx 2.2.5, but looking at the sources, seems that 2.2.6 is also affected by this...

I could also try to provide a patch for this in the next days (now I'm really too busy with work+real life)
Posts: 15
Joined: Mon Feb 11, 2008 2:39 pm

Re: plupload jsonrpc error handling

Postby hansfn » Fri Jun 10, 2011 10:56 am

We are well aware that the errors from fileupload.php aren't handled. We could of course have removed the die-jsonrpc statements, but we decided to keep them because we wanted to add handling at a later time.

I raised this issue on the dev mailing list in November last year, and still no-one has done anything - we have been busy with other stuff. In other words, a patch is very much welcome.
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: plupload jsonrpc error handling

Postby janniz » Thu Jun 16, 2011 10:09 am

This is a quick patch I've made that should fix this bug.

Now errors raised on server-size by the upload handler should be correctly detected by the client.

Server side errors must follow this 'JSON-RPC like' format:
Code: Select all
        die('{"jsonrpc" : "2.0", "error" : {"code": <errorcode>, "message": <error message>}, "id" : null}');

this is an example:
Code: Select all
        die('{"jsonrpc" : "2.0", "error" : {"code": 104, "message": "Uploading to illegal directory."}, "id" : null}');

On the other hand this is the response I'm using when all things goes right... (you could extend it as you prefer using "result" : <your response json object>)
Code: Select all
// Return JSON-RPC response
die('{"jsonrpc" : "2.0", "result" : null, "id" : null}');

I've not tested it to much... I've made only some trivial tests (before my notebook died past Firday night :()... so handle it with care :-)
Tested on pivotx 2.2.5 and 2.2.6
(5.52 KiB) Downloaded 399 times
Posts: 15
Joined: Mon Feb 11, 2008 2:39 pm

Return to 2.x Bugs

Who is online

Users browsing this forum: No registered users and 1 guest