Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate product fails when using PDO and there are multiple rows for duplicated product in the product_group_reduction_cache #31737

Open
2 tasks done
Tracked by #19259
jukkakorpelainen opened this issue Mar 12, 2023 · 9 comments
Labels
1.7.8.8 Affects versions Bug Type: Bug CO Category: Core Minor Severity: minor bug > https://build.prestashop.com/news/severity-classification Old Products Page Concerns the old product page Ready Status: Issue is ready to be worked on Verified The issue has been reproduced

Comments

@jukkakorpelainen
Copy link

jukkakorpelainen commented Mar 12, 2023

Prerequisites

Describe the bug and add attachments

GroupReduction::duplicateReduction has a multistatement query that is blocked in config/defines.inc.php with define('_PS_ALLOW_MULTI_STATEMENTS_QUERIES_', false);
This prevents product duplication in \PrestaShop\PrestaShop\Adapter\Product\AdminProductDataUpdater::duplicateProduct function.
This affects products that have multiple rows in product_group_reduction_cache and database setups using PDO

Expected behavior

No response

Steps to reproduce

There should be enough information in the description to verify and fix this bug.

PrestaShop version(s) where the bug happened

1.7.8.8

PHP version(s) where the bug happened

7.4.33

If your bug is related to a module, specify its name and its version

No response

@jukkakorpelainen jukkakorpelainen added Bug Type: Bug New New issue not yet processed by QA labels Mar 12, 2023
@AureRita
Copy link
Contributor

Hi @jukkakorpelainen

Thank for your repor and for submitting this issue. Unfortunately, there is not enough information provided to reproduce it and work on it. You must follow the template and provide clear and concise steps to reproduce the bug.
Read more about how we expect the issues to be handled here,

This issue is too technical for me.

Thanks

@AureRita AureRita added Waiting for author Status: action required, waiting for author feedback NMI Status: issue needs more information CO Category: Core Old Products Page Concerns the old product page and removed New New issue not yet processed by QA labels Mar 13, 2023
@kpodemski
Copy link
Contributor

@AureRita, there's enough information, it's a valid bug report

@prestashop-issue-bot prestashop-issue-bot bot removed the Waiting for author Status: action required, waiting for author feedback label Mar 13, 2023
@kpodemski kpodemski removed the NMI Status: issue needs more information label Mar 13, 2023
@hibatallahAouadni hibatallahAouadni added the 1.7.8.8 Affects versions label Mar 13, 2023
@zelduxs
Copy link

zelduxs commented Apr 18, 2023

After updating 1.7.8.7 -> 1.7.8.8 I can't duplicate items..

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO lwgx_product_group_reduction_cache (id_product, id_group, ...' at line 1<br /><br /><pre>INSERT INTO lwgx_product_group_reduction_cache (id_product, id_group, reduction) VALUES (8187, 5, 0.12) ON DUPLICATE KEY UPDATE reduction= 0.12;INSERT INTOlwgx_product_group_reduction_cache (id_product, id_group, reduction) VALUES (8187, 6, 0.07) ON DUPLICATE KEY UPDATE reduction` = 0.07;
• Exception
• Logs 2
• Stack Trace
PrestaShopDatabaseException
in classes/db/Db.php (line 769)
764. if ($webservice_call && $errno) {
765. $dbg = debug_backtrace();
766. WebserviceRequest::getInstance()->setError(500, '[SQL Error] ' . $this->getMsgError() . '. From ' . (isset($dbg[3]['class']) ? $dbg[3]['class'] : '') . '->' . $dbg[3]['function'] . '() Query was : ' . $sql, 97);
767. } elseif (PS_DEBUG_SQL && $errno && !defined('PS_INSTALLATION_IN_PROGRESS')) {
768. if ($sql) {
769. throw new PrestaShopDatabaseException($this->getMsgError() . '

' . $sql . '
');
770. }
771.
772. throw new PrestaShopDatabaseException($this->getMsgError());
773. }
774. }

@hibatallahAouadni hibatallahAouadni added the NMI Status: issue needs more information label May 3, 2023
@AureRita AureRita added Ready Status: Issue is ready to be worked on Verified The issue has been reproduced Trivial Severity: trivial bug > https://build.prestashop.com/news/severity-classification Minor Severity: minor bug > https://build.prestashop.com/news/severity-classification and removed NMI Status: issue needs more information Trivial Severity: trivial bug > https://build.prestashop.com/news/severity-classification labels May 4, 2023
@iulianm16
Copy link

I have same problem, did you find any solution?

@JavierEB
Copy link

imagen
another here with the same problem when trying to duplicate a product, with several customer groups created with different individual discounts in each group. I use Prestashop 1.7.8.8 , php 7.4.33 and 10.6.12-MariaDB-cll-lve

@zelduxs
Copy link

zelduxs commented Jun 1, 2023

After updating 1.7.8.7 -> 1.7.8.8 I can't duplicate items..

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO lwgx_product_group_reduction_cache (id_product, id_group, ...' at line 1<br /><br />\<pre\>INSERT INTO lwgx_product_group_reduction_cache (id_product, id_group, reduction) VALUES (8187, 5, 0.12) ON DUPLICATE KEY UPDATE reduction= 0.12;INSERT INTOlwgx_product_group_reduction_cache (id_product, id_group, reduction) VALUES (8187, 6, 0.07) ON DUPLICATE KEY UPDATE reduction` = 0.07; • Exception • Logs 2 • Stack Trace PrestaShopDatabaseException in classes/db/Db.php (line 769) 764. if ($webservice_call && $errno) { 765. $dbg = debug_backtrace(); 766. WebserviceRequest::getInstance()->setError(500, '[SQL Error] ' . $this->getMsgError() . '. From ' . (isset($dbg[3]['class']) ? $dbg[3]['class'] : '') . '->' . $dbg[3]['function'] . '() Query was : ' . $sql, 97); 767. } elseif (PS_DEBUG_SQL && $errno && !defined('PS_INSTALLATION_IN_PROGRESS')) { 768. if ($sql) { 769. throw new PrestaShopDatabaseException($this->getMsgError() . '

' . $sql . '
');
770. }
771.
772. throw new PrestaShopDatabaseException($this->getMsgError());
773. }
774. }

@zelduxs
Copy link

zelduxs commented Jun 1, 2023

I updated to 1.7.8.9, the problem still persists. But after making the change it works. config/defines.inc.php define('PS_ALLOW_MULTI_STATEMENTS_QUERIES', false);
FALSE change to TRUE

@JavierEB
Copy link

JavierEB commented Jul 11, 2023

I updated to 1.7.8.9, the problem still persists. But after making the change it works. config/defines.inc.php define('PS_ALLOW_MULTI_STATEMENTS_QUERIES', false); FALSE change to TRUE

To temporarily fix it works, but this I think should not be a solution...

PS: Thanks for your research ;)

@ShaiMagal
Copy link
Contributor

FIY:
Today I had totally same issue for PS 8.1.2 -> so, problem still persist.
Workaround:
define('PS_ALLOW_MULTI_STATEMENTS_QUERIES', false);
to:
define('PS_ALLOW_MULTI_STATEMENTS_QUERIES', true);
is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.7.8.8 Affects versions Bug Type: Bug CO Category: Core Minor Severity: minor bug > https://build.prestashop.com/news/severity-classification Old Products Page Concerns the old product page Ready Status: Issue is ready to be worked on Verified The issue has been reproduced
Projects
None yet
Development

No branches or pull requests

8 participants