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

Doctrine ORM annotations in psdgpr are not compatible with multishop activated #35521

Open
2 tasks done
lmeyer1 opened this issue Feb 29, 2024 · 1 comment · May be fixed by PrestaShop/psgdpr#230
Open
2 tasks done

Doctrine ORM annotations in psdgpr are not compatible with multishop activated #35521

lmeyer1 opened this issue Feb 29, 2024 · 1 comment · May be fixed by PrestaShop/psgdpr#230
Labels
Blocked Status: The issue is blocked by another task Bug Type: Bug GDPR Module: psgdpr Module Module Multistore Label: Which BO under menu is concerned

Comments

@lmeyer1
Copy link
Contributor

lmeyer1 commented Feb 29, 2024

Prerequisites

Describe the bug and add attachments

When updating the database scema to the latest installed version, php bin/console doctrine:schema:update --dump-sql showed these lines related to the psgdpr module:

ALTER TABLE ps_psgdpr_consent_lang MODIFY id_gdpr_consent INT UNSIGNED NOT NULL;
ALTER TABLE ps_psgdpr_consent_lang DROP PRIMARY KEY;
ALTER TABLE ps_psgdpr_consent_lang CHANGE id_gdpr_consent id_gdpr_consent INT NOT NULL, CHANGE id_lang id_lang INT NOT NULL, CHANGE id_shop id_shop INT NOT NULL, CHANGE message message VARCHAR(255) NOT NULL;
ALTER TABLE ps_psgdpr_consent_lang ADD CONSTRAINT FK_9C2246C9BEB78BEF FOREIGN KEY (id_gdpr_consent) REFERENCES ps_psgdpr_consent (id_gdpr_consent);
ALTER TABLE ps_psgdpr_consent_lang ADD CONSTRAINT FK_9C2246C9BA299860 FOREIGN KEY (id_lang) REFERENCES ps_lang (id_lang) ON DELETE CASCADE;
CREATE INDEX IDX_9C2246C9BEB78BEF ON ps_psgdpr_consent_lang (id_gdpr_consent);
CREATE INDEX IDX_9C2246C9BA299860 ON ps_psgdpr_consent_lang (id_lang);
# Bug in psgdpr : id_shop must be included
ALTER TABLE ps_psgdpr_consent_lang ADD PRIMARY KEY (id_gdpr_consent, id_lang);

The last line is incorrect. The table ps_psgdpr_consent_lang contains a column id_shop that must be part of the primary key. The SQL command will fail, with an error duplicate key, because there is a line for each shop in the table.

Expected behavior

php bin/console doctrine:schema:update --dump-sql should produce valid output. This means, it must be ALTER TABLE ps_psgdpr_consent_lang ADD PRIMARY KEY (id_gdpr_consent, id_lang, id_shop); instead of ALTER TABLE ps_psgdpr_consent_lang ADD PRIMARY KEY (id_gdpr_consent, id_lang);

Steps to reproduce

  1. Install Prestashop, enable multishop and configure at least 2 shops
  2. Install the module psgdpr at version 1.4.3
  3. Look at the table PREFIX_psgdpr_consent_lang, it has a primary key (id_gdpr_consent, id_lang, id_shop). You can also look at the file modules/psgdpr/sql/install/psgdpr_consent_lang.sql both for psgdpr 1.4.3 and psgdpr 2.0.1 and find this same definition
  4. Update psgdpr to version 2.0.1
  5. On the command line run php bin/console doctrine:schema:update --dump-sql and observe the output. It will contain a primary key (id_gdpr_consent, id_lang) with id_shop absent.

PrestaShop version(s) where the bug happened

8.1.4

PHP version(s) where the bug happened

8.0 / 8.1

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

psgdpr 2.0.1

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
@florine2623 florine2623 added GDPR Module: psgdpr Blocked Status: The issue is blocked by another task Multistore Label: Which BO under menu is concerned Module Module and removed New New issue not yet processed by QA labels Mar 1, 2024
@florine2623
Copy link
Contributor

Hello @lmeyer1 ,

I'm putting the label Blocked because the latest functioning version of module GDPR is 1.4.3, not 2.0.1.

Thanks ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked Status: The issue is blocked by another task Bug Type: Bug GDPR Module: psgdpr Module Module Multistore Label: Which BO under menu is concerned
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants