blog

Posts Tagged ‘error’

Fixing Geshi on line 2132

Saturday, June 13th, 2009

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 &lt;?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.

Modifiying WordPress plugin activation behavior

Saturday, January 5th, 2008

As I continue to work on and debug Yet Another Related Posts Plugin and WP-Smartdate, I’ve come across an issue where plugin activation fails, but I get no useful error message.

When I try to activate the plugin, I am redirected to a url of the type /plugins.php?error=true&plugin=...&_error_nonce=.... This redirect just gives me the plugins control panel with my plugin still disactivated, and with no useful error message.1 This apparently is an issue with the Plugin Protection mechanism introduced in WP 2.2. A quick fix (hack) is available on the WP forums.

Here’s hoping this helps some people scratching their heads, and that this behavior is reconsidered/fixed in future releases.


  1. Apparently some people get a message like “Plugin could not be activated because it triggered a fatal error.” 


© 2006–2011 mitcho (Michael 芳貴 Erlewine).
Proudly powered by WordPress on Media Temple.
The views expressed on these pages are mine alone and do not
reflect those of my employers and clients, past and present.