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

productcomments: Incorrect declaration of foreign keys in Doctrine ORM Entity annotations #35523

Open
2 tasks done
lmeyer1 opened this issue Feb 29, 2024 · 3 comments · May be fixed by PrestaShop/productcomments#199
Open
2 tasks done
Labels
8.1.x Branch BO Category: Back Office Bug Type: Bug Module Module NMI Status: issue needs more information Productcomments Module: productcomments Waiting for dev Status: action required, waiting for tech feedback

Comments

@lmeyer1
Copy link
Contributor

lmeyer1 commented Feb 29, 2024

Prerequisites

Describe the bug and add attachments

After upgrading to PS 8.1.4 and productcomments 6.0.2, upgrade the database schema with doctrine.
In the BO, productcomments, it is no longer possible to delete a comment. Why?

Docrtine created incorrect foreign keys (run php bin/console doctrine:schema:update --dump-sql to see the script that is executed):

ALTER TABLE ps_product_comment_report ADD CONSTRAINT FK_C2608AB0ACF38A54 FOREIGN KEY (id_product_comment) REFERENCES ps_product_comment (id_product_comment);
ALTER TABLE ps_product_comment_usefulness ADD CONSTRAINT FK_49A8F246ACF38A54 FOREIGN KEY (id_product_comment) REFERENCES ps_product_comment (id_product_comment);
ALTER TABLE ps_product_comment_grade ADD CONSTRAINT FK_A0128571ACF38A54 FOREIGN KEY (id_product_comment) REFERENCES ps_product_comment (id_product_comment);
ALTER TABLE ps_product_comment_grade ADD CONSTRAINT FK_A01285718375853C FOREIGN KEY (id_product_comment_criterion) REFERENCES ps_product_comment_criterion (id_product_comment_criterion);

The first three foreign keys should include on delete cascade to allow deletion of a comment (every comment has a related comment_grade, and if someone reported a spam comment, it will probably have a related comment_usefulness and / or comment_report).

Expected behavior

Updating the database schema must not break a backend functionality. Here: it must not break the possibility to delete a comment in the BO

Steps to reproduce

  1. Install PS with productcomments 6.0.2
  2. In the BO test if it is possible to delete a comment.
    If yes:
  3. on the command line run php bin/console doctrine:schema:update --dump-sql
  4. Execute the queries related to productcomments
  5. In the BO test if it is possible to delete a comment. It is no longer possible

PrestaShop version(s) where the bug happened

8.1.4

PHP version(s) where the bug happened

8.1.27 (not related to PHP)

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

productcomments 6.0.2

Your company or customer's name goes here (if applicable).

Société Biblique de Genève

@lmeyer1 lmeyer1 added Bug Type: Bug New New issue not yet processed by QA labels Feb 29, 2024
@AureRita
Copy link
Contributor

Hi @lmeyer1

Thank for your report,
This issue is too technical for me, ping @PrestaShop/tech-council, can someone please reproduce this issue ?

Thanks

@AureRita AureRita added BO Category: Back Office NMI Status: issue needs more information Waiting for dev Status: action required, waiting for tech feedback Productcomments Module: productcomments Module Module 8.1.x Branch and removed New New issue not yet processed by QA labels Feb 29, 2024
@leemyongpakva
Copy link

I agree with @AureRita, the issue description is too technical ;)
The issue can be described more simple: Use Doctrine cascade delete instead of Manual delete. Before PR we can delete a product comment. After PR we still can delete a product comment, but saved 3 Manual deletes.

@lmeyer1
Copy link
Contributor Author

lmeyer1 commented Mar 1, 2024

Before PR we can delete a product comment

How ? We get an error about a foreign key constraint, and deletion with the delete button (trash icon) does not work.

It does not work if the queries generated be doctrine are applied to the DB. They might not get applied in an automatic upgrade of the shop, because they probably will raise an error about the foreign key constraint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.1.x Branch BO Category: Back Office Bug Type: Bug Module Module NMI Status: issue needs more information Productcomments Module: productcomments Waiting for dev Status: action required, waiting for tech feedback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants