间歇性PHP抽象类错误 [英] Intermittent PHP Abstract Class Error

查看:70
本文介绍了间歇性PHP抽象类错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力解决这个问题,但无法弄清楚,也许其他人遇到了问题,或者Slim,PHP,Apache等存在更深的问题.工作了几个小时之后,我的Slim安装将在所有路线上开始提供该信息:

I've been fighting this for a bit, and can't figure it out, maybe someone else has or maybe there's a deeper issue here with Slim, PHP, Apache etc. After working just fine for hours, my Slim install will start giving this on all routes:

致命错误:Slim \ Collection类包含1个抽象方法,因此必须声明为abstract或实现F:\ Projects \ example \ server \ vendor \ slim \ slim \ Slim \ Collection中的其余方法(IteratorAggregate :: getIterator) .php行21

Fatal error: Class Slim\Collection contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (IteratorAggregate::getIterator) in F:\Projects\example\server\vendor\slim\slim\Slim\Collection.php on line 21

更有什者,如果我重新启动Apache,此问题将消失. (反正要几个小时.)

Maddeningly this issue goes away if I restart Apache. (For a few hours anyway.)

我发现这是两年前有人遇到类似问题的地方,帮助该人的人在没有实际帮助的情况下给他们加了徽章:

I found this where someone had a similar problem two years ago, and the person helping badgered them without actually assisting at all: https://community.apachefriends.org/viewtopic.php?p=250966&sid=96ef58aaeb7fe142a7dcdfd506a8683f

我尝试进行彻底擦除并安装我的作曲家供应商目录.这不能解决.我可以清楚地看到错误消息中的文件中已按预期实现了getIterator.

I've tried doing a clean wipe and install of my composer vendor directory. This doesn't fix it. I can clearly see that getIterator is implemented as expected in the file in the error message.

PHP版本7.0.12,Windows 7,x86 PHP Build

PHP Version 7.0.12, Windows 7, x86 PHP Build

几个小时后又发生了一次,但出现了不同但相似的错误消息:

It happened again after a few hours, with a different but similar error message:

致命错误:类Pimple \ Container包含1个抽象方法,因此必须声明为抽象或实现F:\ Projects \ example \ server \ vendor \ pimple \ pimple \ src \ Pimple中的其余方法(ArrayAccess :: sqlserver) \ Container.php,第34行

Fatal error: Class Pimple\Container contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (ArrayAccess::sqlserver) in F:\Projects\example\server\vendor\pimple\pimple\src\Pimple\Container.php on line 34

这个问题有一个类似的问题,可以通过重新启动PHP来解决",但这显然不是一个实际的解决方案,并且我没有启用opcache: PHP 7 ,Symfony 3:致命错误1抽象方法,因此必须声明为抽象方法或实现其余方法

This question has a similar problem and "solves" it by restarting PHP, but that clearly isn't an actual solution, and I don't have opcache enabled: PHP 7, Symfony 3: Fatal error 1 abstract method and must therefore be declared abstract or implement the remaining methods

有没有猜到?切记:此消息位于我未写的文件中,并且在Apache重新启动时消失了.使用PHP 7进行缓存会导致这种情况吗?

Any guesses? Remember: This message is in files I didn't write, and goes away on Apache restart. Is there some caching with PHP 7 that would cause this?

编辑3/10/17:

是的,我已经和Slim开了张票.我也在非修身文件(Pimple)中看到了它,所以我认为这不是修身问题. https://github.com/slimphp/Slim/issues/2160

Yes, I've opened a ticket with Slim. I also saw it in a non-slim file (Pimple) so I don't think it is a Slim issue. https://github.com/slimphp/Slim/issues/2160

正如我所说,我的操作缓存已关闭.我已经在php.ini文件和phpinfo()中确认了这一点.

As I said, my opcache is off. I've confirmed this is true both in the php.ini file and looking at phpinfo().

推荐答案

我认为您遇到了

I think you've run into this opcache bug. This isn't exactly the same situation but probably related.

在调用opcache_reset()函数之后,我们遇到了一些奇怪的错误. 它随机发生在服务器上(400台服务器中的10台)

After calling opcache_reset() function we encounter some weird errors. It happens randomly on servers (10 of 400 servers production)

某些字母a被其他字母替换,Class似乎已经声明. 等等

Some letter a replaced by others, Class seems to be already declared.. etc

opcache_reset()之后触发的错误示例:

Example of errors triggered after opcache_reset():

  • PHP致命错误:类XXX包含1个抽象方法,因此必须声明为抽象或实现其余方法 第20行的/dir/dir/x.php中的(YYY :: funczzz)
  • PHP Fatal error: Class XXX contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (YYY::funczzz) in /dir/dir/x.php on line 20

由于开发人员没有足够的信息来复制该票证,因此该票证已关闭.如果您能提出最小的可复制案例,我建议报告.创建一个非常小的Slim应用程序,然后使用JMeter或其他工具发出许多请求.发表您的发现.

The ticket is closed because the developers don't have enough information to reproduce it. If you could come up with the smallest reproducible case I recommend reporting it. Create a very small Slim app and then use JMeter or another tool to make many requests. Post your findings.

同时,唯一的解决方法可能是关闭php.ini中的opcache:

Meanwhile the only workaround might be to turn off opcache in php.ini:

opcache.enable=0

当然,这将严重损害性能.在修复之前,您必须在性能还是定期重新启动Apache之间进行选择.

Of course this will drastically hurt performance. Until it's fixed you'll have to choose between performance or periodically restarting Apache.

如果关闭缓存不起作用,那么我想到的唯一原因是操作码编译器出现间歇性问题.缓存或未缓存的编译版本中必定有错误.如果这是原因,那么与PHP开发人员一起打开可复制的凭单或自行调试PHP源代码将是唯一的解决方法.

If turning the cache off doesn't work then the only cause I could think of is an intermittent problem with the opcode compiler. Cached or not the compiled version must have an error in it. Opening a reproducible ticket with the PHP devs or debugging the PHP source yourself would be the only way forward if this is the cause.

这篇关于间歇性PHP抽象类错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆