[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 30 19:19:34 UTC 2009
#8553: preg_replace_callback in do_shortcode returns empty for large posts
-------------------------------------+--------------------------------------
Reporter: AaronCampbell | Type: defect (bug)
Status: new | Priority: high
Milestone: 3.0 | Component: Shortcodes
Version: | Severity: normal
Keywords: has-patch needs-testing |
-------------------------------------+--------------------------------------
Comment(by jalenack):
Replying to [comment:47 Brusdeylins]:
> This Problem still exists in WP 2.8.6.
> My solution in ./wp-includes/shortcodes.php :
>
>
> {{{
> function get_shortcode_regex() {
> global $shortcode_tags;
> $tagnames = array_keys($shortcode_tags);
> $tagregexp = join( '|', array_map('preg_quote', $tagnames) );
>
> // defect for long posts
> // return
'(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)';
>
> // solution for brusdeylins.info
> return
'(.?)\[('.$tagregexp.')\b([^\]]*?)(\/)?\](?:(.+?)\[\/\1\])?(.?)';
> }
> }}}
I was suffering from this issue in 2.8.x and 2.9 on several posts (7600
words with images etc). I added the pcre
ini_set('pcre.backtrack_limit', 1000000); and that fixed the problem.
Wordpress was taking a really long time to save so I tried using the above
get_shortcode_regex() code, and it broke my [caption] shortcode that was
generated by visual mode:
{{{
[caption id="attachment_9522" align="alignright" width="350"
caption="___desc__"]<a href="__url__"><img class="size-full wp-image-9522"
title="___desc___" src="____url___" alt="___desc___" width="350"
height="351" /></a>[/caption]
}}}
broke as in failed to parse and left a hanging `[/caption]`. I didn't try
any other patches besides the pcre.backtrack_limit part, which did fix my
problem.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/8553#comment:49>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list