The attachment table rendering code assumes the order of attachments in the meta-data. But AFAICT that order is random with the change to the indexing scheme in meta. As a result attachments are rendered in no particular order. Because Cairo always added to the end of the attachment table, the order should be increasing date (most recent at bottom).
Index: lib/TWiki/Attach.pm
===================================================================
--- lib/TWiki/Attach.pm (revision 8890)
+++ lib/TWiki/Attach.pm (working copy)
@@ -79,7 +79,7 @@
my $showAll = $attrs->{all};
my $showAttr = $showAll ? 'h' : '';
- my $a = ( $showAttr ) ? ':A' : '';
+ my $at = ( $showAttr ) ? ':A' : '';
my $title = $attrs->{title} || '';
my @attachments = $meta->find( 'FILEATTACHMENT' );
@@ -89,8 +89,8 @@
$templates->readTemplate('attachtables');
my $rows = '';
- my $row = $templates->expandTemplate('ATTACH:files:row'.$a);
- foreach my $attachment ( @attachments ) {
+ my $row = $templates->expandTemplate('ATTACH:files:row'.$at);
+ foreach my $attachment ( sort { $a->{date} <=> $b->{date} } @attachments ) {
my $attrAttr = $attachment->{attr};
if( ! $attrAttr || ( $showAttr && $attrAttr =~ /^[$showAttr]*$/ )) {
@@ -101,8 +101,8 @@
my $text = '';
if( $showAll || $rows ne '' ) {
- my $header = $templates->expandTemplate('ATTACH:files:header'.$a);
- my $footer = $templates->expandTemplate('ATTACH:files:footer'.$a);
+ my $header = $templates->expandTemplate('ATTACH:files:header'.$at);
+ my $footer = $templates->expandTemplate('ATTACH:files:footer'.$at);
$text = $header.$rows.$footer;
}
fixes it.
SVN 8967 (already merged to TWiki4)
CC
SVN 9012 is also noted on this item, but is not merged to TWiki4 (perl 5.6 stuff + meta.pm sorting). Any reason?
--
SP
All the required merges are complete.
CC
Closed with the release of 4.0.2
KJL