【发布时间】:2015-03-27 12:58:51
【问题描述】:
我偶尔会收到 PHP 致命错误:在第 25 行的 agent.php 中调用未定义的方法 stdClass::transition()(我在代码中标记了第 25 行)。这段代码经常被调用,所以很难理解它为什么会发生。
这里是agent.php的sn-p调用
function agent_exam_complete($exam){
$ce = $exam->educational();
$ce->exam_id = $exam->exam_id;
$ce->exam_grade = $exam->score;
$ce->exams_remaining -= 1;
$ce->exam_received_date = sql_now();
if($exam->status()=='passed'){
$ce->transition('passed');
}elseif($ce->exams_remaining <= 0){
$ce->transition('failed');
}
$ce->save();
if($ce->is_certification_completed($ce->certification_id, $ce->client_no)){
agent_certification_complete($ce->certification_id, $ce->client_no);
}
}
function agent_certification_complete($certification_id, $client_no){
$ce = ClientPurchase::find('first', array('conditions' => "certification_id = '$certification_id' and is_certification = 1 and client_no='$client_no'"));
$ce->certification_date = date('Y-m-d');
$ce->transition('passed'); **//Line 25**
$ce->save();
}
transition() 在另一个文件中定义并且经常被调用。我已经包含了一些它的代码只是为了味道。
function transition($event_tag){
$old_status = $this->status;
$next_status = $this->next_status_for_transition($event_tag);
if($next_status==''){
return; }
$this->status = $next_status;
我的问题是,为什么我只是定期而不是一直收到此错误?我可以做些什么来为我的客户消除错误和随后的空白屏幕?我只注意到使用 Firefox 或 Chrome 的用户会发生这种情况。
提前致谢, 吉姆
【问题讨论】:
-
很奇怪。由于 PHP 是服务器端的,它不应该影响特定的浏览器。
-
我同意。不知道每个浏览器是否设置了可能导致问题的不同超时。抓住稻草。
-
PHP 的任何超时也将在 PHP 或 Apache 配置中设置在服务器端。日志中是否有任何错误?
-
你能把
ClientPurchase类也包括进来吗?或者更好的是,该类中的find方法返回什么? -
就是我发的那个,又来了:
PHP Fatal error: Call to undefined method stdClass::transition() in agent.php on line 25
标签: php