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

xPath error in mails #4737

Closed
lgt opened this Issue May 27, 2016 · 57 comments

Comments

Projects
@lgt
Copy link

lgt commented May 27, 2016

I'm using magento 2.0.7 and I get the following error on order mail confirmation.Swicthing from default to production the error is still there. This seems to be related to the included css in header.
If I remove
{{inlinecss file="css/email-inline.css"}} than I do not get the error, but still need some styling!
How to suppress ?

CSS Inline Error: Warning: DOMXPath::query(): Invalid expression in .../vendor/pelago/emogrifier/Classes/Emogrifier.php on line 269

@designhunger

This comment has been minimized.

Copy link

designhunger commented May 30, 2016

I get the same error, but not exclusive in the order confirmation, but on all magento mails (magento 2.0.6)

@eug123

This comment has been minimized.

Copy link
Contributor

eug123 commented May 31, 2016

Hi @lgt
What theme is applied? Have you deployed static content before switching to production?

@juliansthl

This comment has been minimized.

Copy link

juliansthl commented Jun 2, 2016

We have the same issue.
Our theme is based on the blank theme. The issue even appears if we don't override the Magento_Email template files.

We have deployed static content.

@eug123

This comment has been minimized.

Copy link
Contributor

eug123 commented Jun 3, 2016

Hi,

It seems that the error happens when converting styles from email-inline.css to the inline style attribute with Emogrifier tool.

Please try to update this package changing version to 1.0.0 in composer.json ("pelago/emogrifier": "1.0.0") and running composer update.

Could you also check if the issue appears on your environment when one of the native themes is applied?

@juliansthl

This comment has been minimized.

Copy link

juliansthl commented Jun 27, 2016

Hi,

sorry for my late reply.
The issue was that email-inline.less was loading less files from our theme's source and the Emogrifier tool was having problems with a few style declarations.

Thanks,
Julian

@nickmarx12345678

This comment has been minimized.

Copy link

nickmarx12345678 commented Jul 21, 2016

@eug123 I'm also having this issue, but I don't see emogrifier as a dependency in our composer.json

any other suggestios?

@nickmarx12345678

This comment has been minimized.

Copy link

nickmarx12345678 commented Jul 21, 2016

@eug123 update, it may be a sub-dependency. In our composer.lock, emogrifier as version 0.1.1

how would you recommend proceeding to get that version bumped to 1.0.0?

@AntonEvers

This comment has been minimized.

Copy link
Contributor

AntonEvers commented Aug 11, 2016

If you let Magento minify css ul > li becomes ul>li. Emogrify turns this into xpath //ul>li instead of //ul/li so the html nodes are never matched.

This is fixed in MyIntervals/emogrifier@81947fd which is scheduled for version 1.1.0 of pelago/emogrifier. Will you upgrade to v1.1.0 when it's out?

@AntonEvers

This comment has been minimized.

Copy link
Contributor

AntonEvers commented Aug 11, 2016

@nickmarx12345678 put this in the require-dev part of composer.json:

"pelago/emogrifier": "1.0.0 as 0.1.1",

Or if you prefer the development version:

"pelago/emogrifier": "dev-master as 0.1.1",

@buskamuza buskamuza removed their assignment Aug 18, 2016

@DevManav

This comment has been minimized.

Copy link

DevManav commented Aug 24, 2016

Hi @lgt,
I'm also having this issue in all mail. Is there any solution for this issue? Please let me know if any one has a solution.

@adamraya

This comment has been minimized.

Copy link

adamraya commented Aug 24, 2016

I had this problem too, seems like emogrifier had trouble with a multiline comment /* code */ inside a media query in one of the .less files of our theme based on the blank theme.

@oliverklee

This comment has been minimized.

Copy link
Contributor

oliverklee commented Aug 24, 2016

@adamraya Could you please file a ticket at the Emogrifier issues list with the offending HTML and CSS? Then we can have a look at it. Thanks! ❤️

@veloraven

This comment has been minimized.

Copy link
Contributor

veloraven commented Aug 26, 2016

@antonkril please have a look at this.

@DevManav

This comment has been minimized.

Copy link

DevManav commented Aug 31, 2016

@antonkril I had this problem in all mails same as @lgt. This error is comes when my custom created theme is applied , if i select default theme blank or luma email templates working fine. Is there any solution?

@itelebar

This comment has been minimized.

Copy link

itelebar commented Sep 5, 2016

Hi everyone, we had this issue on one site and also noticed that it is not happening when using Luma so conclusion was it must be something we have included into our theme.

I our case Font Awesome we included was root of an issue.

In file font-awesome/_animated.less there are selectors that are breaking the flow. In this case those were keyframes definitions for start and end of animation.

As we don't need this solution was simply disabling/commenting out font-awesome/_animated.less in file font-awesome/_font-awesome.less.

If you check official comment in vendor/magento/theme-frontend-blank/web/css/source/_email-base.less you will find that it is documented what kind of selectors are allowed. This might get updated in future but it is up to Emogrifier. Until all selectors are allowed we as developers should be aware of everything that is getting included and might possibly cause an error.

My advice is to use xDebug and keep an eye/breakpoint on vendor/pelago/emogrifier/Classes/Emogrifier.php (line 269) as this is place where exception is thrown. This way you can easily find out which part of CSS is causing an issue.

Hope this helps anyone!

@mrkhoa99

This comment has been minimized.

Copy link
Contributor

mrkhoa99 commented Sep 7, 2016

Hi all,
This issue also occurs because the email style will import some less files. And then, we add some unsupported selectors to these files. Read more: http://magento.stackexchange.com/a/132691/33057

@DevManav

This comment has been minimized.

Copy link

DevManav commented Sep 13, 2016

Hi all,
I solved this problem in my site by below step:-
step-1:- copy email less and css file from blank theme under below path
app/design/frontend/Your_vendor/Your_theme_neme/web/css
app/design/frontend/Your_vendor/Your_theme_neme/web/css/source
step-2:- After that run command setup:static-content:deploy Your_language.

step-3:- Clear below directory
var/cache
var/generation
var/view_preprocessed
That's it Now check your email error is resolved and if you want to change your email design ,your email css is located in
app/design/frontend/Your_vendor/Your_theme_neme/web/css/email-inline.css

@Bartlomiejsz

This comment has been minimized.

Copy link
Contributor

Bartlomiejsz commented Oct 19, 2016

@veloraven @antonkril are there any updates? Do you know when pelago/emogrifier will be up to date with latest release?

@oliverklee

This comment has been minimized.

Copy link
Contributor

oliverklee commented Jan 22, 2018

In the meantime, we have released Emogrifier 2.0.0. I've created a PR to update to this version: #13132

@electricBonfire

This comment has been minimized.

Copy link

electricBonfire commented Apr 4, 2018

2 years later and this is still an issue... I'm really regretting choosing Magento :(

@magento-engcom-team

This comment has been minimized.

Copy link
Contributor

magento-engcom-team commented Apr 14, 2018

Hi,
Looks like the issue has been fixed by updating to Emogrifier 2.0.0.
Thanks to everyone for collaboration!

@nikidexa

This comment has been minimized.

Copy link

nikidexa commented Apr 19, 2018

Hi, I have the same problem, so it looks like been fixed by udpdating Emogrifier 2.0.0
How can I update this file? sorry fro this question, but I'm learning now to use magento 2
thanks

@Puru2016

This comment has been minimized.

Copy link

Puru2016 commented May 16, 2018

I am facing same issue in Magento ver 2.2.3,

My composer ver is:-
vendor\magento\magento2-base\composer.json => "pelago/emogrifier": "1.2.0"

Please suggest the solution for this

@oliverklee

This comment has been minimized.

Copy link
Contributor

oliverklee commented May 16, 2018

@Puru2016 Does an upgrade to emogrifier ^2.0.0 solve the problem for you?

@Puru2016

This comment has been minimized.

Copy link

Puru2016 commented May 19, 2018

I have changed "pelago/emogrifier": "1.2.0" to "pelago/emogrifier": "2.0.0", and update the composer and then recompile the store , still same issue.

@mattkrupnik

This comment has been minimized.

Copy link

mattkrupnik commented May 21, 2018

Magento 2.2.3
Just add this to the composer require "pelago/emogrifier": "2.0.0 as 1.2.0" then run composer update pelago/emogifier and it solved problem.

@nikidexa

This comment has been minimized.

Copy link

nikidexa commented May 21, 2018

Magento 2.2.3
Just add this to the composer require "pelago/emogrifier": "2.0.0 as 1.2.0" then run composer update pelago/emogifier and it solved problem.

Im still using Magento 2.2.2... is it the same?

@mattkrupnik

This comment has been minimized.

Copy link

mattkrupnik commented May 21, 2018

@nikidexa I think that it will be working on 2.2.2 but I did not test.

@nikidexa

This comment has been minimized.

Copy link

nikidexa commented May 21, 2018

Yes, I can confirm that now is working good for me too....
so the solution is:
-add this line to composer.json : "pelago/emogrifier": "2.0.0 as 1.2.0"
-run -> composer update pelago/emogifier

thanks to everyone

@rcoelros

This comment has been minimized.

Copy link

rcoelros commented May 22, 2018

@Puru2016

This comment has been minimized.

Copy link

Puru2016 commented May 26, 2018

Still issue is there as I am not able to update the "pelago/emogrifier" due to below error:-

Problem 1
- magento/magento2-base 2.2.3 requires pelago/emogrifier 1.2.0 -> satisfiable by pelago/emogrifier[V1.2.0] but these conflict with your requirements or minimum-stability.
- magento/magento2-base 2.2.3 requires pelago/emogrifier 1.2.0 -> satisfiable by pelago/emogrifier[V1.2.0] but these conflict with your requirements or minimum-stability.
- magento/magento2-base 2.2.3 requires pelago/emogrifier 1.2.0 -> satisfiable by pelago/emogrifier[V1.2.0] but these conflict with your requirements or minimum-stability.
- Installation request for magento/magento2-base (locked at 2.2.3) -> satisfiable by magento/magento2-base[2.2.3].

I have tried with below "pelago/emogrifier" version:-
"pelago/emogrifier": "1.0.0 as 0.1.1"
"pelago/emogrifier": "2.0.0 as 1.2.0",
"pelago/emogrifier": "1.0.0 as 0.1.1",
"pelago/emogrifier": "dev-master as 0.1.1",

in vendor\magento\magento2-base\composer.json
Please suggest the solution if I am doing wrong in the above process.

My exact error is as below in email template:-
CSS inlining error: DOMXPath::query(): Invalid expression in selector >> 50% << in /var/www/html/magento2/vendor/pelago/emogrifier/Classes/Emogrifier.php on line 370"

@crtl

This comment has been minimized.

Copy link

crtl commented Jun 20, 2018

Ive recently updated from Magento 2.1.11 to 2.2.4 and got this exception.
Installed version of pelago/emogrifier is v2.0.0.

Exception is:
[2018-06-20 08:29:16] main.ERROR: DOMXPath::query(): Invalid expression in selector >> 100% << in /path/to/magento/vendor/pelago/emogrifier/Classes/Emogrifier.php on line 372 {"exception":"[object] (InvalidArgumentException(code: 1509279985): DOMXPath::query(): Invalid expression in selector >> 100% << in /path/to/magento/vendor/pelago/emogrifier/Classes/Emogrifier.php on line 372 at /path/to/magento/vendor/pelago/emogrifier/Classes/Emogrifier.php:1785)"} []

@ronin1310

This comment has been minimized.

Copy link

ronin1310 commented Jun 25, 2018

Same situation here. Magento 2.2.4, pelago/emogrifier in version 2.0.0.
Issue is still valid.

@chammedinger

This comment has been minimized.

Copy link

chammedinger commented Jul 17, 2018

Again having the same issue on Magento 2.2.5.
I had it fixed with the composer line "pelago/emogrifier": "2.0.0 as 1.2.0" on Magento 2.2.3
but sadly on 2.2.5 this fix does not work anymore.

@chammedinger

This comment has been minimized.

Copy link

chammedinger commented Jul 17, 2018

found a solution for Magento 2.2.5:

created the files
/web/css/email.less and
/web/css/email-inline.less
in my custom theme and added the content from
/vendor/magento/theme-frontend-blank/web/css/email.less and
/vendor/magento/theme-frontend-blank/web/css/email-inline.css respectively
but each with the line "@import 'source/_theme.less';" commented out (or removed)

@tehtea

This comment has been minimized.

Copy link

tehtea commented Jul 20, 2018

@chammedinger your fixed worked, thank you! If you don't mind sharing, what is your thought process towards fixing the bug?

@jorgb90

This comment has been minimized.

Copy link

jorgb90 commented Nov 2, 2018

@tehtea Probably your _theme.less file is causing the css problem for the transactional emails, so by including the email-inline.less and email.less into your theme you are overwriting it and by commenting @import _theme.less you fix the error by excluding it :)

@pratikhmehta

This comment has been minimized.

Copy link

pratikhmehta commented Jan 9, 2019

composer.json >> require-dev >> "pelago/emogrifier": "dev-master as 0.1.1"
Then composer update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment