views:

24

answers:

2

So I have this in my index.php:

Zend_Session::start();

Then in one of my controllers in the init method I do:

if (false === isset($this->defaultNamespace->tree)) {
    $this->defaultNamespace->tree = array();
}

Which still works. But then in action in the same controller I write this:

unset($this->defaultNamespace->tree); // I tried commenting this line
$this->defaultNamespace->tree = $this->tree;

And I get an exception like this:

<br />
<b>Fatal error</b>:  Uncaught exception 'Zend_Session_Exception' with message 'Zend_Session::start() - D:\data\o\WebProjects\elearning\public\index.php(Line:22): Error #2 include() [&lt;a href='function.include'&gt;function.include&lt;/a&gt;]: Failed opening 'SlideQuestion.php' for inclusion (include_path='D:\data\o\WebProjects\elearning/../../library;D:\data\o\WebProjects\elearning/application/../library;.;C:\php\pear;D:\data\o\WebLib\ZendFramework\library;') Array' in D:\data\o\WebLib\ZendFramework\library\Zend\Session.php:493
Stack trace:
#0 D:\data\o\WebProjects\elearning\public\index.php(26): Zend_Session::start()
#1 {main}
  thrown in <b>D:\data\o\WebLib\ZendFramework\library\Zend\Session.php</b> on line <b>493</b><br />

What the hell? Any ideas?

The $this->tree is a property contains an array with some objects in it.

A: 

The file SlideQuestion.php couldnt be included. The library include paths is wrong.

include_path='D:\data\o\WebProjects\elearning/../../library;

Should be

include_path='D:\data\o\WebProjects\elearning\..\..\library;
streetparade
No that's certainly not the problem. When I comment the line $this->defaultNamespace->tree = $this->tree; everything works. I can do var_dump($this->tree) and everything is ok.
Richard Knop
+1  A: 

Ok, I think I nailed the problem.

Apparently it was a problem with encoding (as it's been the case too often lately...). Zend_Session probably can only accept UTF-8 encoded data. Some objects in the array had Windows-1250 strings in their properties.

I just looped the objects with foreach and changed them to UTF-8:

foreach ($array as $obj) {
    foreach ($obj as $property => $value) {
        if (is_string($value)) {
            $obj->$property = iconv('Windows-1250', 'UTF-8', $value);
        }
    }
}

And now it works fine.

Damn internationalized applications that were written with non standard encoding (other than UTF-8, usually Windows-1250) :P

Richard Knop