Issue with GeSHI and CakePHP

So today I was having an issue where, for some reason, an incredibly long script in our script repository built using CakePHP would not display the GeSHI syntax-highlighted code. I tore apart the code looking for an answer and the only unique attribute to this script was its very long length (around 1k lines, over 50k characters). I eventually narrowed it down to the preg_replace that was being used in the CakePHP wrapper for GeSHI I was using and discovered that the pcre.backtrack_limit was too low at the default of 10000 (10 thousand). I upped the limit to 10000000 (10 million) and it’s now able to display the syntax highlighted code without issue.

Just thought I’d make a quick post because I could not find another blog with this solution. Hope this helps someone else in a similar predicament!

Leave a Reply

Your email address will not be published. Required fields are marked *