mailjet / prestashop-mailjet-plugin-apiv3

GNU General Public License v2.0
15 stars 9 forks source link

Problem when upgrading from Prestashop 1.7.8.8 to 8.02 when module is installed #133

Closed jsuzineau closed 1 year ago

jsuzineau commented 1 year ago

When the module is installed and connected to a Mailjet account( and then even removed), I get an error 500 on login in administration after updating Prestashop from 1.7.8.8 to 8.0.2. After activating the debug mode ( define('_PS_MODEDEV', true); in config/defines.inc.php ) I got the error message: La propriété EmployeeSession->date_add n'est pas valide.

It seems that when the module has been installed (and even removed), Prestashop is modified, an EmployeeSession is loaded before the admin login create a new EmployeeSession. For now I couldn't track the problem more deeply in the source code.

On Prestashop 8.0.0 a new field date_add is added on table employee_session: ALTER TABLE PREFIX_employee_session ADD date_add DATETIME NOT NULL AFTER date_upd; For existing lines before, this new field ends up initialized with 0000-00-00 00:00:00 which seems to be considered invalid.

I'm not sure whether this should be considered as a bug of this module or a bug of Prestashop 8, in doubt, I start with creating an issue here. I could solve the problem by modifying the alter table, adding DEFAULT NOW() to initialize the old line with the current date/time in modules/autoupgrade/upgrade/sql/8.0.0.sql line 179 ALTER TABLE PREFIX_employee_session ADD date_upd DATETIME NOT NULL DEFAULT NOW() AFTER token; ALTER TABLE PREFIX_employee_session ADD date_add DATETIME NOT NULL DEFAULT NOW() AFTER date_upd; ALTER TABLE PREFIX_customer_session ADD date_upd DATETIME NOT NULL DEFAULT NOW() AFTER token; ALTER TABLE PREFIX_customer_session ADD date_add DATETIME NOT NULL DEFAULT NOW() AFTER date_upd;

This happens when testing the Prestashop 8 update on a local copy before applying it to online to the site in production. On the local copy, the domain name is faked by an entry in /etc/hosts and a snakeoil certificate. The local copy is running on an Ubuntu 22.04 vm, with phpbrew configured on php 7.4.32. I made test with two archives, one before installing mailjet module, and one after installation. Unfortunately with mailjet installation I had 13 modules updates too, but if I make these updates separately, it doesn't trigger the problem. I tested too with just installing the mailjet module without connection to the mailjet account, it didn't triggered the problem.

oleksandr-mykhailenko commented 1 year ago

Hello @jsuzineau We will check this error. Thank you for reporting this

oleksandr-mykhailenko commented 1 year ago

The problem was resolved. Thank you