magento2: Email template displayed incorrectly when using depend inside an if

Preconditions and environment

  • Magento version: 2.4.5-p1
  • Magento version: 2.4.4-p2

Steps to reproduce

  1. Go to admin -> marketing -> email templates
  2. Click Add new email template
  3. Load Default Template form “New Order”

Add these lines before greeting/or wherever you want {{if order_id}} {{depend order_id}} {{trans 'My order id is: <span class="no-link">%order_id</span>.' order_id=$order_id |raw}} {{/depend}} {{/if}}

So looks like this:

        {{if order_id}}
            {{depend order_id}}
            {{trans 'My order id is: <span class="no-link">%order_id</span>.' order_id=$order_id |raw}}
            {{/depend}}
        {{/if}}

        <p class="greeting">{{trans "%customer_name," customer_name=$order_data.customer_name}}</p>
  1. Save email template and go to stores -> configuration -> sales -> sales emails
  2. Add this new email template to “New Order Confirmation Template” than save it
  3. Clear cache
  4. Place and order in frontend and see the email content. image

The if condition is not processed.

I see that this in 2.4.5 (without p2) it is working. Probably the issue is in the filter function, which is in the vendor/magento/framework/Filter/Template.php file

When i compare this with 2.4.5 version it way to different

2.4.5-p2 image

2.4.5 image

Expected result

if condition in email template processed correctly

Actual result

if condition in email template not processed correctly

Additional information

this issue also happening on Magento 2.4.4-p2

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 23 (13 by maintainers)

Most upvoted comments

For anyone else who is getting this issue on 2.4.6-p3, this is a patch pulling in the lastest version of vendor/magento/framework/Filter/Template.php (from 2.4-develop) This may also work on other versions, but I haven’t tested.

  1. Install the patch. (Alternatively download and store in local path)
composer config --json --merge extra.patches.magento/framework '{"Fixes https://github.com/magento/magento2/issues/36438":"https://raw.githubusercontent.com/zero1limited/magento2- patches/master/patches/issue/36438/2.4.6-p3.patch"}'
  1. Apply the patch
composer install

Reproducible in 2.4.6-p3 as well.

@hostep None of the 2.4.6 security fixes will be merged back into 2.4-develop until after 2.4.6 is GA in March’23. 2.4.5-p1, 2.4.4-p2 and 2.4.6 all have their own scope and all security fixes are kept private until the release is GA.

As for the issue being described here, we are taking a look at this issue via internal ticket AC-7093

@nathanjosiah: I’m talking about the security fixes from 2.4.5-p1 (which already went GA more than a month ago), not upcoming ones from 2.4.6 😉 These really should get merged in 2.4-develop, otherwise new bugs introduced by them can’t be verified.

❌ You don’t have permission to export this issue.

Small update on this, the changes from AC-7093 are based on some security work that was done for the upcoming GA on March 14. For that reason, we cannot move the change to the public branches until the final release branches for 2.4.6 (which contain security fixes) are synced back into 2.4-develop. That means it will be at LEAST March 14 before we can move them but this process of synchronization usually takes a couple of weeks to finalize for every GA release.

@hostep The ticket is AC-7093. It was merged but for some reason it was merged to private branches. I’m not sure why it was merged this way and I’m trying to find out.

That said, I’m not sure why this was closed by @engcom-Lima as “cannot reproduce”. This is a valid issue which has been escalated by a number of merchants. However, there is also workaround of just not using this specific combination. You can recreate the same templates by using a combination of if and else instead of depend.

Hi @igi8819 ,

Thanks for your contribution and collaboration.

We have tried to reproduce the issue in latest 2.4-develop but issue is not reproducible. This issue will get fixed in upcoming version. Hence , closing this issue as not reproducible. Please feel free to reopen this ticket if you are facing any issue.

Thanks

@hostep None of the 2.4.6 security fixes will be merged back into 2.4-develop until after 2.4.6 is GA in March’23. 2.4.5-p1, 2.4.4-p2 and 2.4.6 all have their own scope and all security fixes are kept private until the release is GA.

As for the issue being described here, we are taking a look at this issue via internal ticket AC-7093