Mantis, PHP and PCRE

April 17, 2007 on 4:11 pm | In Coding | No Comments

Had an odd issue to look at where Mantis 1.0.6 was sending blank notification emails once they got to a certain size. After looking at the issue long and hard I determined that it was only happening on PHP 5.2.0 and above and seemed to be related to the size of the notification email, but wasn’t a constant size and seemed to depend on the contents of the bugnotes.

Long story short, the PHP function preg_match_all was failing once the email reached a certain size. preg_match_all is basically a thin wrapper around the Perl Compatible Regular Expression function built into PHP and since 5.2.0 the recursion and backtracking limits have been set and you need to edit your PHP.INI in order to increase them…

[Pcre]
pcre.recursion_limit = 100000
pcre.backtrack_limit = 100000

These are the default values that need to be increased, I found 500000 in each happily worked but I think you need to be careful when changing this as you can allow a complex recursive expression to consume all the stack space and crash PHP. Hope that helps somebody.

No Comments yet

TrackBack URI

Sorry, the comment form is closed at this time.

Powered by WordPress with custom theme based on "Pool" by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^

Bad Behavior has blocked 49 access attempts in the last 7 days.