Hello,
recently I got an error while trying to update a Shopware Shop.
Some other users got the same error too and solved it with removing two lines in one of the update scripts. But before removing them I tried to understand whats going on there to not break anything with it. The affected code is:
$sql = <<<'SQL'
SET @parent = (SELECT id FROM s_core_config_forms WHERE name = 'Checkout' LIMIT 1);
INSERT IGNORE INTO `s_core_config_elements` (`id`, `form_id`, `name`, `value`, `label`, `description`, `type`, `required`, `position`, `scope`, `options`) VALUES
(NULL, @parent, 'showVoucherModeForCheckout', 'i:2;', 'Gutscheinfeld im Bestellabschluss anzeigen', NULL, 'select', 0, 0, 0, '%s');
SET @voucherModeElementId = (SELECT id FROM `s_core_config_elements` WHERE `name` = 'showVoucherModeForCheckout' LIMIT 1);
INSERT IGNORE INTO `s_core_config_element_translations` (`element_id`, `locale_id`, `label`)
VALUES (@voucherModeElementId, '2', 'Display voucher field on checkout page');
SET @commentArticleElementId = (SELECT id FROM `s_core_config_elements` WHERE `name` = 'commentVoucherArticle');
--UPDATE `s_core_config_elements` SET `description` = 'Artikel hinzufügen, Kommentarfunktion', name = 'commentArticle' WHERE id = @commentArticleElementId;
--UPDATE `s_core_config_element_translations` SET description = 'Add product, comment function' WHERE element_id = @commentArticleElementId;
SQL;
Summary
The two lines I commented out with ‚–‘ at the end are the ones I have to remove.
The Error I got while updating is:
Could not apply migration (Migrations_Migration1607). Error: SQLSTATE[HY000]: General error: 1093 You can't specify target table 's_core_config_values' for update in FROM clause
I also checked which value „@voucherModeElementId“ and „@commentArticleElementId“ have after the select filesynced statement and it turns out that there is no entry with name ‚showVoucherModeForCheckout‘ in table ‚s_core_config_elements‘.
And the id of the entry with name = ‚commentVoucherArticle‘ in s_core_config_elements is 877. So ‚@commentArticleElementId‘ has the value 877 I think.
Can anyone explain me what the two lines are doing and maybe even why I got the error?
This text will be hidden