Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.78k stars 894 forks source link

Syntax error from Yoast when editing pages with Visual Composer 5.2 #7961

Closed jgryn closed 4 years ago

jgryn commented 7 years ago

Please give us a description of what happened.

When editing a page with Visual Composer 5.2, we get the following error in the console (note, it only shows up if the editor has visual composer on that particular page.

Uncaught SyntaxError: Unexpected token < in JSON at position 9 at JSON.parse () at a.saveParsedShortcodes (wp-seo-shortcode-plugin-551.min.js?ver=5.5.1:1) at a. (wp-seo-shortcode-plugin-551.min.js?ver=5.5.1:1) at i (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery-ui-mouse,jquery-ui-position,jquery-ui-menu,wp-a11y,jquer&load[]=y-ui-autocomplete,plupload,jquery-ui-draggable,jquery-ui-slider,jquery-touch-punch,iris,wp-color-picker,jquery-ui-tooltip&ver=4.8.2:2) at Object.fireWith [as resolveWith] (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery-ui-mouse,jquery-ui-position,jquery-ui-menu,wp-a11y,jquer&load[]=y-ui-autocomplete,plupload,jquery-ui-draggable,jquery-ui-slider,jquery-touch-punch,iris,wp-color-picker,jquery-ui-tooltip&ver=4.8.2:2) at y (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery-ui-mouse,jquery-ui-position,jquery-ui-menu,wp-a11y,jquer&load[]=y-ui-autocomplete,plupload,jquery-ui-draggable,jquery-ui-slider,jquery-touch-punch,iris,wp-color-picker,jquery-ui-tooltip&ver=4.8.2:4) at XMLHttpRequest.c (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,utils,jquery-ui-widget,jquery-ui-mouse,jquery-ui-position,jquery-ui-menu,wp-a11y,jquer&load[]=y-ui-autocomplete,plupload,jquery-ui-draggable,jquery-ui-slider,jquery-touch-punch,iris,wp-color-picker,jquery-ui-tooltip&ver=4.8.2:4)

Please describe what you expected to happen and why.

Expected to be no errors in the console.

How can we reproduce this behavior?

Technical info

benvaassen commented 7 years ago

Thank you for reporting this issue. I've added it to the backlog of our developers.

Ad-Ok commented 6 years ago

Any updates for this? I have the similar error 4 months later, version 6.3

Dedrago commented 6 years ago

Still getting the error. Please fix.

gamedevsteve commented 6 years ago

We're seeing a similar issue and it seems like it's trying to parse rendered shortcode as json.

a.prototype.saveParsedShortcodes = function(a, b) {
                a = JSON.parse(a);
                for (var c = 0; c < a.length; c++)
                    this.parsedShortcodes.push(a[c]);
                b()
            }

Found this in the minified wp-seo-shortcode-plugin js file where a is html as rendered by our shortcode.

gamedevsteve commented 6 years ago

Our shortcode was outputting HTML. We wrapped that portion with an ob_start() and ob_get_clean() and avoided the syntax error.

amboutwe commented 5 years ago

Please inform the customer of conversation # 451920 when this conversation has been closed.

amboutwe commented 5 years ago

Uncaught SyntaxError: Unexpected token < in JSON at position 0

Above conversation is not using Visual Composer. Instead it's a conflict with Affiliate Toolkit.

malakani commented 5 years ago

I am experiencing the same issues with WPBakery Page Builder and custom shortcodes that I built that output HTML,

jugaldumkaGP commented 4 years ago

Even i'm experiencing the same issue with the WPBakery Page Builder, guys any update on this?

stodorovic commented 4 years ago

I'm trying to explain how to you could debug more details. You should open browser console - Network. More details: https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor https://developers.google.com/web/tools/chrome-devtools/network/reference https://www.youtube.com/watch?v=vAC1SVlh7o0

When you open "Network" (while you are editing post) then you should locate admin-ajax.php request with action wpseo_filter_shortcodes (see parameters for all XHR requests). bad_shortcode_yoast

As you can see there is shortcode "my_bad_shortcode" which directly outputs some text (before JSON). It'll break JSON parser. It could be text from shortcode or even PHP notice/warning. When you find out this text (and possible shortcode) then it's easier to solve specific issue. If there are more shortcodes then you should remove one by one until you locate problematic shortcode.

monbauza commented 4 years ago

+1 HS Ticket 584975. When investigating this ticket, I found out that the JSON error also occurs when running the Yoast content analysis under SEO > Tools (Yoast SEO Premium) . The error causes the analysis to halt.

Djennez commented 4 years ago

I'm not getting any of these issues / errors on a default installation with WP 5.3.2, Yoast Premium 13.0 and WPBagery Page Builder 6.1.

Going to close this one, since the information in this issue does not lead me to believe that there is an error in our plugin. If you come along this thread because you're having the same issues, please feel free to open a new issue following our bugreport template and provide all errors and reproduction steps you can find.