Site Notes

Update on RTH Edit Comment Bug

By Ryan McGreal
Published April 22, 2010

A few RTH readers have reported an occasional issue in which they try to edit a recently-posted comment but the page says the window to edit comments has already closed.

The bug might have something to do with the fact that comments have been showing a posted datestamp an hour before they were actually posted (What? The internet spans more than one time zone??). However, the bug occurs only sporadically and I haven't yet been able to replicate it.

In the meantime, I've bumped the edit/delete window for new comments from 15 minutes to 90 minutes. I hope this will ameliorate the effects of the bug while I continue to try and chase it down.

If you have any suggestions, please feel free to leave a comment on this blog entry or the bug report on Github.

Ryan McGreal, the editor of Raise the Hammer, lives in Hamilton with his family and works as a programmer, writer and consultant. Ryan volunteers with Hamilton Light Rail, a citizen group dedicated to bringing light rail transit to Hamilton. Ryan writes a city affairs column in Hamilton Magazine, and several of his articles have been published in the Hamilton Spectator. He also maintains a personal website and has been known to post passing thoughts on Twitter @RyanMcGreal. Recently, he took the plunge and finally joined Facebook.


View Comments: Nested | Flat

Read Comments

[ - ]

By crhayes (registered) - website | Posted April 23, 2010 at 00:43:36

There's an easy way to fix this... WordPress ;)

All joking aside, I have seen others with similar issues (on stackoverflow for example) where subtracting datetimes can cause buggy result records.

What if you tried using TIMESTAMPDIFF?

select *, now() as now, TIMESTAMPDIFF(SECOND, date_posted, now()) as timediff from comments where comment_id = :comment_id

You can use it with a SECOND argument.

P.S. Why don't you use WordPress? I'm guessing it's because developing this is more enjoyable (as a hobby?)... that's how it is for me...

P.P.S. This site is blazingly fast, I'm sure that's a factor ;)

Comment edited by crhayes on 2010-04-22 23:59:37

Permalink | Context

[ - ]

By Ryan (registered) - website | Posted April 23, 2010 at 08:21:50

What if you tried using TIMESTAMPDIFF?

Thanks for the suggestion! I'll definitely try it on my dev setup first chance I get.

Why don't you use WordPress?

Because PHP makes the baby Jesus cry. :)

And you're right: I really do enjoy building stuff - especially in an expressive, powerful language like Python. I've been stuck for the past two weeks writing code in PHP and VBScript for two separate projects, and it's making me a very grumpy programmer.

This site is blazingly fast

I'm very glad to hear that! Python isn't a particularly fast language, and the site runs on shared hosting, but it runs behind nginx and I've tried to optimize for speed (the YSlow Firefox addon is hugely helpful in this regard) - though there's certainly more room for improvement.

Comment edited by administrator Ryan on 2010-04-23 07:30:04

Permalink | Context

[ - ]

By schmadrian (registered) | Posted April 23, 2010 at 10:23:36

Anyone who uses the word 'ameliorate' instantly goes on my Christmas list.

: )

(What size socks do you wear, Ryan...?)

Permalink | Context

[ - ]

By crhayes (registered) - website | Posted April 23, 2010 at 15:39:32


I love programming in PHP, although I don't have any experience in Python. To each their own :)

Permalink | Context

[ - ]

By Ryan (registered) - website | Posted April 23, 2010 at 16:32:04

I just find the quirks of PHP feel like a major drag on my productivity with the language - not only its artifacts, like $dollar $signs $for $variable $names, curly braces and semicolon terminators, but also such missing features as namespaces, block scope, strong typing, first-class objects, method chaining, list comprehensions [1], iterators and generators, and so on. That's not to mention the well-known issue of a bajillion global functions with no apparent rhyme or reason - somearemashedtogether, some_use_underscores and someUseCamelCase - and no orthogonality.

With Python, the coefficient of friction is just a lost smaller. Now, I'm fairly certain that I'm essentially a blub programmer, and I know there are more powerful languages than Python [2], but just moving from PHP/VBS to Python dramatically expanded my conception of how to organize and articulate code. I'm even a better programmer in those languages insofar as I've been able to backport some of the things I learned using Python.


[1] A list comprehension is a one-line syntactic sugar that combines mapping and filtering.

The following example takes a list of the numbers between 0 and 100, pulls out the even numbers, multiplies each even number by two, and dumps the products into a new list:

newlist = [x * 2 for x in range(100) if x % 2 == 0]

This fun example generates a deck of cards:

deck = ['%s%s' % (n, s) for n in '23456789XJQKA' for s in 'HCDS']

[2] I'm dabbling with Ruby, which seems roughly similar albeit with more powerful lambdas. I'm also trying to pick up Lisp, but macros remain outside my conceptual grasp.

Comment edited by administrator Ryan on 2010-04-23 15:35:58

Permalink | Context

[ - ]

By crhayes (registered) - website | Posted April 23, 2010 at 18:45:19

I have done some C and Java as well, but PHP is the first programming language I learned (when I was around 15) and so it has always been my favourite (and I feel comfortable with it).

Some of the features you mentioned have been included in PHP 5 (namespacing, method chaining)... PHP 5 is much more OO.

I don't have experience with Ruby but I know it's really powerful. It used to be difficult to find a Ruby host but I think it has gotten better in recent years.

Comment edited by crhayes on 2010-04-23 17:47:39

Permalink | Context

[ - ]

By Ryan (registered) - website | Posted April 24, 2010 at 08:43:38

I'm about to show my age, but my first programming language was GW-BASIC.

20 GOTO 10

Interestingly, when I first started doing websites years later, the company I worked for was using VBScript on IIS. When I looked at VBScript, it was very familiar to me. :)

Comment edited by administrator Ryan on 2010-04-24 10:02:50

Permalink | Context

[ - ]

By PyGuy (anonymous) | Posted April 27, 2010 at 11:06:09

^If you haven't coded in a language like Python (or Ruby or Lisp or Scheme or...) and you think PHP is pretty good, do yourself the favour and expand your mind with a modern, powerful, DESIGNED language. You'll be a better coder for it and never look at PHP the same again.

Permalink | Context

View Comments: Nested | Flat

Post a Comment

You must be logged in to comment.

Events Calendar

Recent Articles

Article Archives

Blog Archives

Site Tools