[wp-trac] [WordPress Trac] #8553: preg_replace_callback in do_shortcode returns empty for large posts

WordPress Trac wp-trac at lists.automattic.com
Wed Dec 10 01:51:29 GMT 2008


#8553: preg_replace_callback in do_shortcode returns empty for large posts
---------------------------+------------------------------------------------
 Reporter:  AaronCampbell  |       Owner:  anonymous  
     Type:  defect         |      Status:  new        
 Priority:  normal         |   Milestone:  2.7.1      
Component:  General        |     Version:             
 Severity:  normal         |    Keywords:  needs-patch
---------------------------+------------------------------------------------
 This is definitely related to #6877, though I don't know that I'd call it
 a dupe.  Anyway, the problem is that on long posts the
 [http://www.php.net/manual/en/pcre.configuration.php#ini.pcre.backtrack-
 limit pcre.backtrack_limit] is exceeded.  I have a post that is 105k+
 characters and I couldn't process even a single shortcode.

 Setting the pcre.backtrack_limit to 1,000,000 worked
 (`ini_set('pcre.backtrack_limit', 1000000);`), but the default (100,000)
 should definitely work.

 Here are some thoughts to kick around:
  * I wonder if it would help to break the post into chunks first: process
 from the first `[` to the last `]` for shortcodes then re-add the start
 and end.  In many cases this would reduce the amount of text being
 processed.
  * Alternatively, maybe some of them could be handled with str_replace?
 (if `[shortcode]` exists and `[/shortcode]` doesn't).  I know that this
 would only work for shortcodes with no attributes or content, but if
 that's a common usage (in the specific case I was working with, all the
 shortcodes were like this).

 Anyway, the database allows 4,294,967,296 characters for a post, but I run
 against this problem pretty regularly on posts over 100,000.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/8553>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list