質問
だから、私はこのコードを持っています:
} else {
$photograph_moderation = new PhotographModeration($this->photograph_id);
$photograph_moderation->purgePhotograph();
//eventually take to an error page
die('image is not big enough to upload');
}
purgephotograph()関数は、この条件が満たされたときに適切に呼び出されますが、スクリプトは死ぬようには見えません。死ぬことがここで呼ばれない理由はありますか? purgephotograph()には、スクリプトキリングコマンドもありません。
これがpurge_photograph関数です:
public function purgePhotograph() {
$db = Connect::connect();
$photograph_id = $db->real_escape_string($this->photograph_id);
$query = "SELECT * from photographs WHERE id='{$this->photograph_id}'";
$result = $db->query($query);
$photograph = $result->fetch_assoc();
if ($photograph['location'])
unlink($photograph['location']);
if ($photograph['thumbnail_location'])
unlink($photograph['thumbnail_location']);
if ($photograph['watermark_location'])
unlink($photograph['watermark_location']);
if ($photograph['xsmall_location'])
unlink($photograph['xsmall_location']);
if ($photograph['small_location'])
unlink($photograph['small_location']);
if ($photograph['medium_location'])
unlink($photograph['medium_location']);
if ($photograph['large_location'])
unlink($photograph['large_location']);
if ($photograph['xlarge_location'])
unlink($photograph['xlarge_location']);
if ($photograph['xxlarge_location'])
unlink($photograph['xxlarge_location']);
if ($photograph['xxxlarge_location'])
unlink($photograph['xxxlarge_location']);
$query = "DELETE from photographs WHERE id='{$this->photograph_id}'";
$result = $db->query($query);
$query = "DELETE from photograph_tags WHERE photograph_id='{$this->photograph_id}'";
$result = $db->query($query);
}
解決
たぶん今がインストールする時です PHPデバッガーモジュール 問題のコードに足を踏み入れます。
xdebug そして例えば netbeans フロントエンドが十分に機能するので。
他のヒント
purgephotograph()が返されるかどうかを確認します。多分それはデッドループを持っているか、本当に長い時間がかかるでしょう。
うわー、問題はpurgephotograph()が返されなかったことでした。最後に。これが実行するためにこれが必要であるとは知りませんでした。
トライ/キャッチブロックに入れてみてください。たぶん、死ぬことができる前に何かが例外を投げかけているかもしれません。
エラーが発生していますか?
所属していません StackOverflow