Sat 12th May '07 6:51am
|
|
|
|
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('/(?<!&|"|<|>|©|&#[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('/(?<!&|"|<|>|©|&#[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.
|