Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Duplicating pages with multiple languages causes different page IDs for non-primary languages #2163

Open
FrittenKeeZ opened this issue Sep 5, 2018 · 8 comments

Comments

@FrittenKeeZ
Copy link

Describe the bug
Duplicating a page with multiple languages will cause duplicate IDs error.
When trying to resolve the issue, the non-primary languages with get different IDs than the primary, which will blow up the cache/stache.

To Reproduce
Steps to reproduce the behavior:

  1. Create a page with multiple language versions.
  2. Duplicate the page.
  3. See that there's suddenly duplicate IDs and press the button to resolve.
  4. See that Stache updater explodes with Call to a member function in() on null.

Expected behavior
Duplication of pages should work regardless of number of languages.

Screenshots
stache-explosion

Environment details (please complete the following information):

  • Statamic Version: 2.10.4 upgrade
  • OS: Alpine Linux 3.7
  • Web Server: Nginx
  • PHP Version: 7.1
@FrittenKeeZ
Copy link
Author

FrittenKeeZ commented Sep 5, 2018

Worth noting that this is an extremely hard to reproduce bug, which has only occurred on our staging environment. The localized pages will have the same ID, but they will differ from the main language.
This is the only errors we have prior to the crash:

[2018-09-05 14:35:57] stage.ERROR: Cannot add [pages/1.hoteller/17.comwell-hotel-varbergs-kusthotell/4.behandlinger/_3.spabehandlingar-1/index.md] to Stache repository [pages]. File at [pages/1.hoteller/17.comwell-hotel-varbergs-kusthotell/4.behandlinger/_1.spabehandlingar-1/index.md] already exists in repository [pages] with an ID of [4b7daf5a-ec5b-4fcb-a106-9aa1f860e7b2].
[2018-09-05 14:38:12] stage.ERROR: Cannot add [pages/1.hoteller/17.comwell-hotel-varbergs-kusthotell/4.behandlinger/3.spabehandlingar-1/index.md] to Stache repository [pages]. File at [pages/1.hoteller/17.comwell-hotel-varbergs-kusthotell/4.behandlinger/1.spabehandlingar-1/index.md] already exists in repository [pages] with an ID of [4b7daf5a-ec5b-4fcb-a106-9aa1f860e7b2].
[2018-09-05 14:44:56] stage.ERROR: Cannot add [pages/1.hoteller/17.comwell-hotel-varbergs-kusthotell/4.behandlinger/4.spabehandlingar-1-1/index.md] to Stache repository [pages]. File at [pages/1.hoteller/17.comwell-hotel-varbergs-kusthotell/4.behandlinger/1.spabehandlingar-1-1/index.md] already exists in repository [pages] with an ID of [9769d355-1d0f-45f3-980d-b1bf1a8ba7c3].
[2018-09-05 14:44:56] stage.ERROR: Cannot add [pages/1.hoteller/17.comwell-hotel-varbergs-kusthotell/4.behandlinger/5.spabehandlingar-1-1-1/index.md] to Stache repository [pages]. File at [pages/1.hoteller/17.comwell-hotel-varbergs-kusthotell/4.behandlinger/1.spabehandlingar-1-1-1/index.md] already exists in repository [pages] with an ID of [1e607b7a-1697-43ce-97cf-c7c00ebd904b].
[2018-09-05 14:57:08] stage.ERROR: Cannot add [pages/1.hoteller/17.comwell-hotel-varbergs-kusthotell/3.spa/1.behandlinger/3.spabehandlingar-hand-fot/index.md] to Stache repository [pages]. File at [pages/1.hoteller/17.comwell-hotel-varbergs-kusthotell/4.behandlinger/3.spabehandlingar-hand-fot/index.md] already exists in repository [pages] with an ID of [4b7daf5a-ec5b-4fcb-a106-9aa1f860e7b2].

@FrittenKeeZ
Copy link
Author

FrittenKeeZ commented Sep 25, 2018

Hey @jackmcdade and @jasonvarga

We're having a really rough time with multiple languages - we get a lot of duplicate ID issues and editors only use CP... I don't know how or why it's happening, but we're losing credibility with our client, as they think the system is unstable with these errors, which potentially can force the site to crash.

We need this to be resolved once and for all.

@FrittenKeeZ
Copy link
Author

This sadly also occurs when moving pages around.

@nobodyiscertain
Copy link

Any update on this one? I've got a client site that is having the same issue when reordering or removing pages. Also a site with multiple languages.

Let me know what info I can provide to help debug further.

@FrittenKeeZ
Copy link
Author

@nobodyiscertain how much content do they have on their site? We have a patch in place for locking the Stache when pages are being moved around, but Stache still isn't always updated correctly after the reordering - but corruption seems to be prevented with it.

diff --git statamic/core/Http/Controllers/PagesController.php statamic/core/Http/Controllers/PagesController.php
index 5b79402..52af909 100644
--- statamic/core/Http/Controllers/PagesController.php
+++ statamic/core/Http/Controllers/PagesController.php
@@ -161,10 +161,20 @@ class PagesController extends CpController
     {
         $this->authorize('pages:reorder');
 
-        // Grab the JSON payload
-        $tree = $this->request->input('pages');
+        // Hang it there, this might take a while!
+        set_time_limit(0);
 
-        $reorderer->reorder($tree);
+        if (app('stache')->lock()->acquire(true)) {
+            // Grab the JSON payload
+            $tree = $this->request->input('pages');
+
+            $reorderer->reorder($tree);
+
+            app('stache')->lock()->release();
+        }
 
         Stache::update();

@nobodyiscertain
Copy link

Quite a bit of content, hundreds of pages/collection entries. Does that patch work with lots of content?

@FrittenKeeZ
Copy link
Author

It works a lot better than without the patch, that much I can say.

@nobodyiscertain
Copy link

Patching core code isn't ideal, but will give it a shot and see how it goes. Thanks for the help!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants