Intermittent PHP Abstract Class Error

前端 未结 4 1976
旧时难觅i
旧时难觅i 2020-11-29 10:24

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 fin

4条回答
  •  春和景丽
    2020-11-29 10:38

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

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

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

    Example of errors triggered after opcache_reset():

    • 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

    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.

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

    opcache.enable=0
    

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

    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.

提交回复
热议问题