【发布时间】:2011-02-22 12:45:09
【问题描述】:
所以,我有这个代码:
} 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);
}
【问题讨论】:
-
您是否真的尝试过仅使用您提供的三行代码,中间没有
eventually的东西? -
我从未见过 die() 失败。是什么让您如此确定 purgePhotograph() 会退出?
-
@Anthony:我认为这是一个 TODO 评论,如,最终用错误页面替换
die:-) -
仅供参考,您那里有一个 SQL 注入漏洞。在 SQL 内部,它应该是
WHERE id = {$photograph_id}而不是 $this->photograph_id... -
@Josh:是的,这是一条 TODO 评论;仅使用 die 进行测试