Opened 10 years ago
Closed 10 years ago
#5648 closed defect (bug) (no action required)
problem with warning AJAX functions
Reported by: | dmuneras | Owned by: | |
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | minor | Version: | 1.9.2 |
Component: | Groups | Keywords: | reporter-feedback |
Cc: |
Description
When the AJAX function to load more activity updates is executed and PHP warnings are triggered. The response is caught by the .fail function of the jQuery post function (if you are using promises to handle the response), because the response is a malformed JSON. That happens because warnings are attached to the response.
Example:
I am fixing a plugin called Activity plus tabs extension, which has all AJAX functions broken because of a problem with event delegation.
In order to get what I want I had to create my own AJAX handlers. I avoid the problem by following an advice from this post: http://codex.wordpress.org/AJAX_in_Plugins
I added the ob_clean() function to remove warnings from my JSON response (you can add the warnings to the JSON).
I don't know if my solution is a good one, but it works.
It could be nice if you can fix it in Buddypress because that problem is very annoying when you are working in a development environment.
This is the line in the buddypress JS where the AJAX function for this case is triggered:
Thanks in advance,
Daniel Múnera Sánchez.
Change History (3)
#2
@
10 years ago
Hi Boone,
I will send you a more complete backtrace as soon as I can, for the moment this is the information I have:
=> My wordpress version is 3.9.1
=> The error is related with the capabilities of the user, if the logged user is an admin, the warning not appears and everything works fine.
=> Error reporting level is turned on only in the development server
Best regards,
Daniel.
#3
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Agree this is annoying in a dev environment, but it's not a real problem for production because errors should be handled silently. I also suspect the cause of the error is in another plugin, as BP is pretty reliable at not throwing errors/warnings nowadays.
@Daniel If you can track down what plugin is actually causing the problem, and if it does turn out to be BuddyPress, please let us know, and supply as much debugging information as you discover so we can fix the problem.
For now, until we get any further updates that identify BuddyPress as the cause, I'm going to close the ticket.
Thanks for the report. Can you get a more detailed stack trace of the PHP warning, to see its root cause? Without knowing what version of WP you're running, I can't be sure what line 1375 of
wp-admin/includes/plugin.php
is, but I'm guessing that it has something to do withremove_menu_page()
orremove_submenu_page()
. And my guess is that this doesn't actually have to do with BuddyPress at all - it's just that BuddyPress's AJAX is demonstrating the problem.So, if you can get a more complete stack trace, that would be helpful.
Your output buffer workaround is fine, but it would be better to do one or both of the following: