Jerome's Blog

  • 10:49:14 pm on April 14, 2006 | # |

    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截短成事先設好的長度,就可以免除接下來的困擾。

     

Comments

  • - priv - » Blog Archive » Get Recent Comments 1:54 am on October 31, 2006 | #

    [...] Update: 我終於也遇到comment太長的問題,根據Jerome的修正我也更新了,這邊有更新好的版本,可以自行下載取用。 引用時請使用此URL [...]