Bug #872

The comment auto-close for articles checks created_at, and not published_at

Added by nick-recoil-org - 688 days ago. Updated 294 days ago.

Status :Feedback Start :
Priority :Normal Due date :
Assigned to :scott - % Done :

0%

Category :frontend
Target version :-
Resolution :


Description

I had an issue with a post which was created weeks ago, but only recently published. SpamProtection#article_closed? in lib/spam_protection.rb checks the created_at date, rather than the published_at date.

This case seemed to be handled badly, with a NilClass issue caught in the comment post in the articles controller. This will also need checking.

Also, should the themes be using article.comments_closed? rather than article.comments_allowed? The comments_closed? method does the correct check against sp_article_auto_close rather than just looking at the boolean in the articles table.

History

08/16/2006 07:26 PM - nick-recoil-org -

Of course I mean SpamProtection#comments_closed? rather than article_closed?

08/16/2006 07:31 PM - sprewell -

I just copied and pasted the created_at line when I submitted that method. I'm going to go through the code and try to fix all remaining created_at problems. I'll also look at the problems you had with that method and submit a patch.

08/16/2006 07:56 PM - nick-recoil-org -

This is getting a little confusing, so I'll post what turned up in my production.log:

-----------------------------------
Processing ArticlesController#comment (for IP_ADDRESS at 2006-08-14 01:57:46) [POST]
Session ID: 34d490c75ca47cf9ca67f00033053444
Parameters: {"commit"=>"Submit", "action"=>"comment", "id"=>"34", "controller"=>"articles", "comment"=>{"body"=>"comment body", "author"=>"tester", "url"=>"", "email"=>""}}
[SP] Blocked interaction with ARTICLE_NAME_HERE

NoMethodError (undefined method @errors' for nil:NilClass):
/app/controllers/articles_controller.rb:111:in @comment'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in @perform_action_without_filters'

[Blah blah full backtrace]

Rendering actionerrorlayoutfalse within ../../themes/scribbish/layouts/default
Rendering articles/error


So I think the issue is with the assumption that the comment gets created regardless of errors, and when the article_controller.rb gets to this line (111):

STDERR.puts @comment.errors.inspect

it blows up as @comment never got instantiated, because of something during the creation process

08/18/2006 01:34 AM - scott -

  • Status changed from New to Closed
  • Resolution set to fixed

(In r1225) Use published_at for comment spam checks. Closes #1089

08/24/2006 02:33 AM - sprewell -

  • Status changed from Closed to Feedback
  • Resolution deleted (fixed)

OK, I finally got around to checking all uses of created_at in trunk and generated the attached patch. Scott's fix only works for the scribbish theme (and other themes that similarly override the article view), this fix should work for the rest. Please check over all the substitutions of published_at for created_at to make sure they're necessary. I found other places where created_at was used but they were mostly in admin so I let those stay the way they were. I also got rid of that stderr.puts line that Nick complains about, I think it was the only one left. The theme overriding the views issue with scribbish raises the possibility of other errors in other themes. I think one of the maintainers or the scribbish author should go over scribbish to make sure it's doing stuff the same way as azure. I'm coming up with a way for Tim to do more generic updates of the themes that are stored at his repository to keep them compatible with trunk.

Also available in: Atom PDF