Make WordPress Core

Opened 14 years ago

Closed 10 years ago

Last modified 10 years ago

#13580 closed enhancement (fixed)

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

Reported by: brianlayman's profile brianlayman Owned by: johnbillion's profile johnbillion
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: has-patch commit
Focuses: Cc:

Description

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 (6)

admin-ajax_ajax-tag-search.diff (915 bytes) - added by brianlayman 14 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 13 years ago.
Patch with just strip and prepare
13580.diff (1.1 KB) - added by brianlayman 13 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.
13580.3.diff (982 bytes) - added by iamfriendly 10 years ago.
Refreshed patch to use a filter and some sanity checking with docs
13580.4.diff (1012 bytes) - added by iamfriendly 10 years ago.
Refreshed patch; added a filter for minimum characters for the tag search. Added documentation for the new filter.
13580.5.diff (1.0 KB) - added by DrewAPicture 10 years ago.
tweaks

Download all attachments as: .zip

Change History (22)

@brianlayman
14 years ago

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

#1 @nacin
14 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.

Suggestions:

The options should instead be filters.

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

#2 @technosailor
14 years ago

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

#3 @brianlayman
14 years ago

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

#4 @nacin
14 years ago

  • Milestone changed from Awaiting Triage to Future Release

@ryan
13 years ago

Patch with just strip and prepare

#5 @westi
13 years ago

Patch looks good

#6 @ryan
13 years ago

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

@brianlayman
13 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.

#7 @brianlayman
13 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

#8 @SergeyBiryukov
13 years ago

  • Keywords has-patch added; needs-patch removed

#10 @nacin
10 years 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".

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


10 years ago

#12 @DrewAPicture
10 years 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().

@iamfriendly
10 years ago

Refreshed patch to use a filter and some sanity checking with docs

@iamfriendly
10 years ago

Refreshed patch; added a filter for minimum characters for the tag search. Added documentation for the new filter.

#13 @iamfriendly
10 years ago

  • Keywords has-patch added; needs-patch needs-refresh needs-docs removed

Refreshed patch; added a filter for minimum characters for the tag search.
Added documentation for the new filter in the correct manner (thanks @DrewAPicture).

@DrewAPicture
10 years ago

tweaks

#14 @DrewAPicture
10 years ago

  • Keywords commit added
  • Milestone changed from Future Release to 4.0

13580.5.diff just slightly tweaks the docs.

Nice work @iamfriendly (another new contributor at BeachPress)!

#15 @johnbillion
10 years ago

  • Owner set to johnbillion
  • Resolution set to fixed
  • Status changed from new to closed

In 28892:

Introduce a filter to control the minimum characters required for an AJAX term search. Fixes #13580. Props iamfriendly, brianlayman

#16 @johnbillion
10 years ago

I added the taxonomy object and search term as parameters on that filter too.

Note: See TracTickets for help on using tickets.