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

Use GenerateThemeMailTemplatesCommand during upgrade #434

Merged
merged 6 commits into from
Feb 16, 2022

Conversation

jolelievre
Copy link
Contributor

@jolelievre jolelievre commented Nov 2, 2021

Questions Answers
Description? Use GenerateThemeMailTemplatesCommand during upgrade instead of legacy removed Language::installEmailsLanguagePack function
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes PrestaShop/PrestaShop#26503
How to test? PrestaShop/PrestaShop#27276 must be merged before. Build the module based on this branch Install it and try to upgrade to 8.0.0 (you will probably need to create a release from the most recent develop branch). You shouldn't have anymore error related to mail generation (there might be other errors down on the road but it's not the purpose of this PR)
Possible impacts? The module now relies on GenerateThemeMailTemplatesCommand which was introduced in PrestaShop 1.7.6 which means the module would now be only compatible with target versions above 1.7.6 I don't know if we should handle retrocompatibility with older versions? If so then we might need to extract this new code in a dedicated class or service to handle the switch more cleanly

@@ -28,6 +28,9 @@
namespace PrestaShop\Module\AutoUpgrade\UpgradeTools\CoreUpgrader;

use PrestaShop\Module\AutoUpgrade\UpgradeException;
use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we are allowed to use core classes like this in the upgrade module Especially since these classes may not be available in the source version and/or the target version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik you can do it:
image
It will only raise an error if the class is not found and executed by PHP

@@ -87,7 +90,33 @@ protected function upgradeLanguage($lang)
\Language::installSfLanguagePack($lang_pack['locale'], $errorsLanguage);

if (!$this->container->getUpgradeConfiguration()->shouldKeepMails()) {
\Language::installEmailsLanguagePack($lang_pack, $errorsLanguage);
$mailTheme = \Configuration::get('PS_MAIL_THEME', null, null, null, 'modern');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we handle backward compatibility and use the Language::installEmailsLanguagePack for versions older than the 1.7.6? If so maybe this should be extracted in a dedicated tool class or service.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor to keep the backward compatibilty!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes keep it

Copy link
Contributor

@matks matks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR is OK IMO, if you apply latest feedbacks from @PierreRambaud

@matks
Copy link
Contributor

matks commented Dec 3, 2021

PHPStan issue not related to change PrestaShop/PrestaShop#26861

@atomiix atomiix closed this Dec 13, 2021
@atomiix atomiix reopened this Dec 13, 2021
atomiix
atomiix previously approved these changes Dec 16, 2021
return new CoreUpgrader16($this->container, $this->logger);
}

return new CoreUpgrader17($this->container, $this->logger);
if (version_compare($this->container->getState()->getInstallVersion(), '8.0.0.0', '<')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Contributor Author

@jolelievre jolelievre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @atomiix for the finishing touch 😉
I'd like to approve but I can't approve my own PR 😅

@jolelievre
Copy link
Contributor Author

Oh and it seems like PHPStan is not happy about something

@atomiix atomiix force-pushed the mail-generation-command branch 2 times, most recently from 7607803 to 21978bf Compare January 7, 2022 18:54
Copy link
Contributor Author

@jolelievre jolelievre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't approve this PR, seems legitimate I just have one suggestion

I didn't see any modif related to the bug you mentioned regarding LegacyLoader, is it fixed in the core?

@@ -90,8 +90,8 @@ protected function upgradeLanguage($lang)
$mailTheme,
$lang_pack['locale'],
true,
$frontThemeMailsFolder,
$frontThemeModulesFolder
is_dir($frontThemeMailsFolder) ? $frontThemeMailsFolder : '',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these folders supposed to always exist? Is it really needed to check their existence?

I just checked the handler, which actually handles the default folder internally when the command parameters are empty, so maybe specifying these parameters is actually not useful here? We could ignore this and let that handler handle?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These folders aren't supposed to always exist, if you check the themes/classic/ folder, you'll see no mails folder.
Also, I see that's what we do in src/PrestaShopBundle/Controller/Admin/Improve/Design/MailThemeController.php

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see any modif related to the bug you mentioned regarding LegacyLoader, is it fixed in the core?

@jolelievre yep, it's fixed in the core ;)

kpodemski
kpodemski previously approved these changes Jan 10, 2022
Copy link
Contributor

@kpodemski kpodemski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if ModuleAdapter:: getCommandBus shouldn't throw an error if we're not in the context of 1.7+, but of course, this is an edge case scenario.

@khouloudbelguith
Copy link

Hi @jolelievre,

  1. I created a release from this PR: Remove useless legacyContextLoader PrestaShop#27276
  2. I installed PS1782 with English language & France country
  3. I added the Algeria pack
  4. I enabled multistore & created a new shop
  5. I created some order
  6. I installed the autoupgrade module using this PR
  7. During the upgrade, I have an error

image

What do you think, this error is related to the PR module or the develop PR?

PS: I tried to make an upgrade from PS1778 to PS1782 using this PR => ok

Thanks!

@jolelievre
Copy link
Contributor Author

Hi @khouloudbelguith

sorry I cowardly left this PR's responsibility to @atomiix so I believe he is looking into it but can't reproduce the bug...

@khouloudbelguith
Copy link

Hi @jolelievre, @atomiix,

I tried again with PS1782 fresh install & an upgrade to the PR & same error

Untitled_.Jan.12.2022.2_59.PM.mp4

Thanks!

@atomiix
Copy link
Contributor

atomiix commented Jan 12, 2022

@khouloudbelguith it seems that your PHP version is 7.1, can you try with PHP 7.2 or above as the develop branch is not compatible with PHP < 7.2?

Also, you'll have to delete ps_facebook & ps_metrics before the upgrade, they are not compatible yet with develop

Copy link

@khouloudbelguith khouloudbelguith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @atomiix,

Yes, It is ok with PHP7.3
image
I tried to make an upgrade from PS1782 to PrestaShop/PrestaShop#27276
But after the upgrade, I have a lot of exceptions:

  1. Go to BO > Orders > View Order > See exception
    image
  2. Go to BO > Orders > Shopping cart page > See exception
    image
  3. Go to BO > Customers page > View customer > see exception
    image
  4. Go to BO > Modules > Module Catalog > See exception
    image
  5. Go to FO > Sign in > Se exception
    image

Thanks!

@atomiix
Copy link
Contributor

atomiix commented Jan 14, 2022

@khouloudbelguith I think we might be in an infinite loop as this PR #441 seems to be solving the issue you just had but to validate it you need this one 😅
Maybe we can merge this one as the upgrade itself went well, see if #441 solve the issue you had and if not, create a new issue. WDYT?

Copy link

@khouloudbelguith khouloudbelguith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @atomiix, @jolelievre,

Could you please check the Conflicting files?

Thanks!

@atomiix atomiix force-pushed the mail-generation-command branch from de5d119 to b99c34d Compare February 9, 2022 16:54
@atomiix atomiix force-pushed the mail-generation-command branch from 1956b15 to 86678ea Compare February 9, 2022 17:49
@Progi1984 Progi1984 added this to the 4.15.0 milestone Feb 15, 2022
Copy link

@khouloudbelguith khouloudbelguith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @atomiix, @jolelievre,

It is ok ✔️

I tried to upgrade PS1778 to PS1783 using this PR => OK (PHP7.3)
I tried to generate modern/classic emails in different languages (RTL & non RTL)
I tried to check the HTTP of emails 'Modern template / classic template)
I tried to translate some emails and resend them

I tried to upgrade from PS1769 to 178x branch using this PR
I tried to generate some emails with RTL to check this issue: => ok

I tried to upgrade from PS1783 to this PR: PrestaShop/PrestaShop#27276 => OK
I tried to upgrade from 178x branch to this PR: PrestaShop/PrestaShop#27276 => OK

upgrade178x_develop_Pr
I tried to generate some emails in Arabic language & English language
I checked Gmail, outlook web version, outlook desktop version, maildev server

Untitled_.Feb.16.2022.12_56.PM.mp4

I found some bugs but not the scope of this PR, which are blocking

PS:

Before the upgrade to this PR: PrestaShop/PrestaShop#27276
I uninstall those modules: ps_metrics, ps_facebook, Prestashop Checkout, Google marketing, welcome
After the upgrade

  1. Go to BO > Orders > View Order > See exception & Add new order from BO, will be fixed with this Add SQL upgrade queries for new unit price column #441
    image

  2. Go to BO > Orders > Shopping cart page > See exception => will be fixed with this Add SQL upgrade queries for new unit price column #441
    image

  3. Go to BO > Customers page > View customer > see exception => will be fixed with this Add SQL upgrade queries for new unit price column #441
    image

  4. Go to BO > Modules > Module Catalog > See exception => I will create a new issue.
    image

  5. Go to FO > Sign in > See exception => will be fixed with this Add SQL upgrade queries for new unit price column #441
    image

  6. Go to FO as a visitor & add a product to cart > see exception => will be fixed with this Add SQL upgrade queries for new unit price column #441
    image

  7. Go to BO > SEO & URLs > Reffers Tab > see exception => will be fixed here: Remove the page Referrers PrestaShop#27098
    image

  8. Go to BO > SEO & URLs page > see exception => I will create a new issue
    image

  9. Go to BO > Design > Email theme > choose any theme (Classic or modern) > View Htpp or any action for order_conf > see exception => will be fixed with this Add SQL upgrade queries for new unit price column #441
    image

  10. The Security menu is not displayed => I will create a new issue.

Thanks!

@Progi1984
Copy link
Member

Thanks @jolelievre & @khouloudbelguith

@matks matks mentioned this pull request Apr 25, 2022
atomiix pushed a commit to atomiix/autoupgrade that referenced this pull request Sep 16, 2022
…mand

Use GenerateThemeMailTemplatesCommand during upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autoupgrade - Error during upgrade to develop
7 participants