Critical error in parse_smilies() Issue Tools
issueid=22015 Sat 12th May '07 6:51am
New Member
Critical error in parse_smilies()
"overran compiling workspace" appears when installed too much smilies

Warning: preg_replace_callback() [function.preg-replace-callback]: Compilation failed: internal error: overran compiling workspace at offset 15905 in /includes/class_bbcode.php on line 474

This made forum completely unworkable. We have 1000+ smilies installed. I fixed this in includes/class_bbcode.php:

Code:
function parse_smilies($text, $do_html = false)
{
	$cache =& $this->cache_smilies($do_html);
	$this->local_smilies =& $cache;

	// replace smilies chunk by chunk
	$quoted = '';
	foreach ($cache AS $find => $replace)
	{
		$quoted .= preg_quote($find, '/');
		if ( strlen($quoted) > 1000 ) {
			$text = preg_replace_callback('/(?<!&amp|&quot|&lt|&gt|&copy|&#[0-9]{1}|&#[0-9]{2}|&#[0-9]{3}|&#[0-9]{4}|&#[0-9]{5})(' . $quoted . ')/s', array(&$this, 'replace_smilies'), $text);
			$quoted = '';
		}
	}
	if ( strlen($quoted) ) {
		$text = preg_replace_callback('/(?<!&amp|&quot|&lt|&gt|&copy|&#[0-9]{1}|&#[0-9]{2}|&#[0-9]{3}|&#[0-9]{4}|&#[0-9]{5})(' . $quoted . ')/s', array(&$this, 'replace_smilies'), $text);
	}

	return $text;
}
This is "average" way between 3.6.5 and 3.6.6. I split quoted smilies by chunks (1000 bytes here). This will prevent too long regexps (as in 3.6.6), and in the same time it's better than smilie by smilie replacing (as in 3.6.5).

Hope you'll implement this asap. Thank you.
Issue Details
Project vBulletin
Category Unknown
Status Fixed (Closed)
Priority 1 - Highest
Affected Version 3.6.6
Fixed Version 3.6.7
Users able to reproduce bug 0
Users unable to reproduce bug 0
Assigned Users (none)
Tags (none)

Mon 14th May '07 8:53am
Former vBulletin Developer
 
Fixed in SVN now. Patch attached.
Reply
Reply