<commit_before><?php
/*
 * This file is part of the sfLucenePlugin package
 * (c) 2007 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * Responsible for handling Doctrine's behaviors.
 * @package    sfLucenePlugin
 * @subpackage Behavior
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 */
class sfLuceneDoctrineListener extends Doctrine_Record_Listener
{
  /**
   * Executes save routine
   */
  public function postSave(Doctrine_Event $event)
  {

    try {
      $this->saveIndex($event->getInvoker());
    } catch(sfException $e) {
      // no context define, cannot do anything,
    }
  }

  /**
   * Deletes the object
   */
  public function postDelete(Doctrine_Event $event)
  {
    try {
      $this->deleteIndex($event->getInvoker());
    } catch(sfException $e) {
      // no context define, cannot do anything
    }
    
  }

  /**
   * Saves index by deleting and inserting.
   */
  public function saveIndex($node)
  {
    $this->deleteIndex($node);
    $this->insertIndex($node);
  }

  /**
  * Deletes the old model
  */
  public function deleteIndex($node)
  {
    if(sfConfig::get('app_sfLucene_disable_listener', false))<commit_msg>sfLucenePlugin (solr branch) : write to the log when solr raise an error, do not throw an exception anymore<commit_after><?php
/*
 * This file is part of the sfLucenePlugin package
 * (c) 2007 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * Responsible for handling Doctrine's behaviors.
 * @package    sfLucenePlugin
 * @subpackage Behavior
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 */
class sfLuceneDoctrineListener extends Doctrine_Record_Listener
{
  /**
   * Executes save routine
   */
  public function postSave(Doctrine_Event $event)
  {

    try {
      $this->saveIndex($event->getInvoker());
    }
    catch(Exception $e) {
      // no context define, cannot do anything,
      if(sfContext::hasInstance())
      {
        sfContext::getInstance()->getLogger()->crit('{sfLuceneDoctrineListener::postSave} Error while saving document to solr : '.$e->getMessage());
      }
    }

  }

  /**
   * Deletes the object
   */
  public function postDelete(Doctrine_Event $event)
  {
    try {
      $this->deleteIndex($event->getInvoker());
    } catch(Exception $e) {
      // no context define, cannot do anything
      if(sfContext::hasInstance())
      {
        sfContext::getInstance()->getLogger()->crit('{sfLuceneDoctrineListener::postSave} Error while deleting document to solr : '.$e->getMessage());
      }
    }
    
  }

  /**
   * Saves index by deleting and inserting.
   */
  public function saveIndex($node)
  {
    $this->deleteIndex($node);
    $this->insertIndex($node);
  }

  /**
  * Deletes the old model
  */
  public function deleteIndex($node)
  {
    if(sfConfig::get('app_sfLucene_disable_listener', false))
{'fraction_non_alphanumeric': 0.13053460150869137, 'fraction_numerical': 0.0026238110856018366, 'mean_word_length': 3.099462365591398, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1452728', 'n_tokens_mistral': 945, 'n_tokens_neox': 916, 'n_words': 248}