昨日、recently_commented_onが正常に作動しない(各エントリーの最新のコメントではなく、最初についたコメントの時刻順にソートされてしまう)ことについてエントリーを書いた(「アップグレードしたのはよいが・・・」)。具体的にどのようになるかというと
3.2-ja-2をそのまま適用
 |
|
ContextHandlers.pmを書き換え
 |
ちょっと見づらいかもしれないけど、「「良い一週間」でありますように☆」と「Upgrade!」が逆に表示されているのが分かると思う。
この件について、同じような症状が現れたという47thさんからさっそくコメントをいただいた。ということは・・・この問題は私に固有の問題ではなくて、もしかしてLolipop+SQLiteの場合に現れる症状なのかな?
なにぶんまだ情報が少ないので、可能性の一つとして、ということだけど。
ちなみに私もLolipopのレンタルサーバーを使ってるわけだけど、mt-check.cgiを実行すると
サーバーに、「DBD::Pg」がインストールされていない、古いバージョンがインストールされている、もしくは「DBD::Pg」に必要なモジュールがインストールされていません 「DBI」と「DBD::Pg」は、PostgreSQLを使ってデータを管理するために必要です。「DBD::Pg」をインストールする場合は、インストール手順を参照してください。
と表示される。PostgreSQLは使わないので、私の場合は関係ないはず、と思ってスルーしてるけど、なにかこのへんも関係あるのでしょうか・・・???
念のため、各バージョンでの関係箇所を抜き書きしておく。
Movable Type 3.171 (/lib/MT/Template/Context.pm)
} elsif (my $n = $args->{recently_commented_on}) {
$args{‘join’} = [ ‘MT::Comment’, ‘entry_id’,
{ blog_id => $blog_id, visible => 1 },
{ ‘sort’ => ‘created_on’,
direction => ‘descend’,
unique => 1,
limit => $n } ];
$no_resort = 1;
}
@entries = MT::Entry->load(\%terms, \%args);
Movable Type 3.2 ja (/lib/MT/Template/ContextHandlers.pm)
@entries = MT::Entry->load(\%terms, \%args);
if ($args->{recently_commented_on}) {
my @e = sort {$b->comment_latest->created_on <=> $a->comment_latest->created_on}
grep {$_->comment_latest} @entries;
@entries = splice(@e, 0, $args->{recently_commented_on});
$no_resort = 1;
}
Movable Type 3.2 ja 2 (/lib/MT/Template/ContextHandlers.pm)
} elsif (my $n = $args->{recently_commented_on}) {
if (MT::ConfigMgr->instance()->ObjectDriver !~ /postgres/) {
require MT::Comment;
$args{‘join’} = [ ‘MT::Comment’, ‘entry_id’,
{ blog_id => $blog_id, visible => 1 },
{ ‘sort’ => ‘created_on’,
direction => ‘descend’,
unique => 1,
limit => $n } ];
$no_resort = 1;
} else {
$args{‘join’} = [ ‘MT::Comment’, ‘entry_id’,
{ blog_id => $blog_id, visible => 1 },
{ unique => 1 }];
}
}
@entries = MT::Entry->load(\%terms, \%args);
if ($args->{recently_commented_on}
&& MT::ConfigMgr->instance()->ObjectDriver =~ /postgres/) {
my @e = sort {$b->comment_latest->created_on <=> $a->comment_latest->created_on}
@entries;
@entries = splice(@e, 0, $args->{recently_commented_on});
$no_resort = 1;
}
私の場合、3.171から3.2-ja-2へとアップグレードしたので、3.2でどのように稼働するのかは未確認。
あとはどなたか詳しい人が解決してくれることを待ちましょう!(笑)