CTPUG/wafer

Duplicate page created

Closed this issue · 5 comments

On https://wafertest.debconf.org, I created the following page: https://wafertest.debconf.org/debconf-16-bursaries-instructions, when my Wafer pages page loaded, I saw that there existed two new pages with that title.

When I visit https://wafertest.debconf.org/debconf-16-bursaries-instructions, wafer gives me a debug page that says "get() returned more than one Page -- it returned 2!"

Here is the traceback: http://paste.debian.net/415666/

For now I'll just delete the duplicate page, but @stefanor mentioned that a unique index for pages may be required.

This is a good idea, although page parentage might make it a little complicated.

For what it's worth, this only happened for the first page, I created another page to test if it would happen again and just a single page was created as expected, so perhaps that was just some freak case, I'll keep an eye out for it if it happens again.

drnlm commented

At the moment, there's no check to prevent creating duplicate pages at all, so any glitch that causes the admin form to be submitted twice will result in this behaviour.

Having all the page names and/or page slugs be unique could be done, but breaks some legimate use cases (allowing sprints/venue and talks/venue seems useful, for example). We should however ensure that that the /slug combination is always unique.

We should add list the parent in the admin interface, since the current listing can be confusing when pages with the same name but different parents exist in the database.

Hrm, it looks like we already try to enforce this.

unique_together = (('parent', 'slug'),)

I'm guessing the problem is the null parent? Maybe the index should have slug first? I don't know how compound indexes including NULLs behave...

drnlm commented

SQL unique constraints and foreign keys are one of the grey areas of the standard and thus don't mix particularly well, IIRC, so we can't just rely on the constraint to enforce this.