Page MenuHomePhabricator

Fatal error when a newsletter sharing a main page with a deleted newsletter is deleted
Open, Needs TriagePublic

Description

Well, this is a wild test case

  1. Create a newsletter Foo with mainpage Bar
  2. Delete Newsletter:Foo
  3. Create a new newsletter Failure with mainpage Bar
  4. Try deleting Newsletter:Failure - it will throw MWException

Reason: We have a UNIQUE(mainpageid, 'active`) in the db making sure that no two newsletters can have same main_page and be active or inactive at the same time.

Should we pursue it, I dont know!

Event Timeline

@tonythomas: Hmm, maybe we should add another, not UNIQUE colummn: "deactive_main_page_id". In that case, when user deletes newsletter, "main_page_id" moves to "deactive_man_page_id". "main_page_id" should be unique, and "main_page_id" is without any index. Its not a good solution, but it should work.

Pppery renamed this task from Strange chance of fatal after latest changes in Newsletter extension to Fatal error when a newsletter sharing a main page with a deleted newsletter is deleted.Feb 1 2017, 8:15 PM

Anything producing a fatal error should be pursued, I'd say.

I've tested a lot of things now, and I don't really know why we have set "nl_main_page_id" and "nl_active" to unique? - All the problems will be solved if we don't make them unique. There is code that make sure that you can't use two newsletters on one page etc. It will also eliminate the fatal error.

FWIW, this "unique" is an index, not a column or anything else

CREATE UNIQUE INDEX /*i*/nl_main_page_active ON /*_*/nl_newsletters (nl_main_page_id, nl_active);

What is nl_main_page_id used for exactly? What is a newsletter main page?

When creating a new newsletter, Main Page is the page defined as the "home" of the newsletter. It makes sense that is is unique because one can assume ust one wiki page designated as wiki page related to just one newsletter. Then again, it would not be the end of the world if checking this uniqueness causes problems and we remove the check.

See related: T177064: When creating a newsletter, the default newsletter page should be offered as Main Page

When creating a new newsletter, Main Page is the page defined as the "home" of the newsletter. It makes sense that is is unique because one can assume ust one wiki page designated as wiki page related to just one newsletter. Then again, it would not be the end of the world if checking this uniqueness causes problems and we remove the check.

Just do it in software (ie in PHP in the extension) where it's easier to handle the errors :)

Apparently this is due to a permission check. Will fix it in an upcoming PR.

Change 977269 had a related patch set uploaded (by Pppery; author: olumpatwit):

[mediawiki/extensions/Newsletter@master] Schema change to drop unique bit from indexes that aren't quite unique

https://gerrit.wikimedia.org/r/977269