<commit_before><?php
class Vps_Component_ModelObserver
{
    /**
     * @var Vps_Component_ModelObserver
     */
    static private $_instance;
    private $_process = array(
        'insert' => array(),
        'update' => array(),
        'delete' => array(),
        'save'   => array()
    );
    private $_skipFnF = true;
    private $_processed = array();
    private $_disableCache = false; // für Tests

    public static function getInstance()
    {
        if (!self::$_instance) {
            self::$_instance = new self();
        }
        return self::$_instance;
    }

    //für tests
    public function setSkipFnF($v)
    {
        $this->_skipFnF = $v;
    }

    //für tests
    public function setDisableCache($disable)
    {
        $this->_disableCache = $disable;
    }

    public function clear()
    {
        foreach (array_keys($this->_process) as $i) {
            $this->_process[$i] = array();
        }
        $this->_processed = array();
    }


    public function insert($source)
    {
        $this->_process['insert'][] = $source;
    }

    public function update($source)
    {
        $this->_process['update'][] = $source;
    }

    public function save($source)
    {
        $this->_process['save'][] = $source;
    }

    public function delete($source)
    {
        // Wird hier direkt aufgerufen, weil wenn später aufgerufen, ist row schon gelöscht
        if (!Vps_Component_Data_Root::getComponentClass()) return;
        $this->_processCache($source);
    }

    protected function _processCache($source)
    {
        if ($source instanceof Vps_Model_Interface) {
            $model = $source;
            $id = null;
        } else {
            $row = $source;
            if ($row instanceof Zend_Db_Table_Row_Abstract) {
                $model = $row->getTable();
                $primary = current($model->info('primary'));
            } else {
                $model = $row->getModel();
                $primary = $model->getPrimaryKey();
                if (get_class($model) == 'Vps_Model_Db') $model = $model->getTable();
                if ($model instanceof Vps_Component_Cache_MetaModel ||
                    $model instanceof Vps_Component_Cache_Model ||
                    ($model instanceof  Vps_Model_Field && !$primary)
                ) {
                    return array();
                }
            }
            $id = is_array($primary) ? null : $row->$primary;
            $componentId = isset($row->component_id) ? $row->component_id : null;
        }
        if (get_class($model) == 'Vps_Db_Table') return array();<commit_msg>Observer hatte Bug beim Rausfiltern von CacheModels<commit_after><?php
class Vps_Component_ModelObserver
{
    /**
     * @var Vps_Component_ModelObserver
     */
    static private $_instance;
    private $_process = array(
        'insert' => array(),
        'update' => array(),
        'delete' => array(),
        'save'   => array()
    );
    private $_skipFnF = true;
    private $_processed = array();
    private $_disableCache = false; // für Tests

    public static function getInstance()
    {
        if (!self::$_instance) {
            self::$_instance = new self();
        }
        return self::$_instance;
    }

    //für tests
    public function setSkipFnF($v)
    {
        $this->_skipFnF = $v;
    }

    //für tests
    public function setDisableCache($disable)
    {
        $this->_disableCache = $disable;
    }

    public function clear()
    {
        foreach (array_keys($this->_process) as $i) {
            $this->_process[$i] = array();
        }
        $this->_processed = array();
    }


    public function insert($source)
    {
        $this->_process['insert'][] = $source;
    }

    public function update($source)
    {
        $this->_process['update'][] = $source;
    }

    public function save($source)
    {
        $this->_process['save'][] = $source;
    }

    public function delete($source)
    {
        // Wird hier direkt aufgerufen, weil wenn später aufgerufen, ist row schon gelöscht
        if (!Vps_Component_Data_Root::getComponentClass()) return;
        $this->_processCache($source);
    }

    protected function _processCache($source)
    {
        if ($source instanceof Vps_Model_Interface) {
            $model = $source;
            $id = null;
        } else {
            $row = $source;
            if ($row instanceof Zend_Db_Table_Row_Abstract) {
                $model = $row->getTable();
                $primary = current($model->info('primary'));
            } else {
                $model = $row->getModel();
                $primary = $model->getPrimaryKey();
                if (get_class($model) == 'Vps_Model_Db') $model = $model->getTable();
            }
            $id = is_array($primary) ? null : $row->$primary;
            $componentId = isset($row->component_id) ? $row->component_id : null;
        }
        if ($model instanceof Vps_Component_Cache_MetaModel ||
            $model instanceof Vps_Component_Cache_Model ||
            ($model instanceof  Vps_Model_Field && !$primary)
        ) {
            return array();
        }
        if (get_class($model) == 'Vps_Db_Table') return array();
{'fraction_non_alphanumeric': 0.13584036838066002, 'fraction_numerical': 0.0, 'mean_word_length': 1.9468626342566422, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '2206524', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1471, 'n_words': 321}