ZF-1471: Zend_Search_Lucene::open() throws fatal error if index does not exist

Issue Type: Bug Created: 2007-05-31T22:32:47.000+0000 Last Updated: 2007-07-05T14:44:15.000+0000 Status: Resolved Fix version(s): - 1.0.0 RC2 (08/Jun/07)

Reporter: Eran Galperin (erangalp) Assignee: Alexander Veremyev (alexander) Tags: - Zend_Search_Lucene

Related issues: Attachments:


When attempting to open a Zend_Search_Lucene index that does not exist a PHP fatal error is thrown instead of an exception.

I am attempting to retrieve an index, first by trying to open it and then by trying to create it, throwing and catching Zend_Search_Lucene exceptions in the process.

<pre class="highlight">
protected function getIndex()
    try {
        $index = Zend_Search_Lucene::open($this->_indexPath);
   } catch (Zend_Search_Lucene_Exception $e) {
       try {
    $index = Zend_Search_Lucene::create($this->_indexPath);
       } catch(Zend_Search_Lucene_Exception $e) {
    $index = false;
   return $index;

However, the ::open method throws a fatal error, making such try and catch tactics futile.

The fatal error is actually thrown by the Zend_Search_Lucene_Proxy::close() method from the class destructor, which tries to commit the index on script end. Since the index does not exist a fatal error is thrown:

<pre class="highlight">
<b>Fatal error</b>:  Call to a member function close() on a non-object in <b>C:\Server\htdocs\Octabox

\library\Zend\Search\Lucene\Proxy.php</b> on line <b>71</b>

I tried to overcome the fatal error by throwing an exception if the index is not set in the Zend_Search_Lucene_Proxy::close() method, changing the method to:

<pre class="highlight">
if(isset($this -> _index)){
        $this->_index = null;
 } else {
        throw new Zend_Search_Lucene_Exception('Index is null');

But then a different fatal error is thrown... :

<pre class="highlight">
<b>Fatal error</b>:  Ignoring exception from Zend_Search_Lucene_Proxy::__destruct() while an exception

 is already active (Uncaught Zend_Search_Lucene_Exception in C:\Server\htdocs\Octabox\library\Zend\Search

\Lucene\Storage\File\Filesystem.php on line 63) in <b>C:\Server\htdocs\Octabox\library\Zend\Search\Lucene

.php</b> on line <b>166</b><br></br>

So for now I removed the exception throwing, leaving the isset check in place. This seems to work, but its a very temporary solution. Could you offer a different method to gracefully open/create an index until you resolve this issue?


Posted by Bill Karwin (bkarwin) on 2007-06-07T11:27:32.000+0000

Assign to Alexander.

Posted by Alexander Veremyev (alexander) on 2007-06-07T12:23:00.000+0000

This problem is already fixed with Changeset 5122 as a part of ZF-1492.

Please try current SVN version or wait for v1.0 RC2.

Have you found an issue?

See the Overview section for more details.


© 2006-2021 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.