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!
Just a quick note on this:
When overwriting a value for a single site using php.ini, I highly suggest copying the root level php.ini (located at /usr/local/lib/php.ini for most suPHP enabled Linux servers) to the directory in question, changing the one value needed, then chowning the file to the user, rather than making your own custom php.ini with one line of the value that is being overwritten. The reasoning behind this is that when you make an empy php.ini with just the one directive, many issues including but not limiting to the following arise:
- safe_mode defaults to On instead of Off
- pdo or any other includes such as zend or ioncube are no longer loaded
- disable_functions line is nullified
Anyways, just a tip for anyone out there using such changes! Let me know if you have any questions about this in the comments!