开发者

Zend_Session uncaught exception

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->defaultNames开发者_StackOverflowpace->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 />

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


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


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜