Fixing Geshi on line 2132
I recently noticed that some of my blog posts, most notably my Templates in YARPP 3 article, was producing a PHP error:
Warning: preg_match() [function.preg-match]: Compilation failed: unrecognized character after (?< at offset 3 in /…/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2132
This seemed to be coming from the version 1.0.8.4 version of Geshi I had installed. A quick google search for “geshi line 2132” gives you over a thousand errors, so this seems to be common issue. Geshi is a fabulous and popular syntax highlighter and is the core component of the WP-Syntax plugin for WordPress.
I did some digging around and realized that the issue was with the compilation of this monstrosity of a regular expression, used (as far as I can tell) to identify PHP code snippets, for example the <?php … ?> keywords:
/(?<start><\\?(?>php\b)?)(?: (?>[^\"'?\\/<]+)| \\?(?!>)| (?>'(?>[^'\\\\]|\\\\'|\\\\\\\|\\\\)*')| (?>\"(?>[^\"\\\\]|\\\\\"|\\\\\\\\|\\\\)*\")| (?>\\/\\*(?>[^\\*]|(?!\\*\\/)\\*)*\\*\\/)| \\/\\/(?>.*?$)| \\/(?=[^*\\/])| <(?!<<)| <<<(?<phpdoc>\w+)\s.*?\s\k<phpdoc> )*(?<end>\\?>|\Z)/sm
Not knowing exactly where to start in diagnosing this crazy expression, I simply disabled those “script delimiters” in the geshi/php.php file. The sections I commented out are lines 1080-1101. Now the script delimiters like <?php don’t get highlighted nicely, but I feel that’s a small price to pay for eliminating these errors. Another solution for the WP-Syntax users seems to be to downgrade to 0.9.4. Hopefully in the near future an update to Geshi will come out which fixes this issue once and for all.
Related posts:
- Yet Another Related Posts Plugin
- Modifiying WordPress plugin activation behavior
- Keep up with Yet Another Related Posts Plugin with RSS!
- Yet Another Related Posts Plugin 2.0
- Using Templates with YARPP 3
Related posts brought to you by Yet Another Related Posts Plugin.
Tags: bug, code, error, geshi, PHP, regular expression, WordPress, WordPress Planet, YARPP
If you enjoyed this post, make sure you subscribe to my RSS feed (optionally with tweets from my Twitter)!
June 13th, 2009 at 5:02 pm
[…] See the original post: Fixing Geshi on line 2132 […]
June 13th, 2009 at 5:13 pm
[…] 3ts perfect for beginner Fixing Geshi on line 2132 – mitcho.com 06ቩ/2009 I recently noticed […]
June 22nd, 2009 at 2:43 pm
[…] Fixing Geshi on line 2132 Version 0.9.4にダウングレード(現在使用しているのは0.9.6)するしかないらしい。 […]
November 20th, 2009 at 10:56 pm
I just wanted to stop by and say THANKYOU! THANKYOU! THANKYOU! for posting this. I searched high and dry for a fix and you came to my rescue. I will be sure to give you a link back from my site.
January 3rd, 2010 at 6:43 am
Fixed in latest release…looks like
March 7th, 2010 at 5:29 pm
Hello, to fix this problem, i put an @ in 2132 line on geshi.php
The @, especifies that the function wich use it, does not show any warning, so, this line begin such as: @preg_match….
PS: I don´t comment any line of the php.php file