question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Page.publisher_public_id sometimes loses it's reference

See original GitHub issue

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.)

Occasionally (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:

def get_page_draft(page):
    """
    Returns the draft version of a page, regardless if the passed in
    page is a published version or a draft version.

    :param page: The page to get the draft version
    :type page: :class:`cms.models.pagemodel.Page` instance
    :return page: draft version of the page
    :type page: :class:`cms.models.pagemodel.Page` instance
    """
    if page:
        if page.publisher_is_draft:
            return page
        else:
            return page.publisher_draft
    else:
        return None

Specifically, 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.

This 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.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
mikemcgowancommented, Jan 21, 2016

Below is a Django management command that fixes the null/lost/corrupt cms_page.publisher_public_id columns. It works on the assumption that the equivalent columns in cms_title are okay. In our experience, it’s only the cms_page.publisher_public_id columns that get broken, so this assumption holds for us.

from django.core.management.base import BaseCommand

from cms.models import Title


class Command(BaseCommand):
    help = 'Fix CMS pages (publisher_public_id foreign key)'

    def handle(self, *args, **options):
        ts = Title.objects.filter(
            publisher_is_draft=False,
            page_id__isnull=False,
            publisher_public_id__isnull=False
        )

        fixed_count = 0

        # for each of the (non-draft, draft) title pairs, fix the equivalent (non-draft, draft) page pairs
        for t in ts:
            fixed = False

            if t.publisher_public.page.publisher_public is None:
                self.stdout.write('Draft page id {} has a null publisher_public_id (it should be {})'.format(
                    t.publisher_public.page_id,
                    t.page_id
                ))
                t.publisher_public.page.publisher_public = t.page
                t.publisher_public.page.save()
                fixed = True

            if t.page.publisher_public is None:
                self.stdout.write('Non-draft page id {} has a null publisher_public_id (it should be {})'.format(
                    t.page_id,
                    t.publisher_public.page_id
                ))
                t.page.publisher_public = t.publisher_public.page
                t.page.save()
                fixed = True

            if fixed:
                fixed_count += 1

        self.stdout.write('Fixed {} pairs of pages.'.format(fixed_count))
0reactions
Aiky30commented, Dec 8, 2020

Closing as this issue appears to be stale and there is no feedback that the proposed fixes in 3.4 did not work. I have never heard of this on any project 3.5+ so assuming fixed.

Due to the age of this issue we are unable to safely accept the contribution. If you feel this issue is still required please inform a member of our technical committee: nicolai@django-cms.org.

Nevertheless we thank you for your participation and would like to emphasize that we do not want to discourage you in your contribution to the django CMS project. On the contrary, we encourage everyone who is interested in the success of django CMS to join us!

If you want to learn more about the work of the technical committee, our product vision and how you can become a member of the dCA, you can find all information here:

We are looking forward to every companion who would like to shape the future of django CMS together with us!

If you have any questions, feel free to reach out to Nicolai, our Community Manager: nicolai@django-cms.org

Sign up for the Association now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Page Publishing | Complaints | Better Business Bureau® Profile
Authors should not market based on the ISBN. (Publishers will often reissue when there is a significant change to the book or sometimes...
Read more >
Publicity - Page Publishing
Your publicity team will utilize information from your About the Author (ATA), as well as your back cover summary to prepare press materials...
Read more >
Why Are Publishers and Editors Wasting Time Formatting ...
One reason why reference lists shoud be in reasonably good shape upon manuscript submission is so that reviewers can check the references.
Read more >
Why has advertising -- a full-page ad every few pages of text ...
Because when book publishers have tried to sell ads in their books, they have failed miserably. Why don't advertisers want to pay for...
Read more >
Book Publishers To Avoid And Watch Out For New Author ...
A lot has been written about possible Page Publishing scams. ... So not only do you lose your money, but you also lose...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found