Recent Comments bug fix

Freshness Warning
This article is over 16 years old. It's possible that the information you read below isn't current.

If you’re using MT’s Recently Commented On feature and you notice that some entries don’t appear there that should, I may have a solution for you. Over at the MT support forums we discovered that at least two of the people experiencing this problem were using MySQL 3.23.45 as their database. Users of later versions of MySQL weren’t having the problem, so it appeared to be a MySQL problem.

A little troubleshooting revealed the culprit. MT uses a temporary table to gather the list of recent comments and that table wasn’t being sorted correctly by MySQL. It took some serious trial and error to figure out how to make it work correctly.

The fix requires that the records be inserted into the temporary table in the order you will want to retrieve them. So a simple ORDER BY statement in the table creation SQL was needed.

To fix the problem, you’ll need to make the following changes. This assumes you are running MT 2.21. Other versions might have different line numbers and code.

Go to <mt>/lib/MT/ObjectDriver/DBI and open mysql.pm. (Replace <mt> with wherever your copy of Movable Type can be found.)

Line 116 reads my $dir = $j_args->{direction} eq 'descend' ? 'desc' : 'asc';. Move it to before line 97, which reads my $ct_sql = "create temporary table tempTable\nselect ";.

Now go down to line 106 where it says $ct_sql .= "where " . join ' and ', @$ct_terms if @$ct_terms;. Right after that line, add a line that reads $ct_sql .= "ORDER BY ${j_tbl}_$j_args->{'sort'} $dir";

That’s it. Upload your newly changed script and rebuild your templates. The usual disclaimer applies. It works for me, it might not work for you. Back everything up before you start and don’t blame me if your computer begins speaking in tongues or emits a foul odor.


Your comments:

Text only, no HTML. URLs will automatically be converted to links. Your email address is required, but it will not be displayed on the site.

Name:

Not your company or your SEO link. Comments without a real name will be deleted as spam.

Email: (not displayed)

If you don't feel comfortable giving me your real email address, don't expect me to feel comfortable publishing your comment.

Website (optional):

Follow me on Twitter

Best Of

  • How not to apply for a job Applying for a job isn't that hard, but it does take some minimal effort and common sense.
  • Movie marketing on a budget Mark Cuban's looking for more cost effective ways to market movies.
  • California State Fair The California State Fair lets you buy tickets in advance from their Web site. That's good. But the site is a horror house of usability problems.
  • Customer reference questions. Sample questions to ask customer references when choosing a software vendor.
  • Comment Spam Manifesto Spammers are hereby put on notice. Your comments are not welcome. If the purpose behind your comment is to advertise yourself, your Web site, or a product that you are affiliated with, that comment is spam and will not be tolerated. We will hit you where it hurts by attacking your source of income.
  • More of the best »

Recently Read

Get More

Subscribe | Archives

Recently

Assumptions and project planning (Feb 18)
When your assumptions change, it's reasonable that your project plans and needs change as well. But too many managers are afraid to go back and re-work a plan that they've already agreed to.
Feature voting is harmful to your product (Feb 7)
There's a lot of problems with using feature voting to drive your product.
Encouraging 1:1s from other managers in your organization (Jan 4)
If you’re managing other managers, encourage them to hold their own 1:1s. It’s such an important tool for managing and leading that everyone needs to be holding them.
One on One Meetings - a collection of posts about 1:1s (Jan 2)
A collection of all my writing on 1:1s
Are 1:1s confidential? (Jan 2)
Is the discussion that occurs in a 1:1 confidential, even if no agreed in the meeting to keep it so?
Skip-level 1:1s are your hidden superpower (Jan 1)
Holding 1:1s with peers and with people far below you on the reporting chain will open your eyes up to what’s really going on in your business.
Do you need a 1:1 if you’re regularly communicating with your team? (Dec 28)
You’re simply not having deep meaningful conversation about the process of work in hallway conversations or in your chat apps.
What agenda items should a manager bring to a 1:1? (Dec 23)
At least 80% of a 1:1 agenda should be driven by your report, but if you also to use this time to work on things with them, then you’ll have better meetings.

Subscribe to this site's feed.

Contact

Adam Kalsey

Mobile: 916.600.2497

Email: adam AT kalsey.com

Twitter, etc: akalsey

Resume

PGP Key

©1999-2019 Adam Kalsey.