[wp-trac] [WordPress Trac] #7691: autosave newer version check can
be slow enough to cause edit tab to time out
WordPress Trac
wp-trac at lists.automattic.com
Fri Sep 5 07:00:23 GMT 2008
#7691: autosave newer version check can be slow enough to cause edit tab to time
out
------------------------+---------------------------------------------------
Reporter: tellyworth | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: 2.6.2
Component: General | Version:
Severity: normal | Keywords:
------------------------+---------------------------------------------------
in edit-form-advanced.php there's a call to wp_text_diff() that checks for
a newer autosave revision that is different (around line 48). Under
certain circumstances this can cause a loop that will eat CPU for several
minutes and prevent the edit post tab from opening.
Specifically it happens if two revisions are very long, have many lines,
and every line is different between the two revs. I can reproduce this in
unit testing with two different revisions, each with 10,000 lines of 50
characters. The real-world circumstances that triggered this was a very
long post (approx 750kb) where one revision contained HTML tags, and the
other revision had html special chars converted to entities. That caused
virtually every line to be different.
There are three separate issues here:
1. edit-form-advanced.php calls wp_text_diff() (a heavyweight function for
displaying the differences between posts) when all it really needs is a
fuzzy text comparison function.
2. wp_text_diff() calls WP_Text_Diff_Renderer_Table, which is very
inefficient under these circumstances. I don't know enough about that
code to know the cause or appropriate fix, but it seems to get stuck in
the compute_string_distance() loop at the top of
interleave_changed_lines(). It's not an infinite loop as far as I can
tell, just very inefficient in this particular case.
3. Under some unknown circumstances, revisions are saved with special
chars entity-encoded. That will screw with versioning diffs even if the
above two issues are fixed.
Working on a fix for 1. I'll leave 2 and 3 for folks with specific
knowledge about those things.
--
Ticket URL: <http://trac.wordpress.org/ticket/7691>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list