- 追加された行はこの色です。
- 削除された行はこの色です。
*PHP 5.0.4 バグ対策&添付ファイルダウンロード等の効率化 [#o0ea77b9]
-ページ: [[BugTrack2]]
-投稿者: [[三浦克介]]
-優先順位: 低
-状態: 提案
-カテゴリー: 本体バグ
-投稿日: 2005-08-29 (月) 21:30:53
-バージョン:
**メッセージ [#h2718e23]
PHP 5.0.4 には、readfile() や fpassthru() が 2000000 バイトで停止してしまうというバグがあるらしいです。
http://bugs.php.net/bug.php?id=32553
プラグイン attach, dump, ref で readfile が使われており、例えば、2000000バイトを越える添付ファイルをダウンロードすると、2000000バイトで切れてしまいます。
PHP 5.0.4 以外では大丈夫だと思いますが、readfile はファイル内容を一度メモり上に読み込みますので、あまり、サーバーに優しくありません。また、readfile よりも、echo fread() を繰り返した方が高速らしいです。
http://jp.php.net/readfile
という訳で、readfile を使っている部分を、echo fread() で置き換えませんか?
例えば、attach.inc.php は以下のようになります。
Index: attach.inc.php
===================================================================
RCS file: /cvsroot/pukiwiki/pukiwiki/plugin/attach.inc.php,v
retrieving revision 1.79
diff -c -r1.79 attach.inc.php
*** attach.inc.php 8 Aug 2005 14:54:15 -0000 1.79
--- attach.inc.php 29 Aug 2005 11:58:59 -0000
--- attach.inc.php 29 Aug 2005 12:32:28 -0000
***************
*** 659,665 ****
header('Content-Length: ' . $this->size);
header('Content-Type: ' . $this->type);
! @readfile($this->filename);
exit;
}
}
--- 659,675 ----
--- 659,672 ----
header('Content-Length: ' . $this->size);
header('Content-Type: ' . $this->type);
! // @readfile($this->filename);
!
! $handle = fopen($this->filename, 'rb') or die;
! $handle = fopen($this->filename, 'rb');
! while (!feof($handle))
! {
! $buffer = fread($handle, 4096);
! echo $buffer;
! echo fread($handle, 4096);
! flush();
! }
! fclose($handle);
!
exit;
}
}
fopen できなかった時はどうすべきですかね? @readfile となっているのに合わせて、なにも表示せずに exit?
**参考 [#kf367aea]
-[[BugTrack2/70]]
----
-(性能を検討した上で)[[BugTrack/779]] -- &new{2005-08-30 (火) 00:15:57};
#comment