dongque20030402 2009-12-17 21:01
浏览 18
已采纳

是什么导致这个奇怪的PHP致命错误?

I have a generic Logger class that looks like this:

class Logger {

  ...

  public function add($userId, $siteId, $logTypeId, $message) {
    $Log = LogMapper::create();
    $Log->setUserId($userId);
    $Log->setSiteId($siteId);
    $Log->setLogTypeId($logTypeId);
    $Log->setMessage($message);
    $Log->save();

    ...
  }

  ...

}    

And the Log class:

class Log {

  public function setUserId($userId) {
    if ($this->userId !== $userId) {
      $this->userId = $userId;
    }

    return $this;
  }

  public function getUserId() {
    return $this->userId;
  }

  public function setSiteId($siteId) {
    if ($this->siteId !== $siteId) {
      $this->siteId = $siteId;
    }

    return $this;
  }

  public function getSiteId() {
    return $this->siteId;
  }

  ...

}

As well as the LogMapper class:

class LogMapper extends DataMapper {

  ...

  public static function create($row = false) {
    return new Log($row);
  }

  public static function getById($id) {
    ...
  }

}

As you can see, I have two other classes, LogMapper and Log, which Logger uses to write records to a database.

I also have a mechanism that emails me when a fatal error occurs. I received the following in about a dozen emails:

Call to undefined method Log::setUserId()

My application uses autoloading, and I first thought that may be the problem, but clearly the Logger class is being loaded, and so autoloading has not broken. The path for the Log class is correct in the autoloader...and clearly the Log class has been loaded--otherwise a "Class 'Log' not found" error would have been thrown.

Any ideas what may be causing this error? I do use eAccelerator on the release.

  • 写回答

6条回答 默认 最新

  • duandi8852752 2009-12-17 21:50
    关注

    Long shot, but do you have PEAR's Log class installed? This is something I ran across a while back. I tried to make a 'Log' class but it was colliding with PEAR's.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了