MT 4.0 に上げてから、月別アーカイブなどで使用している MTEntriesタグでsort_order="ascend"が効かなくなった。
いろいろ調べてみたら、sort_byとか言う属性もあるようなので指定してみたけど変わらず。
結局、ソースを追いかけたらどうもMTのバグらしい。
lib/MT/Template/ContextHandlers.pm に以下のパッチをあてたら、無事にsort_order="ascend"が効くようになった。
どうも、perlの$と@と%と#と\の関係が良くわかってないので、デバッグにも苦労する。
いろいろ調べてみたら、sort_byとか言う属性もあるようなので指定してみたけど変わらず。
結局、ソースを追いかけたらどうもMTのバグらしい。
lib/MT/Template/ContextHandlers.pm に以下のパッチをあてたら、無事にsort_order="ascend"が効くようになった。
どうも、perlの$と@と%と#と\の関係が良くわかってないので、デバッグにも苦労する。
*** ContextHandlers.pm.ORIG 2007-08-04 06:20:03.000000000 +0900
--- ContextHandlers.pm 2007-08-21 00:04:34.000000000 +0900
***************
*** 2917,2929 ****
if ( $col ne 'score' ) {
if (my $def = $class->column_def($col)) {
if ($def->{type} =~ m/^integer|float$/) {
! @entries = $so eq 'ascend' ?
! sort { $a->$col() <=> $b->$col() } @entries :
! sort { $b->$col() <=> $a->$col() } @entries;
} else {
! @entries = $so eq 'ascend' ?
! sort { $a->$col() cmp $b->$col() } @entries :
! sort { $b->$col() cmp $a->$col() } @entries;
}
$no_resort = 1;
}
--- 2917,2929 ----
if ( $col ne 'score' ) {
if (my $def = $class->column_def($col)) {
if ($def->{type} =~ m/^integer|float$/) {
! @$entries = $so eq 'ascend' ?
! sort { $a->$col() <=> $b->$col() } @$entries :
! sort { $b->$col() <=> $a->$col() } @$entries;
} else {
! @$entries = $so eq 'ascend' ?
! sort { $a->$col() cmp $b->$col() } @$entries :
! sort { $b->$col() cmp $a->$col() } @$entries;
}
$no_resort = 1;
}
