Ticket #6305 (closed defect: fixed)

Opened 8 months ago

Last modified 8 months ago

AJAX is teh b0rked when adding categories.

Reported by: christhomson Assigned to: anonymous
Priority: normal Milestone: 2.5
Component: Administration Version: 2.5
Severity: major Keywords:
Cc:

Description

When adding a new category on /wp-admin/categories.php, you always get an error saying "AJAX is teh b0rked". This is happening to me, and a few users on the WP Support Forums.

This is critical to get fixed by the final 2.5 release, otherwise users have to go to the write post page to add a new category.

Attachments

wp-ajax-response-debug.php (3.0 kB) - added by mdawaffe on 03/21/08 01:21:39.
WP Ajax Response Debug.png (26.3 kB) - added by mdawaffe on 03/21/08 01:22:16.
example output of attached plugin
wpdb_ping.diff (2.6 kB) - added by ryan on 03/21/08 07:28:53.
wp-db.php (17.4 kB) - added by ryan on 03/21/08 07:32:16.
wp-db.diff (2.6 kB) - added by westi on 03/21/08 11:55:29.
Update patch to not ping if the reconnect fails
wp-db.2.php (18.0 kB) - added by westi on 03/21/08 11:55:46.
Update wp-db.php to not ping if the reconnect fails

Change History

03/20/08 05:08:32 changed by markjaquith

  • status changed from new to closed.
  • resolution set to worksforme.
  • milestone deleted.

Cannot reproduce as of [7412] using Safari 3.1 or Firefox 2.0.0.12 (both OS X 10.5.2). Server environment is Apache 2, PHP 5.2.4

Please re-open with more details about your server/browser environment. Please try it with ALL plugins disabled.

03/20/08 19:49:58 changed by christhomson

  • status changed from closed to reopened.
  • resolution deleted.
  • severity changed from critical to normal.

I just tested this locally and it seems to work fine (on Mac OS X Leopard with MAMP, with no plugins). I just tested it again on the same install, with the same settings (on my actual website), and it still said "AJAX is teh b0rked" but once I refreshed it, all the categories disappeared! I refreshed again, and all the categories reappeared, including the one I was trying to make when "AJAX was b0rked". Here's a little info that might be useful to find the problem:

I'm running Apache/2.0.54, php 5.2.5, mysql 4.1.11.

03/20/08 20:09:46 changed by markjaquith

christhompson, what WordPress version/revision?

03/20/08 20:17:04 changed by mdawaffe

Try disabling JavaScript? in your browser and then add a category from Manage -> Categories. What happens?

03/21/08 00:55:58 changed by ryan

Trunk adds some extra error checks to help isolate the problem. If you're using svn, update and trying adding a category. Do you see "Could not insert term into the database"?

03/21/08 01:14:20 changed by Viper007Bond

Indeed. I'm having this happen on a client's install.

03/21/08 01:20:41 changed by mdawaffe

wp-ajax-response-debug.php

A plugin that will output the parsed data of any XML response resulting from a WP AJAX request (see attached screenshot). Upload it to your wp-content/plugins/ directory and activate it from your WordPress' Plugins admin page.

Tested in FF2, Safari3, Opera9, IE6/7

03/21/08 01:21:39 changed by mdawaffe

  • attachment wp-ajax-response-debug.php added.

03/21/08 01:22:16 changed by mdawaffe

  • attachment WP Ajax Response Debug.png added.

example output of attached plugin

03/21/08 01:37:23 changed by Otto42

mod_security problem, perhaps?

03/21/08 05:10:19 changed by helmi

having the same problem here (FF3b4, Safari 3.1, MaxOSX 10.5.2). When switching of Javascript i get "Category not added" instead without any other visible error/problem. I switched off all plugins and still get the same error. Probably something server related. Can't say too much about installed modules as this server isn't my own. Will try another install on a local test machine.

03/21/08 05:19:01 changed by ryan

Check error logs to see if anything is being output there, particularly database error related stuff.

03/21/08 05:19:12 changed by ryan

  • milestone set to 2.5.

03/21/08 07:28:31 changed by ryan

"Lost connection to MySQL server during query"

That error was reported on the testers list. Seems related to the "gone away" errors from #5951 that people worked around by using mysql_ping(). I'll create a mysql_ping() patch to wpdb to see if that helps.

03/21/08 07:28:53 changed by ryan

  • attachment wpdb_ping.diff added.

03/21/08 07:31:37 changed by ryan

If a query errors out with a CR_SERVER_GONE_ERROR or CR_SERVER_LOST errno, two attempts are made to mysql_ping() and reconnect. If successful, the query is done again, otherwise we bail.

03/21/08 07:32:16 changed by ryan

  • attachment wp-db.php added.

03/21/08 07:32:58 changed by ryan

Modified wp-db.php attached for those who don't have patch handy.

03/21/08 11:42:23 changed by Viper007Bond

Seems to have worked, but it's REALLY slow (like 10-30 seconds).

Also:

Warning: mysql_ping() expects parameter 1 to be resource, boolean given in [...]

03/21/08 11:51:21 changed by westi

Looking at the patch $this->dbh can only be a bool if the mysql_connect fails - I assume it's the reconnect that fails.

03/21/08 11:55:29 changed by westi

  • attachment wp-db.diff added.

Update patch to not ping if the reconnect fails

03/21/08 11:55:46 changed by westi

  • attachment wp-db.2.php added.

Update wp-db.php to not ping if the reconnect fails

03/21/08 11:56:36 changed by westi

I've attached a new patch (or wp-db.php) for people to try which won't ping if the reconnect fails.

03/22/08 23:43:32 changed by Viper007Bond

Works, but still a horridly long page load. Takes exactly 30 seconds to get the AJAX response (same for non-AJAX). Seems some timeout is occurring and it takes 30 seconds before it gives up.

03/22/08 23:43:51 changed by Viper007Bond

  • severity changed from normal to major.

03/23/08 00:55:12 changed by ryan

(In [7481]) Make sure IDs are >= 0. see #6305

03/23/08 01:02:28 changed by ryan

I looked at differences between how categories are created from Write->Post versus Manage->Categories. Manage->Categories allows parent IDs of -1 to be passed down. The commit above changes negative IDs to zero just in case negative IDs are somehow responsible.

03/23/08 01:10:46 changed by ryan

(In [7483]) Make sure cat parents are >= 0. see #6305

03/23/08 01:22:48 changed by Viper007Bond

  • status changed from reopened to closed.
  • resolution set to fixed.

Indeed they were. Totally blazing fast as of the current SVN version. Woot!

03/23/08 01:24:22 changed by Viper007Bond

Er, I probably shoulda waited for confirmation from others before closing. Someone reopen this if it didn't fix it for you.