seo-pro icon indicating copy to clipboard operation
seo-pro copied to clipboard

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

Open wanze opened this issue 1 year ago • 0 comments

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

  • SeoPro is installed
  • Multisite enabled with at least 2 sites
  • Stache watcher set to false

How to reproduce

  • Create a new entry in the default site. Save it unpublished (Save draft)
  • Publish the entry (Save & Publish)
  • Create a new entry for the second site using the default site as origin, save it published or unpublished
  • In the sidebar, navigate back to the entry of the default site

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:

  • 2023-01-04.article-fr.md (correct file)
  • 2023-01-04.article-de.1.md (wrong file)
  • 2023-01-04.article-de.md (wrong file)
  • 2023-01-04.wha.md (wrong file)

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

wanze avatar Jan 04 '23 12:01 wanze