1

[Update 18.01.14] This question was marked a duplicate of Intermittent PHP Abstract Class Error . However, they are different in much of the bug appearance as follows.

  1. That link only have contains x abstract method error. But mine have more types, and the errors are more weird (see the errors below, even containing some control characters).
  2. In that link, the questioner said disabling opcache will make it happen less frequently. But in my case I did never enable the opcache but these bugs happened.

[/Update]

I am using Apache, PHP, Laravel to develop my web backend. But several times a day, errors will occur saying some php built-in functions are undefined, but at other time when it is not mad, these functions are obviously defined and work well. (So it is not because I call something really undefined!)

There are even stranger things. The "undefined" things can be a php function, system constant, or even some strange strings which look like regex, or even control characters in ASCII! The examples are as follows.

  1. Declaration of PDO::() should be compatible with PDO::?)[CHAR1][CHAR2] where the [CHAR1] and [CHAR2] are SOHand ETX in ASCII.
  2. Call to undefined method #^\\{\\w+\\}#::format()
  3. Call to undefined method DateTime::format()
  4. Undefined class constant 'PDO::ERRMODE_EXCEPTION'
  5. (Other types of errors) Class Doctrine\DBAL\Driver\PDOStatement contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Doctrine\DBAL\Driver\Statement::errorInfo, Doctrine\DBAL\Driver\ResultStatement::closeCursor)

Here are some more information: It usually happens every several hours, but can happen in half an hour or do not happen for half a day. My server handles about 1 http GET or POST request every second from one of the 6 remote machines.

This annoys me for a very long time and I would appreciate it if anyone could help me! Thank you so much!

ch271828n
  • 15,854
  • 5
  • 53
  • 88
  • It can be cause of wrong name spacing, If you want to use function / class from global scope - you should use \ (back slash) before calling, for example \PDO:: instead of PDO:: – Alex Slipknot Jan 12 '18 at 13:35
  • @AlexSlipknot However, it works pretty well during most of the time, and without modifying any code, it suddenly goes mad and throws this error. – ch271828n Jan 12 '18 at 13:42
  • Well, it will be great if there is some stack trace for those errors. So you can get exact problem – Alex Slipknot Jan 12 '18 at 14:43
  • I was bitten by a variant of this behaviour, and the solution *might* be the same: https://stackoverflow.com/a/48250183/1428679 – LSerni Jan 14 '18 at 13:44
  • @LSerni But the problem exists **when I was not using opcache at all**. But anyway thank you for your suggestion and I will try it. :) – ch271828n Jan 14 '18 at 13:47
  • Do you have any kind of caching or "make-php-go-faster" trick installed? The behaviour I got - and looks like the one you reported - was due to a class being loaded which was **not** the class we intended, but "similar enough" for the system not to realize this. Your error #4 hints at PDO not being loaded, while #5 hints at *two* different PDOStatement classes existing. Also, `format` does exist in standard DateTime, and your error #3 strongly hints at a different DateTime being in existence in the same namespace. – LSerni Jan 14 '18 at 13:55
  • @LSerni Ha! I think your statement is quite strong, and I will try it out in a few days. Thank you very much! :) – ch271828n Jan 14 '18 at 14:02

0 Answers0