preg_replace_callback in do_shortcode returns empty for large posts
|Reported by:||AaronCampbell||Owned by:|
|Cc:||xavier@…, Brusdeylins, usermrpapa, tom@…|
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 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.
Change History (71)
- Keywords has-patch needs-testing added; needs-patch removed
- Component changed from General to Shortcodes
- Milestone changed from 2.7.2 to Future Release
- Owner anonymous deleted
comment:56 nacin — 3 years ago
- Milestone changed from 3.0 to Future Release
- Severity changed from blocker to normal