Issues

ZF-12412: Zend_Db_Table_Abstract::delete does not delete from dependent table

Description

Although cascade deleting is executed from Zend_Db_Table_Abstract::delete it will not delete from dependent table. While calling _cascadeDelete on dependent table it's class name is passed as parent's table. Zend_Db_Table_Abstract::delete should be:


    public function delete($where)
    {
        $depTables = $this->getDependentTables();
        if (!empty($depTables)) {
            $resultSet = $this->fetchAll($where);
            if (count($resultSet) > 0 ) {
                foreach ($resultSet as $row) {
                    /**
                     * Execute cascading deletes against dependent tables
                     */
                    foreach ($depTables as $tableClass) {
                        $t = self::getTableFromString($tableClass, $this);
                        $t->_cascadeDelete(get_class($this), $row->getPrimaryKey());
                    }
                }
            }
        }

        $tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
        return $this->_db->delete($tableSpec, $where);
    }

Comments

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf1/issues/15