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

Fatal error if I delete a reported comment from module productcomments BO page #34512

Closed
2 tasks done
matks opened this issue Nov 9, 2023 · 4 comments · Fixed by PrestaShop/productcomments#190
Closed
2 tasks done
Labels
BO Category: Back Office Bug Type: Bug develop Branch Minor Severity: minor bug > https://build.prestashop.com/news/severity-classification Module Module Productcomments Module: productcomments Verified The issue has been reproduced

Comments

@matks
Copy link
Contributor

matks commented Nov 9, 2023

Prerequisites

Describe the bug and add attachments

When user admin, on the productcomments module backoffice page, use the "Delete" button to delete a comment that has been reported as abusive, then after the page is refreshed a fatal error is thrown

PrestaShop\Module\ProductComment\Repository\ProductCommentRepository::delete(): Argument #1 ($entity) must be of type PrestaShop\Module\ProductComment\Entity\ProductComment, null given, called in /Users/AAA/www/prestashop/PrestaShop/modules/productcomments/productcomments.php on line 210

Expected behavior

The "delete" button should successfully delete the comment and not display an error page

Steps to reproduce

  1. Install PrestaShop develop branch
  2. Open a first tab, go to front-office, create a customer account. Then open a product Front-office page and review the product: you need to submit a comment about the product. The comment is submitted but must be approved by a shop admin.
  3. Open a 2nd tab, you login on backoffice, go to module manager Backoffice page, then "configure" module "Product Comments"
  4. On 2nd tab, approve the comment.
  5. On 1st tab refresh the product page: now the comment can be seen.
  6. On the 1st tab, use the "report abusive comment" flag icon to report the comment
  7. Back on 2nd tab, on the productcomments module backoffice page you should see the reported comment
  8. Click on "Delete" button next to reported comment
  9. Refresh the page, see the fatal error

Capture d’écran 2023-11-09 à 18 13 02

PrestaShop version(s) where the bug happened

9.0.0

PHP version(s) where the bug happened

8.2

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).

No response

@matks matks added Bug Type: Bug New New issue not yet processed by QA labels Nov 9, 2023
@matks
Copy link
Contributor Author

matks commented Nov 9, 2023

Mmmm looks like the root cause is that I refresh at step 9

As the URL contains the parameter for the action, the module attempts to delete the comment again, and it fails because the comment was successfully deleted at step 8.

The URL is

admin-dev/index.php?controller=AdminModules&configure=productcomments&id_product_comment=3&deleteproductcomments&token=AAA

As you can see the parameters contain the action, so when you hit the refresh button it send the same request

I will submit a PR to mitigate the problem

@leemyongpakvn
Copy link
Contributor

I guess we need an Exception for deleting a deleted comment and a Redirect after a comment deleted ;)

@florine2623 florine2623 added Minor Severity: minor bug > https://build.prestashop.com/news/severity-classification BO Category: Back Office Productcomments Module: productcomments Verified The issue has been reproduced Module Module Ready Status: Issue is ready to be worked on develop Branch and removed New New issue not yet processed by QA labels Nov 13, 2023
@florine2623
Copy link
Contributor

florine2623 commented Nov 13, 2023

Hello @matks ,

I reproduce the issue with PrestaShop version develop, I'll add this to the backlog so it can be fixed.

Screen.Recording.2023-11-13.at.10.59.43.mov

When I refresh my page, I have the following exception :
Screenshot 2023-11-13 at 11 05 32

Please be aware that some issues might take a very long time to be resolved. If this one is important to you and you cannot wait for it to be fixed on the project’s own time, we strongly suggest you consider contacting a professional to help you.

If you fix the issue on your end, please contribute it back to the project. Remember that the more people contribute, the better PrestaShop becomes for everyone.

Thank you

@matks
Copy link
Contributor Author

matks commented Nov 16, 2023

I submitted the PR PrestaShop/productcomments#190

@prestashop-issue-bot prestashop-issue-bot bot removed the Ready Status: Issue is ready to be worked on label Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BO Category: Back Office Bug Type: Bug develop Branch Minor Severity: minor bug > https://build.prestashop.com/news/severity-classification Module Module Productcomments Module: productcomments Verified The issue has been reproduced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants