Recent Comments 修理日誌

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

Entry Filed under: 網路

1 Comment Add your own

  • 1. - priv - » Blog Arc&hellip  |  October 31st, 2006 at 1:54 am

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

Leave a Comment

Required

Required, hidden

Powered by WP Hashcash

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

September 2010
S M T W T F S
« Jan    
 1234
567891011
12131415161718
19202122232425
2627282930  

Most Recent Posts

Copyright