mage2pro / markdown

The «Markdown Editor» extension for Magento 2
https://upwork.com/fl/mage2pro
6 stars 1 forks source link

A Magento 2.2 failure while saving a product in the backend: «Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`store`.`dfe_markdown_product`, CONSTRAINT `dfe_markdown_product_ibfk_1` FOREIGN KEY (`value_id`) REFERENCES `catalog_product_entity_text` (`value_id`) ON DELETE CASCADE), query was: INSERT INTO `dfe_markdown_product` (`value_id`, `markdown`) VALUES (?, ?)» #1

Closed dmitrii-fediuk closed 7 years ago

dmitrii-fediuk commented 7 years ago
Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`store`.`dfe_markdown_product`, CONSTRAINT `dfe_markdown_product_ibfk_1` FOREIGN KEY (`value_id`) REFERENCES `catalog_product_entity_text` (`value_id`) ON DELETE CASCADE), query was: INSERT INTO `dfe_markdown_product` (`value_id`, `markdown`) VALUES (?, ?)
#0 lib\internal\Magento\Framework\DB\Statement\Pdo\Mysql.php(93): Zend_Db_Statement_Pdo->_execute(Array)
#1 vendor\magento\zendframework1\library\Zend\Db\Statement.php(303): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array)
#2 vendor\magento\zendframework1\library\Zend\Db\Adapter\Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 vendor\magento\zendframework1\library\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `df...', Array)
#4 lib\internal\Magento\Framework\DB\Adapter\Pdo\Mysql.php(515): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `df...', Array)
#5 lib\internal\Magento\Framework\DB\Adapter\Pdo\Mysql.php(578): Magento\Framework\DB\Adapter\Pdo\Mysql->_query('INSERT INTO `df...', Array)
#6 vendor\magento\zendframework1\library\Zend\Db\Adapter\Abstract.php(576): Magento\Framework\DB\Adapter\Pdo\Mysql->query('INSERT INTO `df...', Array)
#7 vendor\mage2pro\markdown\CatalogAction\DbRecord.php(32): Zend_Db_Adapter_Abstract->insert('dfe_markdown_pr...', Array)
#8 vendor\mage2pro\markdown\CatalogAction\DbRecord.php(122): Dfe\Markdown\CatalogAction\DbRecord->_save('<p>alligator le...')
#9 vendor\mage2pro\markdown\Observer\Catalog\ControllerAction\Postdispatch.php(30): Dfe\Markdown\CatalogAction\DbRecord::save('description', '<p>alligator le...')
#10 vendor\mage2pro\markdown\Observer\Catalog\ControllerAction.php(57): Dfe\Markdown\Observer\Catalog\ControllerAction\Postdispatch->handleCustomValue(Array, 'description')
#11 vendor\mage2pro\markdown\Observer\Catalog\ControllerAction.php(49): Dfe\Markdown\Observer\Catalog\ControllerAction->processPost(Array)
#12 vendor\mage2pro\markdown\Observer\Catalog\ControllerAction.php(33): Dfe\Markdown\Observer\Catalog\ControllerAction->processPost(Array)
#13 lib\internal\Magento\Framework\Event\Invoker\InvokerDefault.php(72): Dfe\Markdown\Observer\Catalog\ControllerAction->execute(Object(Magento\Framework\Event\Observer))
#14 lib\internal\Magento\Framework\Event\Invoker\InvokerDefault.php(60): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Dfe\Markdown\Observer\Catalog\ControllerAction\Postdispatch), Object(Magento\Framework\Event\Observer))
#15 lib\internal\Magento\Framework\Event\Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#16 generated\code\Magento\Framework\Event\Manager\Proxy.php(95): Magento\Framework\Event\Manager->dispatch('controller_acti...', Array)
#17 lib\internal\Magento\Framework\App\Action\Action.php(111): Magento\Framework\Event\Manager\Proxy->dispatch('controller_acti...', Array)
#18 app\code\Magento\Backend\App\AbstractAction.php(228): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#19 lib\internal\Magento\Framework\Interception\Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#20 lib\internal\Magento\Framework\Interception\Interceptor.php(138): Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor->___callParent('dispatch', Array)
#21 app\code\Magento\Backend\App\Action\Plugin\Authentication.php(143): Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#22 lib\internal\Magento\Framework\Interception\Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#23 lib\internal\Magento\Framework\Interception\Interceptor.php(153): Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#24 generated\code\Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor.php(39): Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor->___callPlugins('dispatch', Array, NULL)
#25 lib\internal\Magento\Framework\App\FrontController.php(55): Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#26 lib\internal\Magento\Framework\Interception\Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#27 lib\internal\Magento\Framework\Interception\Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#28 lib\internal\Magento\Framework\Interception\Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#29 generated\code\Magento\Framework\App\FrontController\Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#30 lib\internal\Magento\Framework\App\Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#31 lib\internal\Magento\Framework\App\Bootstrap.php(256): Magento\Framework\App\Http->launch()
#32 index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#33 {main}
dmitrii-fediuk commented 7 years ago

The dfe_markdown_product table contents:
02

The \Dfe\Markdown\Setup\UpgradeSchema::createTableEav() method:

private function createTableEav($name, $master) {
    $f_MARKDOWN = self::F__MARKDOWN;
    $f_VALUE_ID = self::F__ID;
    $this->c()->rawQuery("
    CREATE TABLE IF NOT EXISTS `{$this->t($name)}` (
        `value_id` int(11) NOT NULL
        ,`{$f_MARKDOWN}` text
        ,PRIMARY KEY (`{$f_VALUE_ID}`)
        ,FOREIGN KEY (`{$f_VALUE_ID}`)
            REFERENCES `{$this->t($master)}` (`value_id`)
            ON DELETE CASCADE
        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
    ");
}

https://github.com/mage2pro/markdown/blob/1.0.23/Setup/UpgradeSchema.php#L73-L85

dmitrii-fediuk commented 7 years ago

Fixed in the 1.1.0 version.