Ajax requests
|
siburny
Joined: 2012-03-27
Posts: 40 |
Posted: Wed, 2012-05-23 21:12
|
|
I've recently discovered that Gallery doesn't handle errors in AJAX requests. Example: I had bad characters in the Album name and when I go to delete that album, Ajax request would fail with 500 status code, but spinner and dialog would still be visible on screen like "request is still being processed". To rectify this, I added an error handler in gallery.dialog.js file (put it right after or before "success" ajax handler in "_ajaxify_dialog" function): error: function(xhr, ajaxOptions, thrownError) { What it does is it replaces HTML of the dialog with text of the error message that server returned. At least now I not only know immediately that requests failed, I also get a full error message (in my case Kahana exception with stack trace). |
|
| Login or register to post comments |

Posts: 25956
Can you explain how that happened?
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 40
They are not bad per se, but they are not being validated. My album name has many periods "." like this "2011.12.31-Happy.New.Year", and Gallery apparently doesn't allow multiple periods in the name. But when you add images using Server Add module, names are not totally validated, and albums are created as they are (with many periods), and (of course) I can't delete them afterwards
Posts: 25956
OK, thanks for the explanation. I'm trying to reproduce this but I'm having trouble.
I created a directory on the server called: 2011.12.31-Happy.New.Year
added a image to that directory
Used server add to add that directory. It did not add that directory.
Trying to manually create that album I get a validation.illegal_data_file_extension in the inernet address field.
Got a better step by step procedure on how to reproduce?
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 40
I figured it out! Look at this commit from May 17: https://github.com/gallery/gallery3/commit/9e2ea2ffedb22f83137db4e5ba4c06b91f11e09d#modules/gallery/models/item.php
When I used Server Add (several weeks ago), that code wasn't there and I was able to add that album. Several days ago I merged with upstream that added extra validation (line 807 in /module/gallery/models/item.php):
// Do not accept files with double extensions, they can cause problems on some
// versions of Apache.
if (substr_count($this->name, ".") > 1) {
$v->add_error("name", "illegal_data_file_extension");
}
Now that check "breaks" my installation, because every album has multiple periods in the name and hence I can't delete them
Posts: 40
But the point of this thread is to add some kind of indication that AJAX request failed, no matter what went wrong
Posts: 25956
Ok, I file a ticket.
Thanks for the leg work!
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 40
There is a ticket from 3 year ago about that
http://sourceforge.net/apps/trac/gallery/ticket/236
I'll add a comment and the snippet.
Posts: 25956
Fixed:
https://github.com/gallery/gallery3/commit/b91d28474759c6183d06f93ab1ff7231d792449f
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team