kilbot / WooCommerce-POS

:bangbang: All development now at https://github.com/wcpos.
http://wcpos.com
GNU General Public License v3.0
353 stars 125 forks source link

POS conflict with NewRelic #122

Open itecedor opened 8 years ago

itecedor commented 8 years ago

I think an external library updated overnight or something, because it was working yesterday (and I haven't changed anything on my site since yesterday). Now when we try to use the POS, this is what we see:

screenshot 2016-05-06 13 02 46

Browser console shows: screenshot 2016-05-06 13 03 22

itecedor commented 8 years ago

Further digging revealed that the bad data is in the response from wp-admin/admin-ajax.php?security=adfbc650e3&action=wc_pos_payload, and here's the bad section:

{ "templates": { "print": { "receipt": "<html><head><meta charset=\"utf-8\"><script type="text/javascript">window.NREUM||(NREUM={}),

I have no idea how that got in there or how to fix it =(

otherjohn commented 8 years ago

Same problem with ours

otherjohn commented 8 years ago

looks like the <script type="text/javascript" needs to be passed like <script type=\"text/javascript\"

otherjohn commented 8 years ago

The script being injected is a new relic browser javascript. I think this is a hosting issue. I am using wpengine and am contacting them.

itecedor commented 8 years ago

@otherjohn I'm on wpengine too, couldn't figure out where this json was being created

otherjohn commented 8 years ago

Ok, this is an issue where the New Relic script is being auto injected at the server level. It's not a code problem. To turn it off, you need to request that the host turn it off for your install.

kilbot commented 8 years ago

Hi guys, thanks for reporting this issue.

From what you describe, the server is injecting javascript into the receipt template. WooCommerce POS is a javascript web app, so any script tag in a template is going to kill the app.

The demo is hosted on WPEngine as well but doesn't seem to have this problem (yet). I had a look through the WPEngine site and couldn't see anything about NewRelic. Do you know if it only applies to certain plans?

Also, I'm wondering if you guys have custom receipt templates? Perhaps it only applies for files in the wp-content/themes folder?

itecedor commented 8 years ago

Yes I do have a custom receipt template, that's probably the difference! Thanks @kilbot

kilbot commented 8 years ago

The next version of WooCommerce POS stores the custom templates in the DB, rather than a file, this may fix the issue.

@itecedor Can you let me know if removing the custom template fixed the problem? I'm still surprised that WPEngine/NewRelic would insert code into every file ... that seems like over-reach to me.

ReindDooyeweerd commented 8 years ago

Same issue over here on the "production" environment here where New-Relic is used. Anyone allready has an solution for this? I didn't use any customized template, just an fresh Wordpress / Woocommerce installation with Woopos on top of it. schermafbeelding 2016-05-09 om 21 06 58

EDIT After updating all new-relic scripts on the server (apt-get upgrade) and an reboot everything seems to work fine again.

otherjohn commented 8 years ago

wpengine turned off this feature after I reported it. I think they did it server wide. You can manually turn it off with editing a flag in the php.ini.

New Relic looks for files that contain certain html tags and injects the content on just those files. If the template is stored in the DB then it will not be affected by this. John