8

cms/block entities have a join table cms_block_store, the records in which link a given block to one or more stores. Prior to CE 1.6, the resource model Mage_Cms_Model_Mysql4_Block (link) does not separately remove these records before the entity is deleted, effectively relying on the cascade to remove them. As of 1.6.0.0, the relocated resource model explicitly removes these records in Mage_Cms_Model_Resource_Block::_beforeDelete (link) before the entity is deleted from cms_block:

protected function _beforeDelete(Mage_Core_Model_Abstract $object)
{
    $condition = array(
        'block_id = ?'     => (int) $object->getId(),
    );

    $this->_getWriteAdapter()->delete($this->getTable('cms/block_store'), $condition);

    return parent::_beforeDelete($object);
}

Is there an apparent reason for performing this operation in two separate queries rather than relying on the cascade as it did before?

  • Is the Magento core team reading here? – Alex Feb 11 '13 at 16:26
  • I would hope so! I'll wait a couple of days and ping some of them if we don't get any good answers here. – benmarks Feb 11 '13 at 16:30
  • maybe the interns that refactored the code thought this is a good idea... move some things out of the database, keep the logic at the code level. – FlorinelChis Feb 13 '13 at 17:53
  • so time to ping them :-) – Alex Mar 4 '13 at 20:46
  • 2
    @Alex - I'll be hanging out with them in LA this weekend and will update here. – benmarks Mar 4 '13 at 21:09
3

To me this most likely has to do with the swap to a relational database management system (RDBMS). Relying on the database cascading functionality could be problematic in different systems, so the logic has been added manually in the new Resource model.

The same can be seen in the Mage_Cms_Model_Resource_Page::_beforeDelete() method and the Mage_Poll and Mage_Review models too (although these occur in the _afterSave() methods.

Read more about Magento's swap to RDBMS here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.