Development

Changeset 6657

You must first sign up to be able to contribute.

Changeset 6657

Show
Ignore:
Timestamp:
12/21/07 07:46:45 (1 year ago)
Author:
Carl.Vondrick
Message:

Fixed sfLucene does not handle changed categories (closes #2687)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfLucenePlugin/branches/1.1/CHANGELOG

    r6525 r6657  
    1313  * Minor refactoring of sfLucene class to move to sfParameterHolder 
    1414  * Upgraded forms to sfForm 
     15  * Fixed sfLucene does not handle changed categories (closes #2687) 
    1516 
    1617Version 0.1.1 Beta 
  • plugins/sfLucenePlugin/branches/1.1/lib/addon/Zend/Search/Lucene/sfLuceneDirectoryStorage.class.php

    r6384 r6657  
    2323      parent::__construct($path); 
    2424 
    25       if (is_dir($path) && substr(sprintf('%o', fileperms($path)), -4) != '0777') 
    26       { 
    27         if (!@chmod($path, 0777)) 
    28         { 
    29           ini_set('track_errors', $trackErrors); 
    30           throw new sfException(sprintf('Unable to chmod file "%s".  Permissions are already %o', $path, fileperms($path))); 
    31         } 
    32       } 
     25      sfLuceneStorageFilesystem::chmod($path, 0777); 
    3326    } 
    3427 
     
    5043        $trackErrors = ini_get('track_errors'); ini_set('track_errors', '1'); 
    5144 
    52         if (file_exists($this->_dirPath . '/' . $filename) && substr(sprintf('%o', fileperms($this->_dirPath . '/' . $filename)), -4) != '0777') 
    53         { 
    54           if (!@chmod($this->_dirPath . '/' . $filename, 0777)) 
    55           { 
    56             ini_set('track_errors', $trackErrors); 
    57             throw new sfException(sprintf('Unable to chmod file "%s".  Permissions are already %o', $this->_dirPath . '/' . $filename, fileperms($this->_dirPath . '/' . $filename))); 
    58           } 
    59         } 
     45        sfLuceneStorageFilesystem::chmod($this->_dirPath, 0777); 
    6046 
    6147        ini_set('track_errors', $trackErrors); 
  • plugins/sfLucenePlugin/branches/1.1/lib/addon/Zend/Search/Lucene/sfLuceneFileStorage.class.php

    r6384 r6657  
    2222    parent::__construct($filename, $mode); 
    2323 
    24     if (file_exists($filename) && substr(sprintf('%o', fileperms($filename)), -4) != '0777') 
    25     { 
    26       if (!@chmod($filename, 0777)) 
    27       { 
    28         throw new sfException(sprintf('Unable to chmod file "%s".  Permissions are already %o', $filename, fileperms($filename))); 
    29       } 
    30     } 
     24    sfLuceneStorageFilesystem::chmod($filename, 0777); 
    3125  } 
    3226} 
  • plugins/sfLucenePlugin/branches/1.1/lib/indexer/sfLuceneActionIndexer.class.php

    r6489 r6657  
    5050    extract($this->getActionProperties()); 
    5151 
    52     if ( $this->deleteGuid( $this->getGuid($params) ) && $this->shouldLog()
     52    if ( $this->deleteGuid( $this->getGuid($params) )
    5353    { 
    5454      $formatter = new sfAnsiColorFormatter(); 
     
    5959        )) 
    6060      ); 
    61  
    62       $categories = $this->getModelCategories(); 
    63  
    64       foreach ($categories as $category) 
    65       { 
    66         $this->removeCategory($category); 
    67       } 
    6861    } 
    6962 
     
    108101      $doc->addField( $this->getLuceneField('text', 'sfl_category', implode(', ', $categories)) ); 
    109102    } 
     103 
     104    $doc->addField( $this->getLuceneField('unindexed', 'sfl_categories_cache', serialize($categories)) ); 
    110105 
    111106    $guid = $this->getGuid($params); 
  • plugins/sfLucenePlugin/branches/1.1/lib/indexer/sfLuceneIndexer.class.php

    r6579 r6657  
    129129    foreach ($hits as $hit) 
    130130    { 
    131       $timer = sfTimerManager::getTimer('Zend Search Lucene'); 
     131      $categories = unserialize($hit->sfl_categories_cache); 
     132 
     133      foreach ($categories as $category) 
     134      { 
     135        $this->removeCategory($category); 
     136      } 
     137 
    132138      $this->getLucene()->delete($hit->id); 
    133       $timer->addTime(); 
    134139    } 
    135140 
  • plugins/sfLucenePlugin/branches/1.1/lib/indexer/sfLucenePropelIndexer.class.php

    r6583 r6657  
    130130      } 
    131131 
    132       $doc->addField( $this->getLuceneField('text', 'sfl_category', implode(', ', $categories)) ); 
    133     } 
     132      $doc->addField( $this->getLuceneField('text', 'sfl_category', implode(' ', $categories)) ); 
     133    } 
     134 
     135    $doc->addField( $this->getLuceneField('unindexed', 'sfl_categories_cache', serialize($categories)) ); 
    134136 
    135137    $doc->addField($this->getLuceneField('unindexed', 'sfl_model', $this->getModelName())); 
     
    140142    $this->addDocument($doc, $this->getModelGuid()); 
    141143 
    142     $formatter = new sfAnsiColorFormatter(); 
    143  
    144     $this->getContext()->getEventDispatcher()->notify( 
    145       new sfEvent($this, 'command.log', array( 
    146         $formatter->formatSection('indexer', sprintf('Inserted model "%s" with PK = %s', $this->getModelName(), $this->getModel()->getPrimaryKey())) 
    147       )) 
    148     ); 
     144// Intentional regression: this needs major clean up! 
     145//     $formatter = new sfAnsiColorFormatter(); 
     146// 
     147//     $this->getContext()->getEventDispatcher()->notify( 
     148//       new sfEvent($this, 'command.log', array( 
     149//         $formatter->formatSection('indexer', sprintf('Inserted model "%s" with PK = %s', $this->getModelName(), $this->getModel()->getPrimaryKey())) 
     150//       )) 
     151//     ); 
    149152 
    150153    // restore culture in symfony i18n detection 
     
    166169    { 
    167170      // TODO: Clean this up 
    168       $formatter = new sfAnsiColorFormatter(); 
    169  
    170       $this->getContext()->getEventDispatcher()->notify( 
    171         new sfEvent($this, 'command.log', array( 
    172           $formatter->formatSection('indexer', sprintf('Deleted model "%s" with PK = %s', $this->getModelName(), $this->getModel()->getPrimaryKey())) 
    173         )) 
    174       ); 
    175  
    176       $categories = $this->getModelCategories(); 
    177  
    178       foreach ($categories as $category) 
    179       { 
    180         $this->removeCategory($category); 
    181       } 
     171// Intentional regression: this needs major clean up! 
     172//       $formatter = new sfAnsiColorFormatter(); 
     173// 
     174//       $this->getContext()->getEventDispatcher()->notify( 
     175//         new sfEvent($this, 'command.log', array( 
     176//           $formatter->formatSection('indexer', sprintf('Deleted model "%s" with PK = %s', $this->getModelName(), $this->getModel()->getPrimaryKey())) 
     177//         )) 
     178//       ); 
    182179    } 
    183180 
  • plugins/sfLucenePlugin/branches/1.1/lib/storage/sfLuceneStorageFilesystem.class.php

    r6489 r6657  
    2020  protected $file; 
    2121 
    22   public function __construct($file) 
     22  protected $mode; 
     23 
     24  public function __construct($file,  $mode = 0777) 
    2325  { 
    2426    $this->file = $file; 
     27    $this->mode = $mode; 
    2528  } 
    2629 
     
    3942    $this->mkdir(dirname($this->file)); 
    4043 
    41     return file_put_contents($this->file, $data); 
     44    $retval = file_put_contents($this->file, $data); 
     45 
     46    self::chmod($this->file, $this->mode); 
     47 
     48    return $retval; 
    4249  } 
    4350 
     
    5461    } 
    5562 
    56     return mkdir($dir, 0777, true); 
     63    return mkdir($dir, $this->mode, true); 
     64  } 
     65 
     66  static public function chmod($file, $mode) 
     67  { 
     68    if (file_exists($file) && substr(sprintf('%o', fileperms($file)), -4) != sprintf('%o', $mode)) 
     69    { 
     70      chmod($file, 0777); 
     71    } 
    5772  } 
    5873}