Tag counts not updated when editing a post

Bug #711831 reported by Joel Goguen
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
GABlog
Fix Released
Medium
Joel Goguen

Bug Description

I noticed that the list of "Categories" (tags) shown in the 2nd column doesn't behave as expected after a blog post is edited after it's been published. This question isn't about that behavior, but it is about 2 lines of code that I noticed while trying to figure out that issue. What is supposed to happen in the two lines of code isn't clear to me. The two lines below look like the use the same logic, but I think they're supposed to be different. I might not understand what's happening at this point. Thanks again!

http://bazaar.launchpad.net/~jgoguen/gablog/trunk/view/head:/handlers/functions.py#L485
http://bazaar.launchpad.net/~jgoguen/gablog/trunk/view/head:/handlers/functions.py#L486

484
  if not property_hash["draft"]:
485
   before_tags = set(article.tag_keys)
486
   after_tags = set(article.tag_keys)
487
   for removed_tag in before_tags - after_tags:

=====

Hi, I added a related question just a few minutes ago about two other lines of code in functions.py. I think I found the line of code that might be the spot that is causing some unexpected behavior for tags on article/blog post edits.

http://bazaar.launchpad.net/~jgoguen/gablog/trunk/view/head:/handlers/functions.py#L472

If "and article.draft" is removed/commented out, the tag counts are updated as expected. I'm not sure why property_hash would not include draft but the article would be a draft. Thanks for the help!

472
  if not property_hash["draft"] and article.draft:
473
   for key in property_hash["tag_keys"]:
474
    db.get(key).counter.increment()
475
   if CONFIG['send_microblog_update'] and article.article_type == "blog post":
476
    try:
477
     do_status_updates(article)
478
    except Exception, de:
479
     logging.error("Download error: %s", de.message)

Revision history for this message
Joel Goguen (jgoguen) wrote :

Hi Roberto,

Thank you for reporting this issue. The intention here was to avoid counting tags twice (if you submitted a post as a draft, then edited it and saved it as published) but I believe I see that you are correct. I will investigate this further in trunk.

Changed in gablog:
importance: Undecided → Low
Joel Goguen (jgoguen)
Changed in gablog:
milestone: none → 1.0
description: updated
Changed in gablog:
status: New → Confirmed
importance: Low → Medium
Revision history for this message
Joel Goguen (jgoguen) wrote :

Tag counts do not appear to be getting properly decremented when a post is converted to draft form, and do not get updated properly when editing a post in either form.

Revision history for this message
Roberto R (roberto-rabe) wrote :

Thanks Joel!

Joel Goguen (jgoguen)
Changed in gablog:
assignee: nobody → Joel Goguen (jgoguen)
Revision history for this message
Joel Goguen (jgoguen) wrote :

This is resolved in trunk as of revision 372. A near-total rewrite of how post edits are handled was needed to properly account for all cases and simplify the code.

Changed in gablog:
status: Confirmed → Fix Committed
Revision history for this message
Roberto R (roberto-rabe) wrote :

Wow, that's great Joel. I'll check it out.

Joel Goguen (jgoguen)
Changed in gablog:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.