{"action":"created","issue":{"url":"https://api.github.com/repos/divio/django-cms/issues/4940","repository_url":"https://api.github.com/repos/divio/django-cms","labels_url":"https://api.github.com/repos/divio/django-cms/issues/4940/labels{/name}","comments_url":"https://api.github.com/repos/divio/django-cms/issues/4940/comments","events_url":"https://api.github.com/repos/divio/django-cms/issues/4940/events","html_url":"https://github.com/divio/django-cms/issues/4940","id":127888302,"number":4940,"title":"Publishing pages intermittently breaks cms_page.publisher_public_id foreign key","user":{"login":"mikemcgowan","id":2492670,"avatar_url":"https://avatars.githubusercontent.com/u/2492670?v=3","gravatar_id":"","url":"https://api.github.com/users/mikemcgowan","html_url":"https://github.com/mikemcgowan","followers_url":"https://api.github.com/users/mikemcgowan/followers","following_url":"https://api.github.com/users/mikemcgowan/following{/other_user}","gists_url":"https://api.github.com/users/mikemcgowan/gists{/gist_id}","starred_url":"https://api.github.com/users/mikemcgowan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikemcgowan/subscriptions","organizations_url":"https://api.github.com/users/mikemcgowan/orgs","repos_url":"https://api.github.com/users/mikemcgowan/repos","events_url":"https://api.github.com/users/mikemcgowan/events{/privacy}","received_events_url":"https://api.github.com/users/mikemcgowan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/divio/django-cms/labels/status:%20accepted","name":"status: accepted","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/divio/django-cms/milestones/43","html_url":"https://github.com/divio/django-cms/milestones/3.2.x","labels_url":"https://api.github.com/repos/divio/django-cms/milestones/43/labels","id":1389260,"number":43,"title":"3.2.x","description":"","creator":{"login":"mkoistinen","id":615759,"avatar_url":"https://avatars.githubusercontent.com/u/615759?v=3","gravatar_id":"","url":"https://api.github.com/users/mkoistinen","html_url":"https://github.com/mkoistinen","followers_url":"https://api.github.com/users/mkoistinen/followers","following_url":"https://api.github.com/users/mkoistinen/following{/other_user}","gists_url":"https://api.github.com/users/mkoistinen/gists{/gist_id}","starred_url":"https://api.github.com/users/mkoistinen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkoistinen/subscriptions","organizations_url":"https://api.github.com/users/mkoistinen/orgs","repos_url":"https://api.github.com/users/mkoistinen/repos","events_url":"https://api.github.com/users/mkoistinen/events{/privacy}","received_events_url":"https://api.github.com/users/mkoistinen/received_events","type":"User","site_admin":false},"open_issues":13,"closed_issues":31,"state":"open","created_at":"2015-11-02T15:54:55Z","updated_at":"2016-04-08T14:40:42Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-01-21T10:06:53Z","updated_at":"2016-04-08T17:59:28Z","closed_at":null,"body":"Our production systems are currently on Python 2.7, Django 1.7, CMS 3.1, MySQL 5.6. (We are in the process of moving to Django 1.8, CMS 3.2.)\r\n\r\nOccasionally (at least 3 times in the last 6 months) publishing a page causes the `cms_page.publisher_public_id` foreign key to get set to null on either _a)_ the draft version or _b)_ both the draft and non-draft versions of the 'pair' of `cms_page` records. This corrupt data can then result in several unhandled exceptions, including attempting to invoke `cms.api.get_page_draft` on a non-draft page:\r\n\r\n```python\r\ndef get_page_draft(page):\r\n    \"\"\"\r\n    Returns the draft version of a page, regardless if the passed in\r\n    page is a published version or a draft version.\r\n\r\n    :param page: The page to get the draft version\r\n    :type page: :class:`cms.models.pagemodel.Page` instance\r\n    :return page: draft version of the page\r\n    :type page: :class:`cms.models.pagemodel.Page` instance\r\n    \"\"\"\r\n    if page:\r\n        if page.publisher_is_draft:\r\n            return page\r\n        else:\r\n            return page.publisher_draft\r\n    else:\r\n        return None\r\n```\r\n\r\nSpecifically, when invoked on a non-draft page, the line `return page.publisher_draft` throws an exception because the reverse lookup fails due to the foreign key being null.\r\n\r\nThis issue is intermittent and we cannot reproduce the problem, so unfortunately, I'm unable to run it through a debugger to get any better information. "},"comment":{"url":"https://api.github.com/repos/divio/django-cms/issues/comments/207538123","html_url":"https://github.com/divio/django-cms/issues/4940#issuecomment-207538123","issue_url":"https://api.github.com/repos/divio/django-cms/issues/4940","id":207538123,"user":{"login":"vishnuratheesh","id":1498605,"avatar_url":"https://avatars.githubusercontent.com/u/1498605?v=3","gravatar_id":"","url":"https://api.github.com/users/vishnuratheesh","html_url":"https://github.com/vishnuratheesh","followers_url":"https://api.github.com/users/vishnuratheesh/followers","following_url":"https://api.github.com/users/vishnuratheesh/following{/other_user}","gists_url":"https://api.github.com/users/vishnuratheesh/gists{/gist_id}","starred_url":"https://api.github.com/users/vishnuratheesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vishnuratheesh/subscriptions","organizations_url":"https://api.github.com/users/vishnuratheesh/orgs","repos_url":"https://api.github.com/users/vishnuratheesh/repos","events_url":"https://api.github.com/users/vishnuratheesh/events{/privacy}","received_events_url":"https://api.github.com/users/vishnuratheesh/received_events","type":"User","site_admin":false},"created_at":"2016-04-08T17:59:28Z","updated_at":"2016-04-08T17:59:28Z","body":"I experienced the same on Django 1.8.9 / Django-CMS 3.2.0 / Postgres 9.1\r\n\r\nThe management command helped! Thanks a bunch @mikemcgowan"}}