HTML comments ruined my api
-
Thank you for this great plugin! @tillkruess but…
I’m running an API server that will serve JSON codes to my users, with your plugin adding message:
<!-- Performance optimized by Redis Object Cache. Learn more: https://wprediscache.com -->to every page of site, my JSON output also with this message, this cause my users keep getting errors by decoding the JSON, this is NOT cool.
Please consider give an option in back-end or remove this in the future. Thank you!
-
Same here. Does also effect the WooCommerce API.
Thanks for bringing this to my attention!
Are you both on v1.6.2 or an earlier version?
Before the HTML comment is printed, the plugin makes sure it’s not a JSON request or any of the REST constants are set.
However, you can turn off the comment using the “WP_REDIS_DISABLE_COMMENT“ constant. https://github.com/tillkruss/redis-cache/wiki/Configuration-Options#wp_redis_disable_comment-default-not-set
I’ve tested the WP and WC API and both work with v1.6.2:
curl https://wordpress.test/wp-json/wc/v3 curl https://wordpress.test/wp-json/wp/v2/users/meIf you’re on V1.6.2 could either of you send me a example URL of their API request, so I can try to replicate that?
Hi @tillkruess
The earlier version of this plugin works great, this issue came along with the latest update 1.6.2 in yesterday or the day before yesterday.I clicked update this plugin and go to sleep, when I woke up my message box was like 30 unreads LOL, users complaining about getting errors on their ends with my JSON output.
The php decode JSON from my server returning Null all the time.
I debug my codes like 3 hours then found the comment below the JSON output from Redis Object Cache plugin.
Sorry for complaining about this, still a great plugin, cheers!
No, I appreciate you bringing this to my attention.
Could you point me to your API, at give me a sample request URL?
@freeduke: Would you be up for a quick screenshare, so I can make sure this doesn’t happen to anyone else on Monday? 🙂
Please wait a moment, I will build a testing server to reproduce it, I’ve manually deleted the comment from my production server earlier this day. 🙂
You can find my email and Twitter here, whatever you prefer.
This is in a testing sever still with the comment:
http://demo.dukeyin.com/?slm_action=slm_check&secret_key=5ed3d2fb85b862.66778230&license_key=5ed3d323d52d1®istered_domain=&item_reference=These json came from another plugin called “Software License Manager”.
Thanks, this is very helpful. I’m gonna work on a fix.
Thank you very much!
I’ve come up with a good solution to prevent this from happening.
Will release v1.6.3 shortly.
Thank you for you help!
This is indeed an unthoughtful bad practice, please don’t do this ever again 🙁
The topic ‘HTML comments ruined my api’ is closed to new replies.