I have an issue that occurs randomly on a machine. After a number of reloads
of the page i can't read $this->_foo although it is set (var_dump shows it
but the script cannot read it). The code works locally and on other machines
i tested. Apache restart seems to fix it but only temporary.

Environment:

.         PHP Version 5.3.3

.         Linux 2.6.32-220.2.1.el6.x86_64 #1 SMP Fri Dec 23 02:21:33 CST
2011 x86_64

.         Apache 2.0

 

class  FooBar

    {

      protected $_foo;

      public function setFoo($bar)

      {

        if (!$bar) {

          print_r("Cannot find bar");

        }

        $this->_foo = $bar;

        if (!$this->_foo) {

          print_r("Cannot read {$this->_foo} set with $bar");

          var_dump($this);

        }

        var_dump($this);

        return $this;

      }

    }

 

    $foobar = new FooBar;

    $foobar->setFoo('bar');

 

The output when this happens would be:

 

Cannot read set with barobject(FooBar)#1 (1) { ["_foo":protected]=>
string(3) "bar" } object(FooBar)#1 (1) { ["_foo":protected]=> string(3)
"bar" }

 

I'm going nuts here, and nobody seems to be able to reproduce this. Where
should I start looking?

Reply via email to