[英]Call to undefined method in class even when it is defined
I am getting the following error message turning up in my apache error logs: 我的apache错误日志中出现以下错误消息:
PHP Fatal error: Call to undefined method MyWebsite\\Model\\ContentMedia::getImagePath() in /var/www/www.website.com/application/libraries/MyWebsite/Model/ContentVersion.php on line 544 PHP致命错误:在第544行的/var/www/www.website.com/application/libraries/MyWebsite/Model/ContentVersion.php中调用未定义的方法MyWebsite \\ Model \\ ContentMedia :: getImagePath()
On line 544 of ContentVersion.php
the call is made: 在ContentVersion.php
的第544行上进行了调用:
$cm->getImagePath('img', 'small');
The ContentMedia
class extends another class called Model
that does have that method: ContentMedia
类扩展了另一个名为Model
类,该类确实具有该方法:
class ContentMedia extends \MyWebsite\Model{
... the Model
class: ... Model
类:
namespace MyWebsite;
class Model{
public function getImagePath($field, $size = null){
...
}
I get this error show up every now and then in the log files, so it may be one particular instance where a user comes across this, but I don't know where. 我不时在日志文件中显示此错误,因此可能是用户遇到此错误的一个特定实例,但我不知道在哪里。 This method is used throughout the site and it works. 该方法在整个站点中都可以使用,并且有效。 If the method is definitely defined how can this error be thrown? 如果明确定义了方法,如何抛出该错误?
I thought about checking the access logs to match an exact requested URL to the timestamp of the error, but the access logs are insanely large of course, so any advice as to how to output just a chunk of time from a large access log would be amazing. 我曾考虑过检查访问日志,以将请求的确切URL与错误的时间戳进行匹配,但是访问日志当然很大,因此,有关如何从大型访问日志中仅输出大部分时间的建议是惊人。
I am using Doctrine 2 and Codeigniter 2. 我正在使用教义2和Codeigniter 2。
My first thought is to check that you definitely have an instance of model present within the script. 我的第一个想法是检查脚本中是否确实存在模型实例。 Have you tried creating another function for the sake of testing that will just echo something like "Object is instantiated and inherited functions properly". 为了测试,您是否尝试过创建另一个函数,而该函数只会回显类似“对象已正确实例化和继承的函数”之类的信息。
That way we might be able to narrow down the problem a little 这样,我们也许可以缩小问题的范围
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.