Issues

ZF-3528: Fatal error: Call to a member function createFile() on a non-object

Description

I get the following error:

Fatal error: Call to a member function createFile() on a non-object in D:\websites\site.com\core_lib\Zend\Search\Lucene\LockManager.php on line 56

when I run this code:

    public function delete($item_id)
    {
        $hits = $this->lucene->find('product_id:'.$item_id);
        $hit_count = count($hits);
        if ($hit_count)
        {
            foreach ($hits as &$hit)
            { $this->lucene->delete($hit->id); 
        }

        return $hit_count;
    }

This error only seems to happen when there's an indexed item that needs to be deleted. when there's 0 results matched, no error.

I'm using wind2k3 standard with php 5.2.6

Comments

I have similar issue to ZF-3528.

Code:

public static function deleteSingleGroupTags($boardID, $index) { $term = new Zend_Search_Lucene_Index_Term($boardID, 'boardID'); $query = new Zend_Search_Lucene_Search_Query_Term($term); $hits = array(); $hits = $index->find($query); foreach ($hits as $hit) $index->delete($hit->id); $index->commit(); }

public static function updateSingleGroupTags($boardID, $index) {

self::deleteSingleGroupTags($boardID, $index);

$tagString = groupsHandler::getGroupTagsAsString($boardID);
$group = groupsHandler::getSingleGroupByID($boardID);
$doc = new Zend_Search_Lucene_Document();

$doc->addField(Zend_Search_Lucene_Field::Keyword('boardID', $boardID));
$doc->addField(Zend_Search_Lucene_Field::Text('tags', $tagString, 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('title', hackFunctions::hack_stringToLower(strip_tags($group['title'])), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('description', hackFunctions::hack_stringToLower(strip_tags($group['description'])), 'utf-8'));
$index->addDocument($doc);

}

Here is how it works: This error occures after a call to addDocument(). The problem is that private variable $_directory is NULL after return from deleteSingleGroupTags().

If I move all code form deleteSingleGroupTags() to deleteSingleGroupTags() variable $_directory is present and addDocument() works fine.

If i call deleteSingleGroupTags() and check for $_directory one line before return form funcion it is present, but it disappears just after return from function. So I'm not sure if this is ZEND or PHP issue. Variable $_directory dissapears only after $index->find() returns any hits. It doesn't matter if I try to delete those hits. It will always fail if I call find().

Tested on versions: ZF 1.5.0 PR ZF 1.5.0 ZF 1.5.3 ZF 1.6.2 ZF 1.7.1 PHP 2.5.2 Vista Home Premium: Windows NT 6.0 build 6001

To above comment: PHP is 5.2.5 of course :)

Is this still an issue?

If so, how are you setting up your instance of Zend_Search_Lucene? The problem the original poster describes can occur when the $directory constructor argument passed to that class is not a string nor an instance of Zend_Search_Lucene_Storage_Directory_Filesystem.