Make WordPress Core

Opened 4 years ago

Last modified 2 months ago

#13580 new enhancement

Ajax Tag Search crashes browsers on databases with large tag lists or slow connections

Reported by: brianlayman Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: needs-patch needs-refresh needs-docs
Focuses: Cc:


In short, many conditions can cause the ajax-tag-search to take a long time. This is not just limited to database size or speed but is also dependent upon the speed of the author's connection. When a browser JS call times out, the user can hit stop script, however the script is usually triggered again almost immediately. The end result currently seems to be the browser session crashing. At best, when these delays happen, getting suggestions for tags can take 30+ seconds be a very tedious process.

This simple backwards compatible patch addresses the issue by allowing site by site customization of the variables involved.

This patch references two new option values:

ats_min_chars - Allows you to specify how many letters must be typed before the search is done. Currently, this number is hard coded at "2". That is the default for the patch..

ats_min_count - Allows you to eliminate tags that are used infrequently. This uses the count column on the already included term_taxonomy table; so it does not expand the query at all. It defaults to "0"

The code in this patch has been running live at b5media for a while now with the defaults of 3 for min chars and either 10 or 20 for the post count dependent upon which site is involved.

Attachments (3)

admin-ajax_ajax-tag-search.diff (915 bytes) - added by brianlayman 4 years ago.
Adds two options for altering tag search behavior defaulting the values to wp 2.x defaults
13580.2.diff (940 bytes) - added by ryan 3 years ago.
Patch with just strip and prepare
13580.diff (1.1 KB) - added by brianlayman 3 years ago.
Updated patch to reflect 13580.2.diff 's inclusion in 3.1. This patch should apply to 3.2's dev/trunk code.

Download all attachments as: .zip

Change History (15)

brianlayman4 years ago

Adds two options for altering tag search behavior defaulting the values to wp 2.x defaults

comment:1 nacin4 years ago

  • Component changed from Editor to Performance
  • Keywords needs-patch added; editor tags crash removed
  • Milestone changed from 3.0 to 3.1
  • Priority changed from high to normal
  • Severity changed from critical to normal
  • Type changed from defect (bug) to enhancement

Seems sane. Too late for 3.0 however.


The options should instead be filters.

We should only add the count to the SQL if the filter returns > 0.

comment:2 technosailor4 years ago

Agree on options being filters. Don't need to clog the options table, or worse, create UI for this.

comment:3 brianlayman4 years ago

Seems reasonable. No UI is a very good reason for that.

comment:4 nacin3 years ago

  • Milestone changed from Awaiting Triage to Future Release

ryan3 years ago

Patch with just strip and prepare

comment:5 westi3 years ago

Patch looks good

comment:6 ryan3 years ago

(In [17256]) Strip and prepare ajax tag search string. Avoids applying slashes toward the character count. Props brianlayman. see #13580

brianlayman3 years ago

Updated patch to reflect 13580.2.diff 's inclusion in 3.1. This patch should apply to 3.2's dev/trunk code.

comment:7 brianlayman3 years ago

Would love to see this included in 3.2. It would be great to not have to do core hacks just to keep the editor from crashing when you have hundreds of tags... And I'd no longer have to keep updating the patch! :D

comment:8 SergeyBiryukov3 years ago

  • Keywords has-patch added; needs-patch removed

comment:10 nacin3 months ago

  • Component changed from Performance to Taxonomy
  • Focuses docs added
  • Keywords needs-patch added; has-patch removed

I'm happy to revisit this, with proper hook documentation. Also, we should spell out "term_search" rather than "ats".

comment:11 ircbot2 months ago

This ticket was mentioned in IRC in #wordpress-dev by DrewAPicture. View the logs.

comment:12 DrewAPicture2 months ago

  • Focuses docs removed
  • Keywords needs-refresh needs-docs added

Looks like 13580.diff needs a refresh as this code lives in wp-admin/includes/ajax-actions.php now, and the query now uses get_terms().

Note: See TracTickets for help on using tickets.