3

Stumped by this one. This code is giving me

PHP Fatal error: Call to undefined method MyObject::helloWorld()

But only the second time I run it, the first time it runs fine.

class MyObject
{

  function __construct()
  {
    echo("creating MyObject...");
  }


  public function helloWorld()
  {
    echo("Hello World!");
  }


}

$obj = new MyObject();
$obj->helloWorld();

I also see "creating MyObject..." generated the second time, but not "Hello World!".

I'm in the process of upgrading to PHP 5.4.0.

I Must be missing something really obvious.

hakre
  • 193,403
  • 52
  • 435
  • 836
Bill
  • 393
  • 4
  • 13

1 Answers1

11

This is APC bug... you can apply a patch or disable APC in /etc/php.ini or /etc/php.d/apc.ini depending on your configs.

The first time you run your script the opcode is getting generated and is cached by APC, the second time you run your script opcode is pulled from APC cache. Because APC cache is bad your script fails on the seconds run.

See this bugs for references php #61219 and php #60658

Alex
  • 6,441
  • 2
  • 25
  • 26
  • Yep. That was totally it. Thanks Alex! – Bill Apr 27 '12 at 17:47
  • @alex: Your help is required ;) http://stackoverflow.com/questions/11147549/anyone-successfully-serving-high-traffic-with-php-5-4-4-and-apc-3-1-10 – hakre Jun 21 '12 at 22:16