kittsville / WP-Librarian

WP-Librarian is an inventory management WordPress plugin for keeping track of books and media
GNU General Public License v3.0
4 stars 1 forks source link

Dashboard AJAX failure improperly reported as server down #46

Closed kittsville closed 9 years ago

kittsville commented 9 years ago

For some time errors have not been correctly reported by Dashboard AJAX. Errors that result in malformed JSON are being reported as the server being down (Unable to contact $site_name The website may be down or you may be having connection issues). This is probably just a minor issue with wp_lib_send_ajax().

kittsville commented 9 years ago

Investigation shows this does not appear to happen with Dash page and Dash action request failures.

kittsville commented 9 years ago

The issue is that I presumed the jQuery.ajax.fail callback was only called when the AJAX request failed due to a connection issue. This issue arises when the PHP fails and thus the server returns 500 (internal server error), meaning the AJAX request failed.

All I need to do is properly inspect the response in the fail callback and take appropriate action to inform the user/developer what's happened.

While this'll make the already a bit shoddy AJAX function messier it's a necessary fix ahead of the refactoring of all scripts, which itself is held back by the porting of KitPipe's functionality over to the WP-Librarian Dev Kit. I'll make an issue anyway and link them all together to keep clear track of what needs doing where.

kittsville commented 9 years ago

See #47 for plugin-wide script refactoring