Archive for April 14th, 2006

Recent Comments 修理日誌

recent comments出現錯誤訊息:Compilation failed: regular expression too large at offset 0 in ....
recent comments出現錯誤訊息:Compilation failed: regular expression too large at offset 0 in ….

目前網站的Recent comments一欄採用的是get recent comments 1.2 版的plugin,主系統是wordpress 1.5.2版。曾經為了修理中文字斷行問題,參考了PRIV的修改說明,更改部分的程式碼,並且一切運作正常。

今天出現了數個超長的comments,版面也因此出現了錯誤訊息。經google大神開示可能為PHP中函數「preg_match_all()」的容量上限造成。

我的解決方法如下:在檔案get-recent-comments.php中找到

$comment_excerpt = preg_replace("/[\n\t\r]/"," ",$comment_excerpt);
$comment_excerpt = preg_replace("/\s{2,}/"," ",$comment_excerpt);

在其下一行加入:

$comment_excerpt = substr($comment_excerpt,0,$chars_per_comment);

其原理為在呼叫函數utf8_wordwrap之前,先把comment截短成事先設好的長度,就可以免除接下來的困擾。

1 comment April 14th, 2006


Calendar

April 2006
S M T W T F S
« Mar   May »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Posts by Month

Posts by Category

Copyright