statamic / seo-pro

An all-in-one site reporting, metadata wrangling, Open Graph managing, Twitter card making, sitemap generating, turn-key addon for Statamic.
https://statamic.com/addons/statamic/seo-pro
52 stars 34 forks source link

Multisite: Lost content in control panel and multiple .md files for localized entries #250

Open wanze opened 1 year ago

wanze commented 1 year ago

This is the same issue previously opened in the statamic/cms repo (https://github.com/statamic/cms/issues/7077), before figuring out that this only happens when SeoPro is installed.

https://user-images.githubusercontent.com/2118742/210557615-82b20d65-d8a8-491d-a6ea-ccdc77f74e79.mp4

Preconditions

How to reproduce

Notice that the just created entry for the second site is not existing anymore (red/crossed). If you know click again on it, Statamic will create a new file on the disk and the previous content is no longer visible in the control panel. 🙀You can repeat this over and over again and create multiple files for the same entry. Clearing the Stache does not fix it, you have to manually remove the "wrong" files from the disk.

The above screen recording produced 4 files for the "FR" site, all having different IDs but having the same correct origin:

How to fix

This issue does not happen if commenting out the listeners where the ensureSeoFields method is called in Statamic\SeoPro\Subscriber.

class Subscriber
{
    /**
     * Subscribed events.
     *
     * @var array
     */
    protected $events = [
//        Events\EntryBlueprintFound::class => 'ensureSeoFields',
//        Events\TermBlueprintFound::class => 'ensureSeoFields',
        Events\CollectionSaved::class => 'clearSitemapCache',
        Events\EntrySaved::class => 'clearSitemapCache',
        Events\TaxonomySaved::class => 'clearSitemapCache',
        Events\TermSaved::class => 'clearSitemapCache',
    ];

Environment

Environment
Application Name: Statamic-Sandbox
Laravel Version: 9.45.1
PHP Version: 8.1.13
Composer Version: 2.4.4
Environment: local
Debug Mode: ENABLED
URL: statamic-sandbox.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 1
Antlers: regex
Stache Watcher: Disabled
Static Caching: Disabled
Version: 3.3.63 PRO

Statamic Addons
statamic/seo-pro: 3.1.3