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

Default language and assigned shop languages inconsistencies #32986

Open
2 tasks done
Tracked by #11687
cruftex opened this issue Jun 23, 2023 · 5 comments
Open
2 tasks done
Tracked by #11687

Default language and assigned shop languages inconsistencies #32986

cruftex opened this issue Jun 23, 2023 · 5 comments
Labels
1.7.8.9 Affects versions Bug Type: Bug Email Label: Which BO under menu is concerned Languages Label: Which BO under menu is concerned Minor Severity: minor bug > https://build.prestashop.com/news/severity-classification Order Component: Which BO section is concerned Ready Status: Issue is ready to be worked on Shopping carts FO All the issues related to the Front Office Shopping Cart Verified The issue has been reproduced

Comments

@cruftex
Copy link
Contributor

cruftex commented Jun 23, 2023

Prerequisites

Describe the bug and add attachments

When the default shop language is not within the assigned languages (Which is a configuration error), the shop looks working normal. However, when an order is made, the confirmation mail of the payment is sent in the default language and not in the user language, and the redirect to the payment confirmation page resulted in a wrong URL and yields a 404.

Expected behavior

It is a misconfiguration, so, according to GIGO everything is allowed to happen. OTOH, the behaviour reveals some inconsistencies which might cause problems in other scenarios as well.

Possible improvements:

  • Allow to select the shop default language from the supported set of languages only
  • Refuse operation at all, if default language is not in the supported set of languages
  • Alternatively, add the default language implicitly to the set of supported languages. This would save a lot of trouble.
  • Remove inconsistencies in the code, see below

Findings in the code:

The FrontController creates the cart with the language from the cookie.

        if (!isset($cart) || !$cart->id) {
            $cart = new Cart();
            $cart->id_lang = (int) $this->context->cookie->id_lang;

But usually Context::getContext()->language->id is used. The problem is that the both might differ, because id_lang in the cookie is not sanitised and may be a not supported language.

The PaymentModuleCore->validateOrder changes the context language to the cart language.

            $this->context->language = $this->context->cart->getAssociatedLanguage();

This is correct behaviour, because we want to send the mail in the language present while ordering. However, the context language needs to be restored to the initial request language after that.

This is all low prio. However, I thought it's worth writing down. Let me know whether this is helpful or not.

Steps to reproduce

I am using multi site, however, it should be the same with a single shop.

  1. Install English and German
  2. Enable German only
  3. Set default Language to English
  4. Make test order with a payment provider that does a redirect to the confirmation page (e.g. Stripe)
  5. Confirmation mail is send in English
  6. Redirect goes to /order-confirmation instead of /bestellbestatigung and yields 404

PrestaShop version(s) where the bug happened

8.0.4

PHP version(s) where the bug happened

8.1

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

No response

Your company or customer's name goes here (if applicable).

headissue GmbH

@cruftex cruftex added Bug Type: Bug New New issue not yet processed by QA labels Jun 23, 2023
@sallemiines
Copy link
Contributor

Hello @cruftex

I didn't manage to reproduce your issue with PS 804 !
Could you please provide us some screenshots or screen recorder for the result you had !

Waiting for your feedback
Thank you !

@sallemiines sallemiines added Waiting for author Status: action required, waiting for author feedback NMI Status: issue needs more information Order Component: Which BO section is concerned Languages Label: Which BO under menu is concerned Shopping carts FO All the issues related to the Front Office Shopping Cart 8.0.4 Affects versions and removed New New issue not yet processed by QA labels Jun 23, 2023
@cruftex
Copy link
Contributor Author

cruftex commented Jun 23, 2023

@sallemiines:
Thanks for trying to reproduce.

I just checked with a single site. When I try to disable the default language, I get the error:

You cannot change the status of the default language.

That looks great!

So the problem is emerging with multi store feature only.

  • Fresh 8.0.4 from docker, with EN and DE, config settings:
    PS_LANGUAGE: "en"
    PS_COUNTRY: "de"
  • Enable multi store
  • Optional:
    • Localization > Languages > Languages Tab, click Edit on "English", remove shop association and save
    • This results in: "This field cannot be empty.", Good!
  • Add a second store
  • Localization > Languages > Languages Tab, click Edit on "English", remove shop association from shop "PrestaShop" and save
  • Association English cloud be removed
MariaDB [shop]> select * from ps_lang_shop;
+---------+---------+
| id_lang | id_shop |
+---------+---------+
|       1 |       2 |
|       2 |       1 |
|       2 |       2 |
+---------+---------+
3 rows in set (0.001 sec)

Shop 1 has only language 2 associated, while the default is 1 (English).

  • Go to the shop, -> it has UI language German (associated ID 2).
  • Put a product in the cart and check cart language via SQL ->
MariaDB [shop]> select id_cart, id_lang, date_add   from ps_cart;
+---------+---------+---------------------+
| id_cart | id_lang | date_add            |
+---------+---------+---------------------+
|       1 |       1 | 2023-06-23 11:21:39 |
|       2 |       1 | 2023-06-23 11:21:39 |
|       3 |       1 | 2023-06-23 11:21:39 |
|       4 |       1 | 2023-06-23 11:21:39 |
|       5 |       1 | 2023-06-23 11:21:39 |
|       6 |       1 | 2023-06-23 12:06:18 |
+---------+---------+---------------------+
6 rows in set (0.001 sec)

Although the shop speaks only German, the cart language is English.
This will lead then to the wrong confirmation mail and redirect resulting in 404.

There should be more scenarios that are problematic, when exploiting the several contributing factors more isolated. For example:

  • Fresh single site, with en and de, en is default
  • put product in the cart
  • change language to de
  • complete order in de / German language
  • order confirmation will (possibly) be send in English, expected: German

@prestashop-issue-bot prestashop-issue-bot bot removed the Waiting for author Status: action required, waiting for author feedback label Jun 23, 2023
@AureRita
Copy link
Contributor

Hi @cruftex

Thank you for the details, I reproduce the issue with PrestaShop version 1.7.8.9. Asi you can see :

Untitled_.Jun.26.2023.2_30.PM.webm

I'll add this to the backlog so it can be fixed.

Please be aware that some issues might take a very long time to be resolved.

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.

Thanks

@AureRita AureRita added Minor Severity: minor bug > https://build.prestashop.com/news/severity-classification Email Label: Which BO under menu is concerned Ready Status: Issue is ready to be worked on Verified The issue has been reproduced 1.7.8.9 Affects versions and removed NMI Status: issue needs more information 8.0.4 Affects versions labels Jun 26, 2023
@JakubSVK
Copy link

Hi !

Please check if you have a valid language for your correct store. You should turn off - Set language from browser and Default country. Maybe it helps

I had same problem.

image

@cruftex
Copy link
Contributor Author

cruftex commented Jun 27, 2023

@JakubSVK
Thanks. I actually "fixed" my problem once I discovered that I had a misconfiguration and that I set the default language to English while only supporting German. Once this was corrected, the problem was gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.7.8.9 Affects versions Bug Type: Bug Email Label: Which BO under menu is concerned Languages Label: Which BO under menu is concerned Minor Severity: minor bug > https://build.prestashop.com/news/severity-classification Order Component: Which BO section is concerned Ready Status: Issue is ready to be worked on Shopping carts FO All the issues related to the Front Office Shopping Cart Verified The issue has been reproduced
Projects
None yet
Development

No branches or pull requests

4 participants