seo icon indicating copy to clipboard operation
seo copied to clipboard

SEO failed to retrieve entry preview

Open icreatestuff opened this issue 5 years ago • 16 comments

Description

When loading or saving an entry that has content within the SEO field's 'Focus Keywords' area we see the error 'SEO failed to retrieve entry preview'. This seems to have only become a problem since an update to Craft 3.5

Additional info

  • Craft version: 3.5.11.1 (Pro)
  • SEO version: 3.6.6
  • PHP version: 7.2.33
  • Database driver & version: MySQL 5.5.62

I haven't been able to see anything related in the log files but there are Javascript errors showing the developer tools console.

Screenshot 2020-09-25 at 13 05 36

icreatestuff avatar Sep 25 '20 12:09 icreatestuff

To update on this I set 'Preview Target' URLs for each of the sections on my site which has now fixed this problem. But I don't think Preview Targets are a requirement in Craft so this plugin needs to bail out before trying to ajax for a preview target URL if none exists.

icreatestuff avatar Sep 28 '20 13:09 icreatestuff

I'm currently seeing this same issue and I have Preview Targets set for all sections.

Craft version: 3.5.11.1 (Pro)
SEO version: 3.6.6
PHP version: 7.4.9
Database driver & version: MySQL 5.7.31

I'm able to see a Preview of the content from my control panel when I'm managing an entry but I still get this same failure message from the SEO plugin.

architech99 avatar Sep 28 '20 16:09 architech99

The issue appears to be here. When I step through, I see that window.draftEditor produces an object but de remains undefined for some reason.

preview-error

Stack Trace

SEO:  Failed to retrieve entry preview fail.js:4:33
    r fail.js:4
    update EntryMarkup.js:86
    update EntryMarkup.js:40
    calculate KeywordChecklist.js:54
    b FocusKeywords.js:182
    setActiveKeyword FocusKeywords.js:164
    initKeywords FocusKeywords.js:82
    b FocusKeywords.js:39
    <anonymous> SeoField.js:56
    <anonymous> 2-landing-page:1526
    jQuery 13
undefined KeywordChecklist.js:138:11
    calculate KeywordChecklist.js:138
    (Async: promise callback)
    calculate KeywordChecklist.js:136
    b FocusKeywords.js:182
    setActiveKeyword FocusKeywords.js:164
    initKeywords FocusKeywords.js:82
    b FocusKeywords.js:39
    <anonymous> SeoField.js:56
    <anonymous> 2

architech99 avatar Sep 28 '20 16:09 architech99

I'm also seeing this issue, same as described above.

mtnorthrop avatar Sep 30 '20 09:09 mtnorthrop

Have the same issue.

Craft CMS 3.5.11.1 (Pro)
SEO version 3.6.6
PHP version 7.3.14
Database driver & version MySQL 5.7.31

Screenshot from console

image

AlexFUNBIT avatar Oct 01 '20 16:10 AlexFUNBIT

Same issue on v3.6.6 with craft v3.4.30


SEO:  Failed to retrieve entry preview fail.js:4:33
    r fail.js:4
    update SeoField.min.js:1
    update SeoField.min.js:1
    calculate SeoField.min.js:1
    b SeoField.min.js:1
    setActiveKeyword SeoField.min.js:1
    initKeywords SeoField.min.js:1
    b SeoField.min.js:1
    <anoniem> SeoField.min.js:1
    <anoniem> 768937

rauwebieten avatar Oct 07 '20 14:10 rauwebieten

@alexjcollins thanks for working through some of the recent issues. Is there any sort of ETA of fixes on those you've labelled as bugs? Cheers.

icreatestuff avatar Nov 09 '20 09:11 icreatestuff

The JS source files doesn't exits on this repos, there is only the compiled files. There is a pull request that resolve the issue. While waiting for the pull request to be merged, this is a workaround to bypass the bug. Simply add <!--<svg></svg>--> anywhere in the template.

oayoub84 avatar Nov 17 '20 22:11 oayoub84

Thanks @masix ! I just tried that out and it gets me around the issue. Plugin works like a charm now.

architech99 avatar Nov 17 '20 23:11 architech99

@masix, @architech99 what do you mean "anywhere in the template"? A plugin template?

geenious avatar Feb 12 '21 23:02 geenious

@geenious I added the tag to my base twig template for the frontend of the website and it fixed the error message. @masix Your fix worked, but I have no idea why. Would you be able to explain how adding this tag to the template fixes the issue? I'm really curious! :-)

mtnorthrop avatar Feb 27 '21 10:02 mtnorthrop

@mtnorthrop the problem was that in EntryMarkup.js the script is looking for svg using match() and looping over the result without checking if there is none (the match() return null is there is no result), so looping using (forEach) on a null variable throws an exception. In the workaround we add svg inside html comment (so it will not affect the page rendering) and then the js will find at least one result, so it will not crashes.

oayoub84 avatar Feb 27 '21 16:02 oayoub84

@masix Thanks for the explanation, and for digging into the problem; it's great having a workaround!

mtnorthrop avatar Feb 27 '21 17:02 mtnorthrop

@oayoub84 Thank you for this workaround!

jakepm avatar Mar 19 '21 11:03 jakepm

@oayoub84 - worked for me too!

jamiematrix avatar Jun 17 '21 09:06 jamiematrix

The issue for me was a missing "Preview Targets" row entry in the Section's Settings tab.

zadro avatar Oct 05 '21 20:10 zadro