PrestaShop / pscleaner

This module allows you to check and fix functional integrity constraints and remove default data
http://www.prestashop.com
Academic Free License v3.0
36 stars 107 forks source link

Bug in pscleaner free module #63

Open hanicab opened 5 years ago

hanicab commented 5 years ago

Describe the bug When we click 'repair database' bouton, the module empties the table 'stock_mvt' and delete all existing columns in this table.

To Reproduce Steps to reproduce the behavior:

  1. Add or edit a stock for some products ( to create some stock movments history )
  2. Go to pscleaner module
  3. Click on 'repair database'
  4. go to phpmyadmin and check the table 'stock_mvt'
  5. You will see that the table has become empty

Cause of problem: I think because in prestashop 1.7.5.0 the table stock is always empty , so when the module try to compare id_stock in the both tables , it will delete all columns of the table 'stock_mvt'

Additionnal information PrestaShop version: 1.7.5.0 PHP version: 7.2

khouloudbelguith commented 5 years ago

Hi @hanicab,

Thanks for your report. I manage to reproduce the issue with PS1.7.6.0beta1 / PS1.7.5.2 & the pscleaner v2.0.0. When we click on Check & fix for the "FUNCTIONAL INTEGRITY CONSTRAINTS" section, the ps_stock_mvt will be empty & we have like a green alert

The following queries successfully fixed broken data:
DELETE FROM `ps_product_attribute_image` WHERE `id_image` NOT IN (SELECT `id_image` FROM `ps_image`)
4 line(s)
DELETE FROM `ps_stock_mvt` WHERE `id_stock` NOT IN (SELECT `id_stock` FROM `ps_stock`)
4 line(s)

I’ll add this to the debug roadmap so that it’s fixed. If you have already fixed it on your end or if you think you can do it, please do send us a pull request! Thanks!