nystudio107 / craft-seomatic

SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.
https://nystudio107.com/plugins/seomatic
Other
166 stars 71 forks source link

Content SEO Section is blank #1517

Closed neokoenig closed 1 month ago

neokoenig commented 1 month ago

Describe the bug

Missing graph and progress, empty Content SEO section... any ideas?

To reproduce

Go to SEO settings section

Expected behaviour

For the content SEO Section to exist Data was there previously

Screenshots

image image

Versions

khalwat commented 1 month ago

Check your JavaScript console in your browser for errors?

Also if you go to SEOmatic -> Content SEO does that also not appear?

neokoenig commented 1 month ago

No console errors.

Content SEO section renders in the dom as follows:

<div class="flex-grow">
    <h2 class="centeralign" style="font-weight: 200;">Content SEO Setup</h2>
    <div id="ContentSEOChart" style="width: 300px; margin: 0px auto;">
        <div class="cursor-pointer" style="min-height: 310px;">
            <div id="apexchartsypxtpxr1" class="apexcharts-canvas apexchartsypxtpxr1 apexcharts-theme-"
                style="width: 300px; height: 310px;"><svg id="SvgjsSvg1126" width="300" height="310"
                    xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink"
                    xmlns:svgjs="http://svgjs.dev" class="apexcharts-svg" xmlns:data="ApexChartsNS"
                    transform="translate(0, 0)">
                    <foreignObject x="0" y="0" width="300" height="310">
                        <div class="apexcharts-legend" xmlns="http://www.w3.org/1999/xhtml"></div>
                    </foreignObject>
                    <g id="SvgjsG1128" class="apexcharts-inner apexcharts-graphical" transform="translate(23, 0)">
                        <defs id="SvgjsDefs1127">
                            <clipPath id="gridRectMaskypxtpxr1">
                                <rect id="SvgjsRect1129" width="262" height="316" x="-3" y="-3" rx="0" ry="0"
                                    opacity="1" stroke-width="0" stroke="none" stroke-dasharray="0" fill="#fff"></rect>
                            </clipPath>
                            <clipPath id="forecastMaskypxtpxr1"></clipPath>
                            <clipPath id="nonForecastMaskypxtpxr1"></clipPath>
                            <clipPath id="gridRectMarkerMaskypxtpxr1">
                                <rect id="SvgjsRect1130" width="260" height="314" x="-2" y="-2" rx="0" ry="0"
                                    opacity="1" stroke-width="0" stroke="none" stroke-dasharray="0" fill="#fff"></rect>
                            </clipPath>
                        </defs>
                        <g id="SvgjsG1133" class="apexcharts-radialbar"></g>
                        <line id="SvgjsLine1134" x1="0" y1="0" x2="256" y2="0" stroke="#b6b6b6" stroke-dasharray="0"
                            stroke-width="1" stroke-linecap="butt" class="apexcharts-ycrosshairs"></line>
                        <line id="SvgjsLine1135" x1="0" y1="0" x2="256" y2="0" stroke-dasharray="0" stroke-width="0"
                            stroke-linecap="butt" class="apexcharts-ycrosshairs-hidden"></line>
                    </g>
                    <g id="SvgjsG1131" class="apexcharts-datalabels-group" transform="translate(0, 0) scale(1)"></g>
                    <g id="SvgjsG1132" class="apexcharts-datalabels-group" transform="translate(0, 0) scale(1)"></g>
                </svg></div>
        </div>
    </div>
    <div style="text-align: left; margin: 0px auto; display: inline-block;">
        <h4>Content SEO Setup Checklist:</h4>
        <ul class="checkboxChecklist"></ul>
    </div>
</div>

admin/seomatic/content is the same as the screenshot I posted previously. (Clicking on the blank section still takes you there)

Have tried clearing all caches etc..

XHR request to index.php/admin/actions/seomatic/content-seo/meta-bundles?sort=sourceName%7Casc&page=1&per_page=20&siteId=1&filter=new returns an empty array.

khalwat commented 1 month ago

Do you not have any sites or sections set up perhaps? Is this a new site or an existing site?

neokoenig commented 1 month ago

Existing site where the plugin has been working for years.... Annoying I hadn't noticed when it happened - it just got reported to me the SEO wasn't working properly.

neokoenig commented 1 month ago

In the DB, there's only one row in the seomatic_metabundles table (the first row, __GLOBAL_BUNDLE__ )

I found an old DB backup which had the additional rows for sections & categories etc;

As an experiment I re-imported the old rows, cleared the SEO caches etc, but no joy - they just get deleted as soon as the admin seomatic content page is loaded - I'm not sure how those rows are generated.

khalwat commented 1 month ago

Did you recently update the plugin and/or Craft?

Is it possible that your Site(s) does not have URLs enabled? Or is it possible the Site itself is disabled?

neokoenig commented 1 month ago

Did you recently update the plugin and/or Craft?

Looks like the behaviour started "nystudio107/craft-seomatic": "4.0.48", -> "nystudio107/craft-seomatic": "4.1.2"; I updated it to 4.1.3 to see if it would fix the issue.

Is it possible that your Site(s) does not have URLs enabled? Or is it possible the Site itself is disabled?

Site is definitely enabled, and is live in production.

Is it worth me disabling/uninstalling the plugin and trying to reset it up from scratch? (bit of a PITA, but not the end of the world).

khalwat commented 1 month ago

So there is one and only one thing that will ever cause SEOmatic to delete anything from the seomatic_metabundles table, and that is this:

https://github.com/nystudio107/craft-seomatic/blob/develop-v5/src/services/MetaBundles.php#L889

    public function pruneVestigialMetaBundle($metaBundle): bool
    {
        $prune = false;
        $sourceBundleType = $metaBundle->sourceBundleType;
        if ($sourceBundleType && $sourceBundleType !== self::GLOBAL_META_BUNDLE) {
            $seoElement = Seomatic::$plugin->seoElements->getSeoElementByMetaBundleType($sourceBundleType);
            if ($seoElement) {
                $sourceModel = $seoElement::sourceModelFromId($metaBundle->sourceId);
                /** @var Section|CategoryGroup|ProductType|null $sourceModel */
                if ($sourceModel === null) {
                    $prune = true;
                } else {
                    $prune = true;
                    $siteSettings = $sourceModel->getSiteSettings();
                    if (!empty($siteSettings)) {
                        /** @var Section_SiteSettings $siteSetting */
                        foreach ($siteSettings as $siteSetting) {
                            if ($siteSetting->siteId == $metaBundle->sourceSiteId && $siteSetting->hasUrls && SiteHelper::siteEnabledWithUrls($siteSetting->siteId)) {
                                $prune = false;
                            }
                        }
                    }
                }
            } else {
                $prune = true;
            }
        }

        return $prune;
    }

If either the source section doesn't exist, or the site doesn't have URLs enabled, or if the site isn't enabled.

neokoenig commented 1 month ago

Aha.

No base url set.

image

If I set to "has it's own base URL" and added @web, then redo the DB imports, it appears to work...!

neokoenig commented 1 month ago

Thanks for the assist!

khalwat commented 1 month ago

Ah great, glad you got it sorted.